new Response(description: 'Collection of departments'), ], ), ), new Get( uriTemplate: '/departments/{department_id}', uriVariables: ['department_id' => new Link(fromClass: Department::class, identifiers: ['department_id'])], openapi: new Operation( summary: 'Get a single department by its code', description: 'Returns a department with its name and region.', responses: [ '200' => new Response(description: 'Department details'), '404' => new Response(description: 'Department not found'), ], ), ), ] )] #[QueryParameter(key: 'department_id', 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)] class Department extends Model { use HasFactory; protected $primaryKey = 'department_id'; public $incrementing = false; protected $keyType = 'string'; protected $fillable = [ 'department_id', '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', 'department_id'); } }