feature test su institution
This commit is contained in:
40
backend/app/Http/Requests/UpdateInstitutionRequest.php
Normal file
40
backend/app/Http/Requests/UpdateInstitutionRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateInstitutionRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* L'autorizzazione (solo Admin) è gestita dal middleware di rotta.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$id = $this->route('institution')->id;
|
||||
|
||||
return [
|
||||
'category_id' => ['required', 'integer', 'exists:institution_categories,id'],
|
||||
'name' => ['required', 'string', 'max:255', Rule::unique('institutions', 'name')->ignore($id)],
|
||||
'abbreviation' => ['required', 'string', 'max:5', Rule::unique('institutions', 'abbreviation')->ignore($id)],
|
||||
'address' => ['required', 'string', 'max:255'],
|
||||
'city' => ['required', 'string', 'max:100'],
|
||||
'lat' => ['required', 'numeric', 'between:-90,90'],
|
||||
'lon' => ['required', 'numeric', 'between:-180,180'],
|
||||
// Opzionale in update: se assente si mantiene il logo esistente.
|
||||
'logo' => ['nullable', 'image', 'max:5120'],
|
||||
'color' => ['required', 'string', 'max:50'],
|
||||
'is_storage_place' => ['required', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user