42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Admin\Pages;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Illuminate\Validation\Rule;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Base request for page operations, containing shared validation logic.
|
||
|
|
*/
|
||
|
|
abstract class BasePageRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Common reserved slugs that cannot be used for pages.
|
||
|
|
*/
|
||
|
|
protected array $reservedSlugs = ['loom', 'admin', 'api', 'login', 'logout', 'register', 'sw-admin', 'dashboard'];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the base validation rules for pages.
|
||
|
|
*
|
||
|
|
* @param int|null $ignoreId
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
protected function baseRules(?int $ignoreId = null): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'title' => 'required|string|max:255',
|
||
|
|
'slug' => [
|
||
|
|
'required',
|
||
|
|
'string',
|
||
|
|
'max:255',
|
||
|
|
$ignoreId ? Rule::unique('pages')->ignore($ignoreId) : 'unique:pages',
|
||
|
|
Rule::notIn($this->reservedSlugs),
|
||
|
|
],
|
||
|
|
'content' => 'required|array',
|
||
|
|
'meta_description' => 'nullable|string|max:255',
|
||
|
|
'is_published' => 'boolean',
|
||
|
|
'include_in_navigation' => 'boolean',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|