v1.0.0
This commit is contained in:
35
src/app/Http/Requests/Api/StoreTicketMessageRequest.php
Normal file
35
src/app/Http/Requests/Api/StoreTicketMessageRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api;
|
||||
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreTicketMessageRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'body' => ['required', 'string'],
|
||||
'internal' => ['sometimes', 'boolean'],
|
||||
'author_name' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'attachments' => ['sometimes', 'array'],
|
||||
'attachments.*' => ['file'],
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function (Validator $validator) {
|
||||
if ($error = Settings::validateAttachments($this->file('attachments', []))) {
|
||||
$validator->errors()->add('attachments', $error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user