- Add SendSmsMessage class for encapsulating SMS message data. - Create KavehNegarProvider and RanginehProvider classes implementing SmsProviderInterface for sending SMS. - Implement SmsLogRepository and SmsTemplateRepository for managing SMS logs and templates. - Develop SendSmsHandler for handling SMS sending messages. - Create SmsService to manage SMS dispatching and logging. - Add UserProfileController for managing user profiles with CRUD operations. - Implement UserProfile entity and repository for user profile data management. - Update symfony.lock and bootstrap.php for project dependencies and environment setup.
213 lines
9.5 KiB
PHP
213 lines
9.5 KiB
PHP
<?php
|
|
|
|
namespace App\Clinic\Entity;
|
|
|
|
use App\Auth\Entity\User;
|
|
use App\Category\Entity\Category;
|
|
use App\Doctor\Entity\Doctor;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'clinics')]
|
|
#[ORM\Index(columns: ['user_id'], name: 'idx_clinics_owner')]
|
|
#[ORM\Index(columns: ['city_id'], name: 'idx_clinics_city')]
|
|
#[ORM\Index(columns: ['state_id'], name: 'idx_clinics_state')]
|
|
class Clinic
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column(type: 'integer')]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(type: 'string', length: 36, unique: true)]
|
|
private string $uuid;
|
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)]
|
|
private User $user;
|
|
|
|
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column(type: 'text', nullable: true)]
|
|
private ?string $info = null;
|
|
|
|
#[ORM\Column(type: 'text', nullable: true)]
|
|
private ?string $address = null;
|
|
|
|
#[ORM\Column(type: 'string', length: 50, nullable: true)]
|
|
private ?string $telephone = null;
|
|
|
|
#[ORM\Column(name: 'is_24_7', type: 'boolean')]
|
|
private bool $is247 = false;
|
|
|
|
#[ORM\Column(name: 'working_days', type: 'string', length: 255, nullable: true)]
|
|
private ?string $workingDays = null;
|
|
|
|
#[ORM\Column(type: 'float', nullable: true)]
|
|
private ?float $latitude = null;
|
|
|
|
#[ORM\Column(type: 'float', nullable: true)]
|
|
private ?float $longitude = null;
|
|
|
|
#[ORM\Column(name: 'city_id', type: 'integer', nullable: true)]
|
|
private ?int $cityId = null;
|
|
|
|
#[ORM\Column(name: 'state_id', type: 'integer', nullable: true)]
|
|
private ?int $stateId = null;
|
|
|
|
#[ORM\Column(name: 'representation_id', type: 'integer', nullable: true)]
|
|
private ?int $representationId = null;
|
|
|
|
#[ORM\Column(name: 'images_clinic', type: 'json', nullable: true)]
|
|
private ?array $imagesClinic = null;
|
|
|
|
#[ORM\Column(name: 'clinic_logo', type: 'json', nullable: true)]
|
|
private ?array $clinicLogo = null;
|
|
|
|
#[ORM\Column(name: 'created_at', type: 'integer')]
|
|
private int $createdAt;
|
|
|
|
#[ORM\Column(name: 'updated_at', type: 'integer')]
|
|
private int $updatedAt;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Doctor::class)]
|
|
#[ORM\JoinTable(
|
|
name: 'clinic_doctors',
|
|
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'doctor_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
|
|
)]
|
|
private Collection $doctors;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Category::class)]
|
|
#[ORM\JoinTable(
|
|
name: 'clinic_specialties',
|
|
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
|
|
)]
|
|
private Collection $specialties;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Category::class)]
|
|
#[ORM\JoinTable(
|
|
name: 'clinic_services',
|
|
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
|
|
)]
|
|
private Collection $services;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Category::class)]
|
|
#[ORM\JoinTable(
|
|
name: 'clinic_insurances',
|
|
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
|
|
)]
|
|
private Collection $insurances;
|
|
|
|
public function __construct(User $user)
|
|
{
|
|
$this->uuid = Uuid::v4()->toRfc4122();
|
|
$this->user = $user;
|
|
$this->createdAt = time();
|
|
$this->updatedAt = time();
|
|
$this->doctors = new ArrayCollection();
|
|
$this->specialties = new ArrayCollection();
|
|
$this->services = new ArrayCollection();
|
|
$this->insurances = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int { return $this->id; }
|
|
public function getUuid(): string { return $this->uuid; }
|
|
public function getUser(): User { return $this->user; }
|
|
public function getName(): ?string { return $this->name; }
|
|
public function getInfo(): ?string { return $this->info; }
|
|
public function getAddress(): ?string { return $this->address; }
|
|
public function getTelephone(): ?string { return $this->telephone; }
|
|
public function isIs247(): bool { return $this->is247; }
|
|
public function getWorkingDays(): ?string { return $this->workingDays; }
|
|
public function getLatitude(): ?float { return $this->latitude; }
|
|
public function getLongitude(): ?float { return $this->longitude; }
|
|
public function getCityId(): ?int { return $this->cityId; }
|
|
public function getStateId(): ?int { return $this->stateId; }
|
|
public function getRepresentationId(): ?int { return $this->representationId; }
|
|
public function getImagesClinic(): ?array { return $this->imagesClinic; }
|
|
public function getClinicLogo(): ?array { return $this->clinicLogo; }
|
|
public function getDoctors(): Collection { return $this->doctors; }
|
|
public function getSpecialties(): Collection { return $this->specialties; }
|
|
public function getServices(): Collection { return $this->services; }
|
|
public function getInsurances(): Collection { return $this->insurances; }
|
|
|
|
public function setName(?string $v): self { $this->name = $v; $this->touch(); return $this; }
|
|
public function setInfo(?string $v): self { $this->info = $v; $this->touch(); return $this; }
|
|
public function setAddress(?string $v): self { $this->address = $v; $this->touch(); return $this; }
|
|
public function setTelephone(?string $v): self { $this->telephone = $v; $this->touch(); return $this; }
|
|
public function setIs247(bool $v): self { $this->is247 = $v; $this->touch(); return $this; }
|
|
public function setWorkingDays(?string $v): self { $this->workingDays = $v; $this->touch(); return $this; }
|
|
public function setLatitude(?float $v): self { $this->latitude = $v; $this->touch(); return $this; }
|
|
public function setLongitude(?float $v): self { $this->longitude = $v; $this->touch(); return $this; }
|
|
public function setCityId(?int $v): self { $this->cityId = $v; $this->touch(); return $this; }
|
|
public function setStateId(?int $v): self { $this->stateId = $v; $this->touch(); return $this; }
|
|
public function setRepresentationId(?int $v): self { $this->representationId = $v; $this->touch(); return $this; }
|
|
public function setImagesClinic(?array $v): self { $this->imagesClinic = $v; $this->touch(); return $this; }
|
|
public function setClinicLogo(?array $v): self { $this->clinicLogo = $v; $this->touch(); return $this; }
|
|
|
|
private function touch(): void { $this->updatedAt = time(); }
|
|
|
|
public function toDetailArray(array $stateData = [], array $cityData = []): array
|
|
{
|
|
$formatCat = fn(Category $c) => [
|
|
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
|
|
];
|
|
$formatCatWithParent = fn(Category $c) => [
|
|
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
|
|
'parent' => $c->getParentId() !== null ? (string) $c->getParentId() : null,
|
|
];
|
|
|
|
return [
|
|
'id' => (string) $this->id,
|
|
'uuid' => $this->uuid,
|
|
'title' => $this->name,
|
|
'images_clinic' => $this->imagesClinic ?? [],
|
|
'clinic_logo' => $this->clinicLogo ?? [],
|
|
'phone_number' => $this->telephone,
|
|
'caption' => $this->info,
|
|
'list_bime' => array_map($formatCat, $this->insurances->toArray()),
|
|
'specialties' => array_map($formatCatWithParent, $this->specialties->toArray()),
|
|
'services' => array_map($formatCat, $this->services->toArray()),
|
|
'clinic_specialty' => array_map($formatCatWithParent, $this->specialties->toArray()),
|
|
'doctors' => $this->doctors->count(),
|
|
'doctor_list' => null,
|
|
'city' => $cityData ? [$cityData] : [],
|
|
'state' => $stateData ? [$stateData] : [],
|
|
'location' => $this->address,
|
|
'map' => [
|
|
'latitude' => $this->latitude !== null ? (string) $this->latitude : null,
|
|
'longitude' => $this->longitude !== null ? (string) $this->longitude : null,
|
|
],
|
|
'24_7' => $this->is247,
|
|
'field_working_days' => $this->workingDays,
|
|
];
|
|
}
|
|
|
|
public function toListArray(): array
|
|
{
|
|
$formatCat = fn(Category $c) => [
|
|
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
|
|
];
|
|
|
|
return [
|
|
'id' => (string) $this->id,
|
|
'uuid' => $this->uuid,
|
|
'title' => $this->name,
|
|
'images_clinic' => $this->imagesClinic ?? [],
|
|
'clinic_logo' => $this->clinicLogo ?? [],
|
|
'phone_number' => $this->telephone,
|
|
'specialties' => array_map($formatCat, $this->specialties->toArray()),
|
|
'doctors' => $this->doctors->count(),
|
|
'24_7' => $this->is247,
|
|
];
|
|
}
|
|
}
|