[#FER-26] Passeport du bovin (!53)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #53 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #53.
This commit is contained in:
129
src/Entity/BovineMovement.php
Normal file
129
src/Entity/BovineMovement.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use App\Repository\BovineMovementRepository;
|
||||
use App\State\Bovin\BovineMovementProcessor;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BovineMovementRepository::class)]
|
||||
#[ORM\Table(name: 'bovine_movement')]
|
||||
#[ORM\Index(name: 'idx_bovine_movement_timeline', columns: ['bovine_id', 'entered_at'])]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Post(
|
||||
denormalizationContext: ['groups' => ['bovine_movement:write']],
|
||||
normalizationContext: ['groups' => ['bovine:read']],
|
||||
processor: BovineMovementProcessor::class,
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_BUREAU')",
|
||||
)]
|
||||
class BovineMovement
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['bovine:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'movements')]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
#[Groups(['bovine_movement:write'])]
|
||||
private Bovine $bovine;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[Groups(['bovine:read', 'bovine_movement:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?BuildingCase $buildingCase = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[Groups(['bovine:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Building $building = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable')]
|
||||
#[Groups(['bovine:read', 'bovine_movement:write'])]
|
||||
private DateTimeImmutable $enteredAt;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
|
||||
#[Groups(['bovine:read'])]
|
||||
private ?DateTimeImmutable $leftAt = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getBovine(): Bovine
|
||||
{
|
||||
return $this->bovine;
|
||||
}
|
||||
|
||||
public function setBovine(Bovine $bovine): static
|
||||
{
|
||||
$this->bovine = $bovine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBuildingCase(): ?BuildingCase
|
||||
{
|
||||
return $this->buildingCase;
|
||||
}
|
||||
|
||||
public function setBuildingCase(?BuildingCase $buildingCase): static
|
||||
{
|
||||
$this->buildingCase = $buildingCase;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBuilding(): ?Building
|
||||
{
|
||||
return $this->building;
|
||||
}
|
||||
|
||||
public function setBuilding(?Building $building): static
|
||||
{
|
||||
$this->building = $building;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnteredAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->enteredAt;
|
||||
}
|
||||
|
||||
public function hasEnteredAt(): bool
|
||||
{
|
||||
return isset($this->enteredAt);
|
||||
}
|
||||
|
||||
public function setEnteredAt(DateTimeImmutable $enteredAt): static
|
||||
{
|
||||
$this->enteredAt = $enteredAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLeftAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->leftAt;
|
||||
}
|
||||
|
||||
public function setLeftAt(?DateTimeImmutable $leftAt): static
|
||||
{
|
||||
$this->leftAt = $leftAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user