Add flash messages and convert to use Breadcrumb class

This commit is contained in:
Ryan Prather 2024-12-10 12:21:33 -05:00
parent be580ac843
commit bcbd0575b6

View File

@ -6,6 +6,7 @@ use App\Entity\Member;
use App\Entity\User; use App\Entity\User;
use App\Entity\MemberCase; use App\Entity\MemberCase;
use App\Form\MemberFormType; use App\Form\MemberFormType;
use App\Libs\Breadcrumb;
use App\Libs\NavList; use App\Libs\NavList;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -35,8 +36,8 @@ class MemberController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [ 'breadcrumbs' => [
'Case', new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'),
'Members' new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
], ],
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'case' => $case, 'case' => $case,
@ -90,6 +91,11 @@ class MemberController extends AbstractController
$this->entityManager->persist($member); $this->entityManager->persist($member);
$this->entityManager->flush(); $this->entityManager->flush();
$this->addFlash(
'success',
'Member added successfully'
);
return $this->redirectToRoute('app_case_members', ['id' => $case->getId()]); return $this->redirectToRoute('app_case_members', ['id' => $case->getId()]);
} }
@ -99,9 +105,9 @@ class MemberController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [ 'breadcrumbs' => [
'Case', new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'),
'Members', new Breadcrumb($this->generateUrl('app_case_members', ['id' => $id]), 'List Members'),
'Add Member' new Breadcrumb($this->generateUrl('app_case_add_member', ['id' => $id]), 'Add Member'),
], ],
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'case' => $case, 'case' => $case,
@ -150,6 +156,11 @@ class MemberController extends AbstractController
$this->entityManager->flush(); $this->entityManager->flush();
$this->addFlash(
'success',
'Member updated successfully'
);
return $this->redirectToRoute('app_case_members', ['id' => $caseId]); return $this->redirectToRoute('app_case_members', ['id' => $caseId]);
} }
@ -159,9 +170,9 @@ class MemberController extends AbstractController
$this->navLinks, $this->navLinks,
[ [
'breadcrumbs' => [ 'breadcrumbs' => [
'Case', new Breadcrumb($this->generateUrl('app_case_list'), 'List Cases'),
'Members', new Breadcrumb($this->generateUrl('app_case_members', ['id' => $caseId]), 'List Members'),
'Edit Member' new Breadcrumb($this->generateUrl('app_case_edit_member', ['caseId' => $caseId, 'memberId' => $memberId]), 'Edit Member'),
], ],
'notifications' => $user->retrieveUnreadNotifications(), 'notifications' => $user->retrieveUnreadNotifications(),
'member' => $member, 'member' => $member,