4 months ago

how to redirect user into its default homepage

Posted 4 months ago by incridible

hello I am working on a user auth which I have changed, but now I tried to make it default ( when user login then he redirect to home.blade.php ) but its not working, here is HomeController.

  public function index()
    if (Auth::user()->admin == 0) {
        return view('home')->withData($files);
    } else {
        $users['users'] = \App\User::all();
        return view('layouts.master', $users);
    //return view('home');
    return view('home')->withData(null);

public function show($id)
    $data = File::findOrFail($id);

    $files = \DB::table('files')->get();

    return view('userhome', compact('data', 'files'));


  Route::get('/', function () {
      return view('welcome');

  Route::group(['middleware' => ['web','auth']], function(){

   Route::get('/home', '[email protected]');



    if(auth()->check() && $request->user()->admin == 0){
        return redirect()->guest('home');
    return $next($request);

and one thing that user become unable to access to the admin panel by typing URL

thnks in advance

Please sign in or create an account to participate in this conversation.