<?php
declare (strict_types=1);

namespace App\Entity\Billing;

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Access\Access;
use App\Entity\Booking\EducationalProject;
//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\ORM\Mapping as ORM;

/**
 * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table EducationalProjectPayer, et supprimer l'attribut discr.
 *
 * Classe ... qui ...
 */
#[ApiResource(
    operations: [
        new Get(
            security: 'is_granted(\'ROLE_ADMIN\') and object.getEducationalProjectPayer().getOrganization().getId() == user.getOrganization().getId()'
        )
    ]
)]
//#[Auditable]
#[ORM\Table(name: 'BillingPayer')]
#[ORM\Entity]
class EducationalProjectPayer
{
    #[ORM\Column(length: 255, nullable: false)]
    private string $discr = 'educationalproject';

    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billingEducationalProjectPayers')]
    private Access $educationalProjectPayer;

    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billingReceivers')]
    private EducationalProject $educationalProjectReceiver;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getEducationalProjectPayer(): ?Access
    {
        return $this->educationalProjectPayer;
    }

    public function setEducationalProjectPayer(?Access $educationalProjectPayer): self
    {
        $this->educationalProjectPayer = $educationalProjectPayer;
        return $this;
    }

    public function getEducationalProjectReceiver(): ?EducationalProject
    {
        return $this->educationalProjectReceiver;
    }

    public function setEducationalProjectReceiver(?EducationalProject $educationalProjectReceiver): self
    {
        $this->educationalProjectReceiver = $educationalProjectReceiver;
        return $this;
    }
}