Laravel: метод redirecTo () работает неправильно - PullRequest
0 голосов
/ 22 мая 2018

Я пытался перенаправить пользователя после входа в систему, пользователи должны быть перенаправлены при выполнении определенного условия.

В контроллере LoginController, предоставленном Laravel

line 31->protected function redirectTo(Request $request){
            if($request->session()->has('credentials')){

            $branch_id = $request->session()->get('credentials')[1];

            return view('/home'.$branch_id);
        }
        else{
            return view('/auth.login');
        }
    }

В RedirectifAuthenticated.php от laravel.

public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            $setBranch = User::on('default')->where('email', $request->email)->first();
            $request->session()->put(['branch_id' => $setBranch->branch_id]);
            return redirect('/home');
        }

        return $next($request);
    }

В моем файле AssetController.php

 public function count_assets(Request $request, $branch = null) {

    //set branch id in session for super admin by getting branch in the url that was selected
    $setBranch = Branch::on('default')->where('branch_db', $branch)->first();
    if($setBranch != null){
        session(['branch_id' => $setBranch->branch_id]);
    }

    $count_assets = Asset::get()->count();
    $count_items = Item::get()->count();
    $count_department = Department::get()->count();
    $count_support = User_support::get()->count();
    $count_items_trans = Item_assignment::get()->count();
    $count_assignment = Assignment::get()->count();
    $count_staff = Staff::get()->count();

    return view('home', [ 'count_assets' => $count_assets,'count_items' => $count_items, 'count_department' => $count_department, 'count_support' => $count_support,
        'count_items_trans' => $count_items_trans, 'count_assignment' => $count_assignment, 'count_staff' => $count_staff]);
}

Теперь в файле web.php яУ меня есть такой маршрут

...