44 lines
930 B
PHP
44 lines
930 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Codes;
|
|
|
|
use App\Models\Code;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class GenerateCodesRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::check('generate', Code::class) and $this->json();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string,string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'quantity' => 'required|integer|min:1'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array<string,string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'quantity' => trans('validation.custom.quantity')
|
|
];
|
|
}
|
|
}
|