37 lines
971 B
PHP
37 lines
971 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreMutationRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
$ledger = $this->route('ledger');
|
|
|
|
return $ledger && $this->user()->can('view', $ledger);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'amount' => ['required', 'integer'],
|
|
'description' => ['required', 'string'],
|
|
'type' => ['nullable', 'string'],
|
|
'status' => ['nullable', 'string'],
|
|
'media' => ['nullable', 'array'],
|
|
'media.*' => ['file', 'mimes:jpg,jpeg,png,gif,mp4,mov,avi,webm', 'max:20480'],
|
|
];
|
|
}
|
|
}
|