<?php
namespace App\Entity\Sales\Profile;
use App\Entity\Profile\Profile;
use App\Repository\ProfileCtrRepository;
use Carbon\CarbonImmutable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\UniqueConstraint;
#[ORM\Table(name: 'profile_ctr')]
#[Index(name: 'idx_date', columns: ['date'])]
#[UniqueConstraint(name: 'uniq_profile_date', columns: ['profile_id', 'date'])]
#[ORM\Entity(repositoryClass: ProfileCtrRepository::class)]
class Ctr
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'profile_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: Profile::class)] // //, inversedBy="ctr"
private Profile $profile;
#[ORM\Column(type: 'date')]
protected \DateTimeInterface $date;
#[ORM\Column(type: 'smallint', options: ['default' => 0])]
protected int $shows;
#[ORM\Column(type: 'smallint', options: ['default' => 0])]
protected int $visits;
public function __construct(Profile $profile, int $shows = 0, int $visits = 0)
{
$this->profile = $profile;
$this->shows = $shows;
$this->visits = $visits;
$this->date = CarbonImmutable::now();
}
public function getProfile(): Profile
{
return $this->profile;
}
public function setProfile(Profile $profile): void
{
$this->profile = $profile;
}
}