/
vladislavts
/
gcppmsp
Обзор
Документация
Войти
/
vladislavts
/
gcppmsp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
prod
src/Repository/ScheduleIntervalRepository.php
80 строк
2 KB
vladislav_ts@list.ru
Добавил отображение дополнительных рабочих дат в редакторе расписаний
02 сен 2024, 20:11
02 сен 2024, 20:11
97a2583
Код
Авторство
О чём код?
<?php namespace App\Repository; use App\Entity\ScheduleInterval; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** * @extends ServiceEntityRepository<ScheduleInterval> * * @method ScheduleInterval|null find($id, $lockMode = null, $lockVersion = null) * @method ScheduleInterval|null findOneBy(array $criteria, array $orderBy = null) * @method ScheduleInterval[] findAll() * @method ScheduleInterval[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ScheduleIntervalRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, ScheduleInterval::class); } public function add(ScheduleInterval $entity, bool $flush = false) : void { $this->getEntityManager()->persist($entity); if ($flush) { $this->getEntityManager()->flush(); } } public function remove(ScheduleInterval $entity, bool $flush = false) : void { $this->getEntityManager()->remove($entity); if ($flush) { $this->getEntityManager()->flush(); } } /** * @return [ * 1=>[ScheduleIntervals from day of week], * 2=>[ScheduleIntervals from day of week], * 3=>[ScheduleIntervals from day of week], * 4=>[ScheduleIntervals from day of week], * 5=>[ScheduleIntervals from day of week], * 6=>[ScheduleIntervals from day of week], * 7=>[ScheduleIntervals from day of week], * ]; */ public function findWeeklyIntervalsBy($value) : array { for ($day = 1; $day <= 7; $day++) { $intervals[$day] = $this->getOneWeekDayIntervals($day, $value); } return $intervals; } ################################ ## Services methods ################################ public function getOneWeekDayIntervals($day, $value) : array { return $this->createQueryBuilder('si') ->andWhere("si.schedule = :val") ->setParameter("val", $value) ->andWhere("si.day = $day") ->orderBy('si.start', 'ASC') ->getQuery() ->getResult() ; } }