Migration complete
This commit is contained in:
41
app/Http/Requests/StoreReviewRequest.php
Normal file
41
app/Http/Requests/StoreReviewRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreReviewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
$review = $this->route('review');
|
||||
if( $review )
|
||||
return $this->user()->can('update', $review);
|
||||
|
||||
return $this->user()->can('create', '\App\Models\EntryReview');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
$isEdit = (bool) $this->route('review');
|
||||
|
||||
$rules = [];
|
||||
|
||||
$rules['rating'] = 'required|numeric|min:1|max:5';
|
||||
$rules['title'] = 'required|string|max:255';
|
||||
$rules['description'] = 'required|string';
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user