forked from Somnia/SomniaRooms
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e7bad7771 | ||
|
|
7a56158563 |
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240427153125 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SEQUENCE config_variable_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE config_variable (id INT NOT NULL, key VARCHAR(32) NOT NULL, value VARCHAR(255) NOT NULL, section VARCHAR(64) DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('DROP SEQUENCE config_variable_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP TABLE config_variable');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240427171934 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE room_availability (day DATE NOT NULL, room_category_id INT NOT NULL, num_available INT NOT NULL, PRIMARY KEY(day, room_category_id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_89C5BA2C67333DD ON room_availability (room_category_id)');
|
||||||
|
$this->addSql('ALTER TABLE room_availability ADD CONSTRAINT FK_89C5BA2C67333DD FOREIGN KEY (room_category_id) REFERENCES room_category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_718569538A90ABA9 ON config_variable (key)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE room_availability DROP CONSTRAINT FK_89C5BA2C67333DD');
|
||||||
|
$this->addSql('DROP TABLE room_availability');
|
||||||
|
$this->addSql('DROP INDEX UNIQ_718569538A90ABA9');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||||
|
|
||||||
|
class ConfigVariableCrudController extends AbstractCrudController
|
||||||
|
{
|
||||||
|
public static function getEntityFqcn(): string
|
||||||
|
{
|
||||||
|
return ConfigVariable::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function configureFields(string $pageName): iterable
|
||||||
|
{
|
||||||
|
yield TextField::new('section');
|
||||||
|
yield TextField::new('key');
|
||||||
|
yield TextField::new('value');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Repository\RoomAvailabilityRepository;
|
||||||
|
use App\Repository\RoomCategoryRepository;
|
||||||
|
use App\Entity\RoomAvailability;
|
||||||
|
use App\Entity\RoomCategory;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\{TextField, DateField, AssociationField, NumberField};
|
||||||
|
|
||||||
|
#[IsGranted("ROLE_ADMIN")]
|
||||||
|
class RoomAvailabilityAdminController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
#[Route('/admin/roomAvailability', name: 'admin_roomAvailability')]
|
||||||
|
public function index(RoomAvailabilityRepository $repo, RoomCategoryRepository $catRepo): Response
|
||||||
|
{
|
||||||
|
$categoryList = $catRepo->findAll();
|
||||||
|
|
||||||
|
return $this->render('admin/room_availability/index.html.twig', [
|
||||||
|
'roomCategoryList' => $categoryList,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/roomAvailability/{categoryId}', name: 'admin_roomAvailability_category')]
|
||||||
|
public function categoryAvailability(RoomAvailabilityRepository $repo, RoomCategoryRepository $catRepo, string $categoryId): Response
|
||||||
|
{
|
||||||
|
$category = $catRepo->find($categoryId);
|
||||||
|
$availabilityList = $repo->findByRoomCategory($categoryId);
|
||||||
|
|
||||||
|
return $this->render('admin/room_availability/category_view.html.twig', [
|
||||||
|
'categoryData' => $category,
|
||||||
|
'availabilityList' => $availabilityList,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/roomAvailabilityTEST/', name: 'admin_roomAvailability_test')]
|
||||||
|
public function availabilityTest(EntityManagerInterface $entityManager): Response
|
||||||
|
{
|
||||||
|
$avl = new RoomAvailability();
|
||||||
|
|
||||||
|
$avl->setDay(new \DateTime("2024-04-24"));
|
||||||
|
$avl->setRoomCategory($entityManager->find(RoomCategory::class, 4));
|
||||||
|
$avl->setNumAvailable(2);
|
||||||
|
|
||||||
|
$entityManager->persist($avl);
|
||||||
|
$entityManager->flush();
|
||||||
|
|
||||||
|
return $this->json($avl);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ class RoomCategoryCrudController extends AbstractCrudController
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
TextField::new('name'),
|
TextField::new('name'),
|
||||||
TextEditorField::new('description'),
|
TextField::new('description'),
|
||||||
TextField::new('bedType'),
|
TextField::new('bedType'),
|
||||||
IntegerField::new('maxGuestNum'),
|
IntegerField::new('maxGuestNum'),
|
||||||
CollectionField::new('roomCategoryDetails')->useEntryCrudForm(),
|
CollectionField::new('roomCategoryDetails')->useEntryCrudForm(),
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ namespace App\Controller\Admin;
|
|||||||
|
|
||||||
use App\Entity\RoomCategoryDetails;
|
use App\Entity\RoomCategoryDetails;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
|
|
||||||
class RoomCategoryDetailsCrudController extends AbstractCrudController
|
class RoomCategoryDetailsCrudController extends AbstractCrudController
|
||||||
@@ -20,7 +18,7 @@ class RoomCategoryDetailsCrudController extends AbstractCrudController
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
TextField::new('detailsSection'),
|
TextField::new('detailsSection'),
|
||||||
TextEditorField::new('detailValue'),
|
TextField::new('detailValue'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ namespace App\Controller\Admin;
|
|||||||
use App\Entity\RoomCategoryPhoto;
|
use App\Entity\RoomCategoryPhoto;
|
||||||
use App\Entity\RoomCategoryPhotoKinds;
|
use App\Entity\RoomCategoryPhotoKinds;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\{TextField, ChoiceField};
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
|
||||||
|
|
||||||
class RoomCategoryPhotoCrudController extends AbstractCrudController
|
class RoomCategoryPhotoCrudController extends AbstractCrudController
|
||||||
{
|
{
|
||||||
@@ -20,7 +17,7 @@ class RoomCategoryPhotoCrudController extends AbstractCrudController
|
|||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield TextField::new('path');
|
yield TextField::new('path');
|
||||||
yield TextEditorField::new('altText');
|
yield TextField::new('altText');
|
||||||
yield ChoiceField::new('kind')->setChoices(['Main' => 'main', 'Bathroom' => 'bathroom', 'Other' => 'other']);
|
yield ChoiceField::new('kind')->setChoices(['Main' => 'main', 'Bathroom' => 'bathroom', 'Other' => 'other']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ 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\RoomAvailability;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
|
||||||
class SomniaDashboardController extends AbstractDashboardController
|
class SomniaDashboardController extends AbstractDashboardController
|
||||||
{
|
{
|
||||||
@@ -30,9 +33,12 @@ class SomniaDashboardController extends AbstractDashboardController
|
|||||||
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
|
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
|
||||||
|
|
||||||
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-door-open', RoomCategory::class);
|
||||||
|
yield MenuItem::linkToRoute('Room Availability', 'fas fa-calendar-check', 'admin_roomAvailability');
|
||||||
|
|
||||||
yield MenuItem::Section('App Management');
|
yield MenuItem::Section('App Management');
|
||||||
yield MenuItem::linkToCrud('Users', 'fas fa-user', User::class);
|
yield MenuItem::linkToCrud('Config Vars', 'fas fa-gear', ConfigVariable::class);
|
||||||
|
yield MenuItem::linkToCrud('Users', 'fas fa-user', User::class)
|
||||||
|
->setPermission("ROLE_SUPERADMIN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class UserCrudController extends AbstractCrudController
|
|||||||
yield TextField::new ('username');
|
yield TextField::new ('username');
|
||||||
yield TextField::new ('username')->onlyWhenUpdating()->setDisabled(true);
|
yield TextField::new ('username')->onlyWhenUpdating()->setDisabled(true);
|
||||||
|
|
||||||
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST'];
|
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST', 'SuperAdmin' => 'ROLE_SUPERADMIN'];
|
||||||
yield ChoiceField::new ('roles')
|
yield ChoiceField::new ('roles')
|
||||||
->setChoices($availableRoles)
|
->setChoices($availableRoles)
|
||||||
->allowMultipleChoices(true);
|
->allowMultipleChoices(true);
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
|
||||||
|
class ConfigVariableController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/config', name: 'app_config_variable')]
|
||||||
|
public function getAllVariables(ConfigVariableRepository $repo): Response
|
||||||
|
{
|
||||||
|
$varList = $repo->findAllVariables();
|
||||||
|
|
||||||
|
return $this->json(['results' => $varList]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/config/section', name: 'app_config_sections')]
|
||||||
|
public function getSections(ConfigVariableRepository $repo): Response
|
||||||
|
{
|
||||||
|
$sectionList = $repo->getAllSections();
|
||||||
|
$returnList = [];
|
||||||
|
foreach ($sectionList as $section) {
|
||||||
|
$sectionValue = $section["section"];
|
||||||
|
$returnList[] = $sectionValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json(['results' => $returnList]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/config/section/{section}', name: 'app_config_variableBySection')]
|
||||||
|
public function getVariablesBySection(ConfigVariableRepository $repo, string $section): Response
|
||||||
|
{
|
||||||
|
if(\is_null($section) || $section == '') {
|
||||||
|
return new Response("Invalid section value", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$varList = $repo->findAllBySection($section);
|
||||||
|
|
||||||
|
return $this->json(['results' => $varList]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/config/var/{key}', name: 'app_config_variable')]
|
||||||
|
public function getByKey(ConfigVariableRepository $repo, string $key): Response
|
||||||
|
{
|
||||||
|
$var = $repo->findVariableByKey($key);
|
||||||
|
|
||||||
|
return $this->json($var);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ class RoomCategoryController extends AbstractController
|
|||||||
{
|
{
|
||||||
|
|
||||||
#[Route('/room/category', name: 'app_room_AllCategories')]
|
#[Route('/room/category', name: 'app_room_AllCategories')]
|
||||||
public function getAll(RoomCategoryRepository $catRepo, SerializerInterface $serializer): Response
|
public function getAll(RoomCategoryRepository $catRepo): Response
|
||||||
{
|
{
|
||||||
$catList = $catRepo->findAll();
|
$catList = $catRepo->findAll();
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ class RoomCategoryController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/room/category/{id}', name: 'app_room_category')]
|
#[Route('/room/category/{id}', name: 'app_room_category')]
|
||||||
public function getById(RoomCategory $category, SerializerInterface $serializer): Response
|
public function getById(RoomCategory $category): Response
|
||||||
{
|
{
|
||||||
return $this->json($category);
|
return $this->json($category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: ConfigVariableRepository::class)]
|
||||||
|
class ConfigVariable
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 32, unique: true)]
|
||||||
|
private ?string $key = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $value = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 64, nullable: true)]
|
||||||
|
private ?string $section = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKey(): ?string
|
||||||
|
{
|
||||||
|
return $this->key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setKey(string $key): static
|
||||||
|
{
|
||||||
|
$this->key = $key;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): ?string
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(string $value): static
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSection(): ?string
|
||||||
|
{
|
||||||
|
return $this->section;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSection(?string $section): static
|
||||||
|
{
|
||||||
|
$this->section = $section;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\RoomAvailabilityRepository;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: RoomAvailabilityRepository::class)]
|
||||||
|
class RoomAvailability
|
||||||
|
{
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?string $day = null;
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\ManyToOne(targetEntity: RoomCategory::class)]
|
||||||
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
|
private ?RoomCategory $roomCategory = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $numAvailable = null;
|
||||||
|
|
||||||
|
public function getDay(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return new \DateTime($this->day);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDay(\DateTimeInterface $day): static
|
||||||
|
{
|
||||||
|
$this->day = $day->format("Ymd");
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoomCategory(): ?RoomCategory
|
||||||
|
{
|
||||||
|
return $this->roomCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRoomCategory(?RoomCategory $roomCategory): static
|
||||||
|
{
|
||||||
|
$this->roomCategory = $roomCategory;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNumAvailable(): ?int
|
||||||
|
{
|
||||||
|
return $this->numAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNumAvailable(int $numAvailable): static
|
||||||
|
{
|
||||||
|
$this->numAvailable = $numAvailable;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -104,7 +104,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getPlainPassword(): string
|
public function getPlainPassword(): ?string
|
||||||
{
|
{
|
||||||
return $this->plainPassword;
|
return $this->plainPassword;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<ConfigVariable>
|
||||||
|
*
|
||||||
|
* @method ConfigVariable|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method ConfigVariable|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method ConfigVariable[] findAll()
|
||||||
|
* @method ConfigVariable[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class ConfigVariableRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, ConfigVariable::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all config variables for API.
|
||||||
|
*/
|
||||||
|
public function findAllVariables(): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('c')
|
||||||
|
->select('c.key, c.value, c.section')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string Config section.
|
||||||
|
* @return ConfigVariable[] Returns an array of ConfigVariable objects
|
||||||
|
*/
|
||||||
|
public function findAllBySection(string $section): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('c')
|
||||||
|
->select('c.key, c.value')
|
||||||
|
->andWhere('c.section = :val')
|
||||||
|
->setParameter('val', $section)
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Config Variable by it's key.
|
||||||
|
* @param string Variable Key
|
||||||
|
* @return ConfigVariable|null Config Variable.
|
||||||
|
*/
|
||||||
|
public function findVariableByKey($varKey)
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('c')
|
||||||
|
->select('c.key, c.value, c.section')
|
||||||
|
->andWhere('c.key = :val')
|
||||||
|
->setParameter('val', $varKey)
|
||||||
|
->getQuery()
|
||||||
|
->getOneOrNullResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all section names that contains config variables.
|
||||||
|
* @return string[] Returns an array of strings.
|
||||||
|
*/
|
||||||
|
public function getAllSections(): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('c')
|
||||||
|
->select('c.section')
|
||||||
|
->distinct()
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\RoomAvailability;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<RoomAvailability>
|
||||||
|
*
|
||||||
|
* @method RoomAvailability|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method RoomAvailability|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method RoomAvailability[] findAll()
|
||||||
|
* @method RoomAvailability[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class RoomAvailabilityRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, RoomAvailability::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RoomAvailability[] Returns an array of RoomAvailability objects
|
||||||
|
*/
|
||||||
|
public function findByRoomCategory($categoryId): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('a')
|
||||||
|
->andWhere('a.roomCategory = :val')
|
||||||
|
->setParameter('val', $categoryId)
|
||||||
|
->orderBy('a.day', 'ASC')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?RoomAvailability
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('r')
|
||||||
|
// ->andWhere('r.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{# templates/admin/room_availability/index.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title 'Room Availability' %}
|
||||||
|
{% block main %}
|
||||||
|
<div>
|
||||||
|
<h3>{{categoryData.name}}</h3>
|
||||||
|
</div>
|
||||||
|
<table class="datagrid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Day</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for availability in availabilityList %}
|
||||||
|
<tr>
|
||||||
|
<td>{{availability.day |date('d-m-Y')}}</td>
|
||||||
|
<td>{{availability.numAvailable}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{# templates/admin/room_availability/index.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title 'Room Availability' %}
|
||||||
|
{% block main %}
|
||||||
|
<table class="datagrid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Category</td>
|
||||||
|
<td>Details</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for category in roomCategoryList %}
|
||||||
|
<tr>
|
||||||
|
<td>{{category.name}}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ ea_url().setRoute('admin_roomAvailability_category', { categoryId: category.id }) }}">
|
||||||
|
View Details
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user