Added the support for generating docs from template doc
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreDocumentTemplateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
return $user && ($user->hasPermission('manage-document-templates') || $user->hasPermission('manage-settings') || $user->hasRole('admin'));
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
// Slug uniqueness enforced only for first version; controller will increment version if slug exists
|
||||
'slug' => ['required', 'string', 'max:255'],
|
||||
'custom_name' => ['nullable', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'file' => ['required', 'file', 'mimetypes:application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'max:4096'],
|
||||
'meta' => ['sometimes', 'array'],
|
||||
'meta.*' => ['nullable'],
|
||||
'action_id' => ['nullable', 'integer', 'exists:actions,id'], // New optional field
|
||||
'decision_id' => ['nullable', 'integer', 'exists:decisions,id'], // New optional field
|
||||
'activity_note_template' => ['nullable', 'string'], // New optional field
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'file.mimetypes' => 'Datoteka mora biti DOCX.',
|
||||
'file.max' => 'Datoteka je prevelika (max 4MB).',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StorePermissionRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user()?->hasPermission('manage-settings') || $this->user()?->hasRole('admin');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['required', 'string', 'max:255', 'alpha_dash', 'unique:permissions,slug'],
|
||||
'description' => ['nullable', 'string', 'max:500'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Ime je obvezno.',
|
||||
'slug.required' => 'Slug je obvezen.',
|
||||
'slug.unique' => 'Slug že obstaja.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateDocumentTemplateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
$u = $this->user();
|
||||
|
||||
return $u && ($u->hasPermission('manage-document-templates') || $u->hasPermission('manage-settings') || $u->hasRole('admin'));
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'output_filename_pattern' => ['nullable', 'string', 'max:255'],
|
||||
'date_format' => ['nullable', 'string', 'max:40'],
|
||||
'fail_on_unresolved' => ['sometimes', 'boolean'],
|
||||
'number_decimals' => ['nullable', 'integer', 'min:0', 'max:6'],
|
||||
'decimal_separator' => ['nullable', 'string', 'max:2'],
|
||||
'thousands_separator' => ['nullable', 'string', 'max:2'],
|
||||
'currency_symbol' => ['nullable', 'string', 'max:8'],
|
||||
'currency_position' => ['nullable', 'in:before,after'],
|
||||
'currency_space' => ['nullable', 'boolean'],
|
||||
'default_date_format' => ['nullable', 'string', 'max:40'],
|
||||
'date_formats' => ['nullable', 'array'],
|
||||
'date_formats.*' => ['nullable', 'string', 'max:40'],
|
||||
'meta' => ['sometimes', 'array'],
|
||||
'meta.*' => ['nullable'],
|
||||
'action_id' => ['nullable', 'integer', 'exists:actions,id'],
|
||||
'decision_id' => ['nullable', 'integer', 'exists:decisions,id'],
|
||||
'activity_note_template' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user