vendredi 6 novembre 2020

Laravel login column handling

I have a table column named "Status" Here is the Schema:

Schema::table('users', function (Blueprint $table) {
            $table->boolean('Status')->default('0');
        });

It's a boolean that's added to my table "users." Its function is to find out if a user is logged in on the admin dashboard. Here is my Auth controller@login :

 public function login(Request $request)
    {
         $validateData = $request->validate([
         'email' => 'required',
         'password' => 'required',
         
     ]);



    $credentials = request(['email', 'password']);

    if (! $token = auth()->attempt($credentials)) {
        return response()->json(['error' => 'Email or Password Invalid'], 401);
    }

    return $this->respondWithToken($token);
} 

Basic stuff, but what I wanted to do is if the user accesses this controller through loggin in that the value of the boolean in status column in the user's table turns to 1 for true instead of 0 meaning false. I'm new to laravel so any help would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire