<?php

namespace App\Location\Entity;

use App\Location\Repository\ProvinceRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: ProvinceRepository::class)]
#[ORM\Table(name: 'provinces')]
#[ORM\Index(columns: ['status'], name: 'idx_provinces_status')]
class Province
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;

    #[ORM\Column(type: 'string', length: 36, unique: true)]
    private string $uuid;

    #[ORM\Column(type: 'string', length: 255)]
    private string $name;

    #[ORM\Column(type: 'smallint')]
    private int $status = 1;

    #[ORM\Column(type: 'integer')]
    private int $weight = 0;

    public function __construct(string $name)
    {
        $this->uuid = Uuid::v4()->toRfc4122();
        $this->name = $name;
    }

    public function getId(): ?int    { return $this->id; }
    public function getUuid(): string { return $this->uuid; }
    public function getName(): string { return $this->name; }
    public function getStatus(): int  { return $this->status; }
    public function getWeight(): int  { return $this->weight; }

    public function setName(string $v): self   { $this->name = $v; return $this; }
    public function setStatus(int $v): self    { $this->status = $v; return $this; }
    public function setWeight(int $v): self    { $this->weight = $v; return $this; }

    public function toArray(): array
    {
        return [
            'id'     => $this->id,
            'uuid'   => $this->uuid,
            'name'   => $this->name,
            'status' => $this->status,
            'weight' => $this->weight,
        ];
    }
}
