feat(bovine) : suivi des mouvements internes (bâtiment/case)
- Entité BovineMovement (bovine, buildingCase|building, enteredAt, leftAt) + relation OneToMany sur Bovine ordonnée DESC - Endpoint POST /api/bovine_movements via BovineMovementProcessor : ferme le mouvement courant, ouvre le nouveau, synchronise bovine.buildingCase - Commande idempotente app:backfill-bovine-movements pour initialiser l'historique des bovins existants - Onglet Mouvement de la page Vie du bovin : form 3 colonnes (style admin) + UiDataTable avec filtres header (Bâtiment, Case actifs ; Du/Au/Durée désactivés) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
34
src/Repository/BovineMovementRepository.php
Normal file
34
src/Repository/BovineMovementRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Bovine;
|
||||
use App\Entity\BovineMovement;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<BovineMovement>
|
||||
*/
|
||||
final class BovineMovementRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BovineMovement::class);
|
||||
}
|
||||
|
||||
public function findOpenMovement(Bovine $bovine): ?BovineMovement
|
||||
{
|
||||
return $this->createQueryBuilder('m')
|
||||
->where('m.bovine = :bovine')
|
||||
->andWhere('m.leftAt IS NULL')
|
||||
->setParameter('bovine', $bovine)
|
||||
->orderBy('m.enteredAt', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user