Answers for "undefined method attempt laravel"

PHP
0

laravel-auth-attempt-undefined-method

Error : laravel-auth-attempt-undefined-method

Solution :

Go to : C:\Users\your_username\.vscode\extensions\bmewburn.vscode-intelephense-client-1.7.1

Then, open package.json and search for intelephense.diagnostics.undefinedTypes.
After this, change in package.json :

				"intelephense.diagnostics.undefinedTypes": false,
				"intelephense.diagnostics.undefinedFunctions": false,
				"intelephense.diagnostics.undefinedConstants": false,
				"intelephense.diagnostics.undefinedClassConstants": false,
				"intelephense.diagnostics.undefinedMethods": false,
				"intelephense.diagnostics.undefinedProperties": false,
				"intelephense.diagnostics.undefinedVariables": false,
                
In the end, press control + shift+p and search for intelephense then select 
index worksapce
Posted by: Guest on September-18-2021
0

undefined method attempt laravel

Better solution :

public function login(Request $request){
        // autenticação login (email e password)
        // dd($request->all(['email' , 'password']));
        
        // attempt() - realiza uma tentativa de autenticação
        // auth espera ou web ou api
        $token = auth('api')->attempt(['email' => $request->email, 'password' => $request->password]);
        // dd($token);

        if($token){
            return response()->json(['token' => $token], 200);
        }else {
            return response()->json(['erro' => 'Email ou Password inválidos'], 403);
        }

        // retornar um JSON Web Token
        return 'login';
    }
Posted by: Guest on October-07-2021

Browse Popular Code Answers by Language