app/Http/Controllers/AuthenticationController.php
//use this method to signin users
use this method to signin users
use this method to signin users
public function signin(Request $request)
    {
        $attr = $request->validate([
            'email' => 'required|string|email|',
            'password' => 'required|string|min:3'
        ]);
        if (!Auth::attempt($attr)) {
            return $this->sendError('Unauthorised.', ['error'=>'Unauthorised']);
        }
        $success['token'] = auth()->user()->createToken('API Token')->plainTextToken ;
        $success['user']  = auth()->user() ;
        return $this->sendResponse($success, 'User login successfully.');
    }
public function signin ( Request $ request ) { $ attr = $ request -> validate ( [ 'email' => 'required|string|email|' , 'password' => 'required|string|min:3' ] ) ; if ( ! Auth :: attempt ( $ attr ) ) { return $ this -> sendError ( 'Unauthorised.' , [ 'error' => 'Unauthorised' ] ) ; } $ success [ 'token' ] = auth ( ) -> user ( ) -> createToken ( 'API Token' ) -> plainTextToken ; $ success [ 'user' ] = auth ( ) -> user ( ) ; return $ this -> sendResponse ( $ success , 'User login successfully.' ) ; }
use this method to signin users
use this method to signin users