46 lines
1.9 KiB
PHP
Executable File
46 lines
1.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Documentation\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
use Modules\Documentation\Models\DocumentationDocument;
|
|
|
|
class UpdateDocumentationDocumentRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine whether the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var DocumentationDocument|null $document */
|
|
$document = $this->route('document');
|
|
|
|
return [
|
|
'documentation_category_id' => ['nullable', 'integer', 'exists:documentation_categories,id'],
|
|
'title' => ['required', 'string', 'max:220'],
|
|
'slug' => ['nullable', 'string', 'max:240', Rule::unique('documentation_documents', 'slug')->ignore($document?->id)],
|
|
'summary' => ['nullable', 'string', 'max:500'],
|
|
'body' => ['nullable', 'string'],
|
|
'status' => ['required', Rule::in([DocumentationDocument::STATUS_DRAFT, DocumentationDocument::STATUS_PUBLISHED, DocumentationDocument::STATUS_ARCHIVED])],
|
|
'is_featured' => ['nullable', 'boolean'],
|
|
'version' => ['required', 'string', 'max:50'],
|
|
'reference' => ['nullable', 'string', 'max:100'],
|
|
'attachment' => ['nullable', 'file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
|
'attachments' => ['nullable', 'array'],
|
|
'attachments.*' => ['file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
|
'remove_attachment' => ['nullable', 'boolean'],
|
|
];
|
|
}
|
|
}
|