<?php
/**
* Created by simpson <simpsonwork@gmail.com>
* Date: 2019-04-25
* Time: 12:01
*/
namespace App\Entity\Sales\Profile;
use App\Entity\Location\City;
use App\Entity\Profile\Profile;
use App\Entity\Sales\PaidPlacementPrice;
use App\Repository\ProfileTopPlacementRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Топовое размещение анкеты
* В одном городе в топе может быть только одна анкета в одно и то же время.
*/
#[ORM\Table(name: 'profile_top_placements')]
#[ORM\Entity(repositoryClass: ProfileTopPlacementRepository::class)]
class TopPlacement
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: City::class)]
protected City $city;
#[ORM\JoinColumn(name: 'profile_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'topPlacements')]
protected Profile $profile;
/**
* Время начала размещения в топе
*/
#[ORM\Column(name: 'placed_at', type: 'datetimetz_immutable')]
protected \DateTimeImmutable $placedAt;
/**
* Время окончания размещения в топе
*/
#[ORM\Column(name: 'expires_at', type: 'datetimetz_immutable')]
protected \DateTimeImmutable $expiresAt;
/**
* Цена, по которой было размещено (для продления по этой же цене)
*/
#[ORM\JoinColumn(name: 'placement_price_id', referencedColumnName: 'id', nullable: true)]
#[ORM\ManyToOne(targetEntity: PaidPlacementPrice::class)]
private ?PaidPlacementPrice $placementPrice;
public function __construct(City $city, Profile $profile, PaidPlacementPrice $paidPlacementPrice, \DateTimeImmutable $placedAt, \DateTimeImmutable $expiresAt)
{
$this->city = $city;
$this->profile = $profile;
$this->placedAt = $placedAt;
$this->expiresAt = $expiresAt;
$this->placementPrice = $paidPlacementPrice;
}
public function getPlacementPrice(): PaidPlacementPrice
{
return $this->placementPrice;
}
public function getProfile(): Profile
{
return $this->profile;
}
public function getPlacedAt(): \DateTimeImmutable
{
return $this->placedAt;
}
public function getExpiresAt(): \DateTimeImmutable
{
return $this->expiresAt;
}
}