24 lines
495 B
PHP
24 lines
495 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class PostReviewsRequest extends FormRequest
|
|
{
|
|
public function rules(): array
|
|
{
|
|
$isCreating = $this->isMethod('post');
|
|
|
|
return [
|
|
'rating' => [$isCreating ? 'required' : 'sometimes', 'integer', 'min:1', 'max:5'],
|
|
'comment' => ['sometimes', 'nullable', 'string', 'max:1000'],
|
|
];
|
|
}
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|