Form Request Validation: Authorizing Form Requests

Authorizing Form Requests

/**
 * 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);
}
Route::post('comment/{comment}');
/**
 * Determine if the user is authorized to make this request.
 *
 * @return bool
 */
public function authorize()
{
    return true;
}

Related concepts

Form Request Validation: Authorizing Form Requests — Structure map

Clickable & Draggable!

Form Request Validation: Authorizing Form Requests — Related pages: