src/Entity/Sales/Profile/TopPlacement.php line 24

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-04-25
  5.  * Time: 12:01
  6.  */
  7. namespace App\Entity\Sales\Profile;
  8. use App\Entity\Location\City;
  9. use App\Entity\Profile\Profile;
  10. use App\Entity\Sales\PaidPlacementPrice;
  11. use App\Repository\ProfileTopPlacementRepository;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Doctrine\ORM\Mapping\UniqueConstraint;
  14. /**
  15.  * Топовое размещение анкеты
  16.  * В одном городе в топе может быть только одна анкета в одно и то же время.
  17.  */
  18. #[ORM\Table(name'profile_top_placements')]
  19. #[UniqueConstraint(name'profile_top_placement_city_time'columns: ['city_id''placed_at''expires_at'])]
  20. #[ORM\Entity(repositoryClassProfileTopPlacementRepository::class)]
  21. class TopPlacement
  22. {
  23.     #[ORM\Id]
  24.     #[ORM\Column(name'id'type'integer')]
  25.     #[ORM\GeneratedValue(strategy'AUTO')]
  26.     protected int $id;
  27.     #[ORM\JoinColumn(name'city_id'referencedColumnName'id')]
  28.     #[ORM\ManyToOne(targetEntityCity::class)]
  29.     protected City $city;
  30.     #[ORM\JoinColumn(name'profile_id'referencedColumnName'id')]
  31.     #[ORM\ManyToOne(targetEntityProfile::class, inversedBy'topPlacements')]
  32.     protected Profile $profile;
  33.     /**
  34.      * Время начала размещения в топе
  35.      */
  36.     #[ORM\Column(name'placed_at'type'datetimetz_immutable')]
  37.     protected \DateTimeImmutable $placedAt;
  38.     /**
  39.      * Время окончания размещения в топе
  40.      */
  41.     #[ORM\Column(name'expires_at'type'datetimetz_immutable')]
  42.     protected \DateTimeImmutable $expiresAt;
  43.     /**
  44.      * Цена, по которой было размещено (для продления по этой же цене)
  45.      */
  46.     #[ORM\JoinColumn(name'placement_price_id'referencedColumnName'id'nullabletrue)]
  47.     #[ORM\ManyToOne(targetEntityPaidPlacementPrice::class)]
  48.     private ?PaidPlacementPrice $placementPrice;
  49.     public function __construct(City $cityProfile $profilePaidPlacementPrice $paidPlacementPrice\DateTimeImmutable $placedAt\DateTimeImmutable $expiresAt)
  50.     {
  51.         $this->city $city;
  52.         $this->profile $profile;
  53.         $this->placedAt $placedAt;
  54.         $this->expiresAt $expiresAt;
  55.         $this->placementPrice $paidPlacementPrice;
  56.     }
  57.     public function getPlacementPrice(): PaidPlacementPrice
  58.     {
  59.         return $this->placementPrice;
  60.     }
  61.     public function getProfile(): Profile
  62.     {
  63.         return $this->profile;
  64.     }
  65.     public function getPlacedAt(): \DateTimeImmutable
  66.     {
  67.         return $this->placedAt;
  68.     }
  69.     public function getExpiresAt(): \DateTimeImmutable
  70.     {
  71.         return $this->expiresAt;
  72.     }
  73. }