Files
Verde-Web/app/Http/Requests/SuperAdmin/UpdateBarangayRequest.php

42 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requests\SuperAdmin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateBarangayRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$barangayId = $this->route('barangay');
return [
'name' => ['required', 'string', 'max:191'],
'city_municipality_id' => ['required', 'integer', 'exists:cities_municipalities,id'],
'psgc_code' => [
'nullable',
'string',
'max:12',
Rule::unique('barangays', 'psgc_code')->ignore($barangayId),
],
'code' => [
'nullable',
'string',
'max:16',
Rule::unique('barangays', 'code')->ignore($barangayId),
],
'urban_rural' => ['required', 'string', 'in:urban,rural,unknown'],
'population' => ['nullable', 'integer', 'min:0'],
'boundary' => ['required', 'array', 'min:3'],
'boundary.*.lat' => ['required', 'numeric', 'between:-90,90'],
'boundary.*.lng' => ['required', 'numeric', 'between:-180,180'],
];
}
}