Answer the question
In order to leave comments, you need to log in
How not to repeat queries in the database?
I validate the input using special Laravel classes that are created using make:request.
Let's say we have a class like this:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BlaBla extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$comment = Comment::find($this->route('comment'));
return $comment && $this->user()->can('update', $comment);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
];
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question