Route::post('/login', 'HomeController@authenticate');
Record in db: https://ibb.co/SX26sWm
public function authenticate(Request $request)
{
if(Auth::attempt(['email' => $request->email, 'password' => $request->password, 'active' => 1, 'course_id' => $request->course_id]))
{
echo "Logged";
}
else
{
echo "Didn't work";
}
}
dd()
+request: ParameterBag {#44 ▼
#parameters: array:4 [▼
"_token" => "JIzP7GMAtiBqPY8pVlC8WqCUgQWbG0QCbGATie7z"
"email" => "[email protected]"
"course_id" => "9"
"password" => "mypassword"
]
}
Using members table
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $table = 'members';
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function getMemberSinceAttribute()
{
return $this->created_at->diffInDays(now());
}
}
Passwords are updated like this
public function update_password(Request $request)
{
\DB::table('members')
->where('id', $request->id)
->update(['password' => Hash::make($request->newPassword)]);
return redirect('/members/'.$request->id."/edit")->with('status', 'Password updated!');
}
dd(Auth::attempt(['email'=>$request['email'],'password'=>$request['password']]));
Returns false
Tried this same thing
if(Auth::attempt(['email' => $request->email, 'password' => Hash::make($request->password), 'active' => 1, 'course_id' => $request->course_id]))