new Response(description: 'Collection of departments'), ], ), ), new Get( uriTemplate: '/departments/{id}', uriVariables: ['id' => new Link(fromClass: Department::class, identifiers: ['id'])], openapi: new Operation( summary: 'Get a single department by its ID', description: 'Returns a department with its code, name and region.', responses: [ '200' => new Response(description: 'Department details'), '404' => new Response(description: 'Department not found'), ], ), ), ] )] #[QueryParameter(key: 'department_code', description: 'Filter by department code (e.g. 76, 75, 13)', filter: EqualsFilter::class)] #[QueryParameter(key: 'department_name', description: 'Filter by department name', filter: EqualsFilter::class)] #[QueryParameter(key: 'region', description: 'Filter by region name (e.g. Normandie)', filter: EqualsFilter::class, property: 'region_name')] #[QueryParameter(key: 'search', description: 'Search by department code or name (partial, case-insensitive)', filter: DepartmentSearchFilter::class)] class Department extends Model { use HasFactory; protected $fillable = [ 'department_code', 'department_name', 'region_name' ]; protected $hidden = ['taxes']; protected $table = 'departments'; public $timestamps = false; /** * Get the taxes for the department. */ public function taxes() { return $this->hasMany(Taxe::class, 'department_id'); } }