48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\Page\app\Http\Requests;
|
|
|
|
use Modules\Page\app\Models\Page;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdatePageRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'required|string|max:255',
|
|
'slug' => 'sometimes|required|string|max:255|unique:pages,slug,' . Page::where('uuid', request('uuid'))->first()->id,
|
|
// Exclude the current page by ID
|
|
'summary' => 'sometimes|nullable|string',
|
|
'description' => 'sometimes|nullable|string',
|
|
'display_order' => 'sometimes|nullable|integer',
|
|
'code' => 'sometimes|nullable|string',
|
|
'status' => 'sometimes|required|in:active,inactive',
|
|
'image' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif|max:2048', // Adjust the image rules as needed
|
|
'meta_title' => 'sometimes|nullable|string|max:255',
|
|
'meta_description' => 'sometimes|nullable|string|max:255',
|
|
'meta_keywords' => 'sometimes|nullable|string|max:255',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
// return auth()->user()->can('users.create');
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'slug.unique' => 'The slug is already in use by another page.',
|
|
// Add custom error messages for other rules as needed
|
|
];
|
|
}
|
|
}
|