Admin Panel - User management
This commit is contained in:
@@ -9,6 +9,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
use App\Entity\RoomCategory;
|
use App\Entity\RoomCategory;
|
||||||
|
use App\Entity\User;
|
||||||
|
|
||||||
class SomniaDashboardController extends AbstractDashboardController
|
class SomniaDashboardController extends AbstractDashboardController
|
||||||
{
|
{
|
||||||
@@ -30,5 +31,8 @@ class SomniaDashboardController extends AbstractDashboardController
|
|||||||
|
|
||||||
yield MenuItem::Section('Room Management');
|
yield MenuItem::Section('Room Management');
|
||||||
yield MenuItem::linkToCrud('Category', 'fas fa-list', RoomCategory::class);
|
yield MenuItem::linkToCrud('Category', 'fas fa-list', RoomCategory::class);
|
||||||
|
|
||||||
|
yield MenuItem::Section('App Management');
|
||||||
|
yield MenuItem::linkToCrud('Users', 'fas fa-user', User::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use App\Entity\User;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||||
|
|
||||||
|
class UserCrudController extends AbstractCrudController
|
||||||
|
{
|
||||||
|
public static function getEntityFqcn(): string
|
||||||
|
{
|
||||||
|
return User::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureFields(string $pageName): iterable
|
||||||
|
{
|
||||||
|
yield TextField::new ('username');
|
||||||
|
yield TextField::new ('username')->onlyWhenUpdating()->setDisabled(true);
|
||||||
|
|
||||||
|
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST'];
|
||||||
|
yield ChoiceField::new ('roles')
|
||||||
|
->setChoices($availableRoles)
|
||||||
|
->allowMultipleChoices(true);
|
||||||
|
|
||||||
|
yield FormField::addPanel('Change password')->setIcon('fa fa-key');
|
||||||
|
|
||||||
|
yield Field::new ('password', 'New password')->onlyWhenCreating()->setRequired(true)
|
||||||
|
->setFormType(RepeatedType::class)
|
||||||
|
->setFormTypeOptions([
|
||||||
|
'type' => PasswordType::class,
|
||||||
|
'first_options' => ['label' => 'New password'],
|
||||||
|
'second_options' => ['label' => 'Repeat password'],
|
||||||
|
'error_bubbling' => true,
|
||||||
|
'invalid_message' => 'The password fields do not match.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//TODO: Allow password change on Update.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuild
|
|||||||
class RoomCategoryController extends AbstractController
|
class RoomCategoryController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
#[Route('/room/category', name: 'app_room_category')]
|
#[Route('/room/category', name: 'app_room_AllCategories')]
|
||||||
public function getAll(RoomCategoryRepository $catRepo, SerializerInterface $serializer): Response
|
public function getAll(RoomCategoryRepository $catRepo, SerializerInterface $serializer): Response
|
||||||
{
|
{
|
||||||
$catList = $catRepo->findAll();
|
$catList = $catRepo->findAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user