i am trying to implement if your trying to login in with his credentials that time login system check the account status if status ACTIVE it login else it show error notification your account has blocked.
my database column name and its value
column account_status
value ACTIVE
and BLOCKED
i tried this in my controller but it not working
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\UserLoginRequest;
use App\Http\Resources\User as UserResource;
use App\User;
class LoginController extends Controller
{
public function login(UserLoginRequest $request)
{
if (!$token = auth()->attempt($request->only(['mobile_number', 'password']))) {
return response()->json([
'errors' => [
'mobile_number' => ['Sorry we cant find you with those details.'],
],
], 422);
};
return (new UserResource($request->user()))->additional([
'meta' => [
'token' => $token,
],
]);
}
public function logout()
{
auth()->logout();
}
}
Try this: