app/Http/Controllers/Api/v1/AdminController.php
/**
     * Mobile Application Authentication Login.
     *
     * @param Request $request
     * @return Response
     */
Mobile Application Authentication Login.
@param Request $request
@return Response
Mobile Application Authentication Login . @param Request $request @return Response
public function login(Request $request)
    {
        $validatedData = $request->validate([
            'email' => "required",
            'password' => 'required|min:6'
        ]);
        $User = User::where('email', $request->email)->first();
        if (!$User || !Hash::check($request->password, $User->password)) {
            return response([
                'message' => ['The provided credentials are incorrect.'],
            ], 200);
        }
        $token = $User->createToken('authToken')->accessToken;
        $response = [
            'error' => false,
            'user' => $User,
            'token' => $token
        ];
        return response($response, 200);
    }
public function login ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'email' => " required " , 'password' => 'required|min:6' ] ) ; $ User = User :: where ( 'email' , $ request -> email ) -> first ( ) ; if ( ! $ User || ! Hash :: check ( $ request -> password , $ User -> password ) ) { return response ( [ 'message' => [ 'The provided credentials are incorrect.' ] , ] , 200 ) ; } $ token = $ User -> createToken ( 'authToken' ) -> accessToken ; $ response = [ 'error' => false , 'user' => $ User , 'token' => $ token ] ; return response ( $ response , 200 ) ; }
Mobile Application Authentication Login.
Mobile Application Authentication Login .