30 lines
870 B
PHP
30 lines
870 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateCategoryRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'parent_id' => ['nullable', 'exists:categories,id', Rule::notIn([$this->route('category')?->id])],
|
|
'name' => ['sometimes', 'required', 'string', 'max:255'],
|
|
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('categories', 'slug')->ignore($this->route('category'))],
|
|
'description' => ['nullable', 'string'],
|
|
'meta_title' => ['nullable', 'string', 'max:60'],
|
|
'meta_description' => ['nullable', 'string', 'max:160'],
|
|
];
|
|
}
|
|
}
|