I have a method for check user role is admin or not and use return redirect('/')->send(); to homepage in Condition at the wrong time but before redirect display my view in other methods and after 1sec redirect to homepage how i can redirect in moment time without index display view
My Controller :
class AdminController extends Controller
{
public function __construct()
{
if(Auth::check())
{
$user=Auth::user();
if($user->role!='admin')
{
return redirect('/')->send();
}
}
else
{
return redirect('/')->send();
}
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return View('admin/index');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire