未定义类型Auth

namespace App\Http\Controllers; 

use Auth; 
use Illuminate\Http\Request;

class maincontroller extends Controller 
{ 
    public function home(Request $request)
    { 
        if(Auth::Attempt($request->only('email','password'))) { 
            return redirect('/'); 
        }
    }
}
评论
花自毁
花自毁

试试这个,\ Auth :: attempt([...]); 我认为这很有帮助

点赞
评论
cnon
cnon

You may use the auth helper instead and then no worries about any class name

namespace App\Http\Controllers; 

use Illuminate\Http\Request;

class maincontroller extends Controller 
{ 
    public function home(Request $request)
    { 
        if(auth()->attempt($request->only('email','password'))) { 
            return redirect('/'); 
        }
    }
}
点赞
评论
猪一样队友
猪一样队友

Change the Auth namespace to:

use Illuminate\Support\Facades\Auth;
点赞
评论