<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * @ORM\Entity()
 * @ORM\Table(name="account_siege", uniqueConstraints={@ORM\UniqueConstraint(name="siegecurrency", columns={"siege_id", "currency"})}) )
 * @UniqueEntity(
 *     fields={"siege", "currency"},
 *     errorPath="siege",
 *     message="Account already created."
 * )
 */
class AccountSiege extends Account
{
    /**
     * @ORM\ManyToOne(targetEntity=Siege::class, inversedBy="accounts", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="siege_id", referencedColumnName="id", nullable=false)
     */
    private $siege;

    /**
     * @var ArrayCollection|OperationSiege[]
     * @ORM\OneToMany(targetEntity=OperationSiege::class, mappedBy="account")
     */
    protected $operations;

    public function __construct()
    {
        $this->operations = new ArrayCollection();
    }

    public function getSiege(): ?Siege
    {
        return $this->siege;
    }

    public function setSiege(Siege $siege): self
    {
        $this->siege = $siege;

        return $this;
    }

    public function setAccountableObject(Siege $siege): self
    {
        return $this->setSiege($siege);
    }
}
