重定向管理面板

时间:2019-07-25 15:51:10

标签: php laravel laravel-5.8

你好,我不知道为什么和在哪里出现问题,但是当我尝试注册或登录或将其重定向到管理面板时,我该怎么做?您能帮我解决这个问题吗?我需要更改什么文件?

管理员控制器

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use Session;

class AdminController extends Controller
{
    public function login(Request $request)
    {
        if($request->isMethod('post')){
            $data = $request->input();
            if (Auth::attempt(['email'=>$data['email'],'password'=>$data['password'],'admin'=>'1'])) {
                Session::put('adminSession',$data['email']);
                return redirect('/admin/dashboard');
            }else{
                return redirect('/admin')->with('flash_message_error', 'Invalid Username or Password');
            }
        }
        return view('admin.admin_login');
    }

    public function dashboard()
    {
        if(Session::has('adminSession'))
        {

        }else{
            return redirect('/admin')->with('flash_message_error', 'Please login to access');
        }
        return view('admin.dashboard');
    }

    public function settings()
    {
        return view('admin.settings');
    }

    public function logout()
    {
        Session::flush();
        return redirect('/admin')->with('flash_message_success', 'Logged out Successfully');
    }
}

0 个答案:

没有答案