52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Back\InvoicePackages;
|
|
|
|
use App\Models\InvoicePackage;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
/**
|
|
* Handles authorization and validation for creating a new InvoicePackage.
|
|
*/
|
|
class StoreInvoicePackageRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::check('create', InvoicePackage::class);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|between:3,255',
|
|
'amount' => 'required|numeric|decimal:0,2|between:1,10000',
|
|
'published' => 'required|boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
#[\Override]
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => trans('validation.custom.name'),
|
|
'amount' => trans('validation.custom.amount'),
|
|
'published' => trans('validation.custom.published'),
|
|
];
|
|
}
|
|
}
|