public function login(Request $request)
    {
        $credentials = $request->only('email', 'password');

        try {
            if (! $token = JWTAuth::attempt($credentials)) {
                return response()->json(['error' => 'invalid_credentials'], 401);
            }
        } catch (JWTException $e) {
            return response()->json(['error' => 'could_not_create_token'], 500);
        }

        return response()->json(compact('token'));
    }
public function login(Request $request)
    {
        $credentials = $request->only('email', 'password');

        try {
            if (! $token = JWTAuth::attempt($credentials)) {
                return response()->json(['error' => 'invalid_credentials'], 401);
            }
        } catch (JWTException $e) {
            return response()->json(['error' => 'could_not_create_token'], 500);
        }

        return response()->json(compact('token'));
    }
public function login ( Request $ request ) { $ credentials = $ request -> only ( 'email' , 'password' ) ; try { if ( ! $ token = JWTAuth :: attempt ( $ credentials ) ) { return response ( ) -> json ( [ 'error' => 'invalid_credentials' ] , 401 ) ; } } catch ( JWTException $ e ) { return response ( ) -> json ( [ 'error' => 'could_not_create_token' ] , 500 ) ; } return response ( ) -> json ( compact ( 'token' ) ) ; }
Login a user

@param  Request $request
@return JSON
Login a user