36 lines
1017 B
PHP
36 lines
1017 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Geo;
|
|
|
|
use App\Models\ServiceArea;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateServiceAreaRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$id = $this->route('service_area')?->id;
|
|
|
|
return [
|
|
'name' => ['sometimes', 'required', 'string', 'max:191'],
|
|
'code' => [
|
|
'sometimes',
|
|
'required',
|
|
'string',
|
|
'max:32',
|
|
Rule::unique('service_areas', 'code')->whereNull('deleted_at')->ignore($id),
|
|
],
|
|
'status' => ['sometimes', Rule::in([ServiceArea::STATUS_ACTIVE, ServiceArea::STATUS_INACTIVE])],
|
|
'description' => ['sometimes', 'nullable', 'string', 'max:1000'],
|
|
'barangay_ids' => ['nullable', 'array'],
|
|
'barangay_ids.*' => ['integer', 'exists:barangays,id'],
|
|
];
|
|
}
|
|
}
|