<?php
namespace App\Entity;
use App\Repository\MagasinDeliveryFeeRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MagasinDeliveryFeeRepository::class)]
#[ORM\Table(name: 'magasin_delivery_fee')]
#[ORM\UniqueConstraint(name: 'uniq_mdf_magasin_region', columns: ['magasin_id', 'region_id'])]
class MagasinDeliveryFee
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Magasin::class, inversedBy: 'deliveryFees')]
#[ORM\JoinColumn(name: 'magasin_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private ?Magasin $magasin = null;
#[ORM\ManyToOne(targetEntity: Region::class)]
#[ORM\JoinColumn(name: 'region_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private ?Region $region = null;
#[ORM\Column(type: 'decimal', precision: 10, scale: 2)]
private string $fee = '0.00';
#[ORM\Column(name: 'can_deliver')]
private bool $canDeliver = true;
public function getId(): ?int { return $this->id; }
public function getMagasin(): ?Magasin { return $this->magasin; }
public function setMagasin(?Magasin $magasin): self { $this->magasin = $magasin; return $this; }
public function getRegion(): ?Region { return $this->region; }
public function setRegion(?Region $region): self { $this->region = $region; return $this; }
public function getFee(): string { return $this->fee; }
public function setFee(string|float $fee): self
{
$this->fee = number_format((float)$fee, 2, '.', '');
return $this;
}
public function getFeeAsFloat(): float { return (float)$this->fee; }
public function canDeliver(): bool { return $this->canDeliver; }
public function setCanDeliver(bool $canDeliver): self { $this->canDeliver = $canDeliver; return $this; }
}