In my requests file in laravel 5.2, I'm setting a condition to check if user is authorized for a request or not.
Code
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
use App\questions;
use Auth;
class answerAddRequest extends Request
{
public function authorize()
{
if(questions::where('people_id',Auth::id())->count()==0)
return true;
else
{
return false;
return redirect('dashboard');
}
}
public function rules()
{
return [
'answer'=>'required|min:3'
];
}
}
If I do not add return false
it executes and inserts in a new row, which shouldn't happen, but with the current code it says Forbidden
which is correct but it doesn't redirect to my dashboard view. How can I make it to redirect to some other page if authorization fails?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2eK2tOy
via IFTTT
Aucun commentaire:
Enregistrer un commentaire