feat: add insurance and location management
- Introduced InsuranceType enum for insurance categorization. - Created InsuranceRepository for managing insurance entities. - Developed LocationController for handling provinces and cities, including CRUD operations. - Implemented City and Province entities with necessary fields and relationships. - Added CityRepository and ProvinceRepository for database interactions. - Established Specialty management with SpecialtyController, including CRUD operations. - Created Specialty and Tag entities with appropriate fields and relationships. - Implemented TagController for managing tags, including CRUD operations. - Added TagRepository for database interactions with tags.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Location\Repository;
|
||||
|
||||
use App\Location\Entity\City;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class CityRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, City::class);
|
||||
}
|
||||
|
||||
/** @return City[] */
|
||||
public function findActive(?int $provinceId = null): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('c')
|
||||
->where('c.status = 1')
|
||||
->orderBy('c.weight', 'ASC')
|
||||
->addOrderBy('c.name', 'ASC');
|
||||
|
||||
if ($provinceId !== null) {
|
||||
$qb->andWhere('c.province = :province')->setParameter('province', $provinceId);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function save(City $city, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($city);
|
||||
if ($flush) $this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
public function remove(City $city, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->remove($city);
|
||||
if ($flush) $this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Location\Repository;
|
||||
|
||||
use App\Location\Entity\Province;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class ProvinceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Province::class);
|
||||
}
|
||||
|
||||
/** @return Province[] */
|
||||
public function findActive(): array
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->where('p.status = 1')
|
||||
->orderBy('p.weight', 'ASC')
|
||||
->addOrderBy('p.name', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function save(Province $province, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($province);
|
||||
if ($flush) $this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
public function remove(Province $province, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->remove($province);
|
||||
if ($flush) $this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user