47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Fo;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreRatingRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'rate' => 'required|integer|min:0|max:5',
|
|
'rating_id' => 'required|integer|exists:products,id',
|
|
'rating_type' => 'required|in:App\\Models\\Product,App\\Models\\Recipe',
|
|
'customer_id' => 'required|integer|exists:customers,id',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the error messages for the defined validation rules.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'rate' => trans('notation'),
|
|
'rating_id' => trans('élément ciblé'),
|
|
'customer_id' => trans('utilisateur connecté'),
|
|
];
|
|
}
|
|
}
|