Reputation: 71
Is seen like I have define the $data, but how come have this error?
public function login(Request $request){
if($request->isMethod('post'))
$data = $request->input();
if (Auth::attempt(['email'=>$data['email'], 'password'=>$data['password'],'admin'=>'1']))
{
echo "Success";
}
else
{
echo "Failed";
}
return view('admin.admin_login');
}
Upvotes: 0
Views: 54
Reputation: 15131
You need to put brackets after the if
if($request->isMethod('post')) { //<--HERE
$data = $request->input();
if (Auth::attempt(['email'=>$data['email'], 'password'=>$data['password'],'admin'=>'1']))
{
echo "Success";
}
else
{
echo "Failed";
}
} //<--HERE
The way your code is, you have an undefined variable $data
if the condition isn't true.
PS: You don't need to check if the request method is "post". A better way is to define in your routes if this accepted method is post or get.
Upvotes: 4