mercredi 24 janvier 2018

Laravel 5.5 Trying to get property 'id' of non-object

I'm new on Laravel.I used Laravel version 5.5

If I try to login with postman.I got "Trying to get property 'id' of non-object" error.And error line is

    private $client;

public function __construct(){
    $this->client = Client::find(1);
}

public function login(Request $request){

    $this->validate($request, [
        'username' => 'required',
        'password' => 'required'
    ]);

    return $this->issueToken($request, 'password'); // this line has error

}

issueToken Function

public function issueToken(Request $request, $grantType, $scope = ""){

    $params = [
        'grant_type' => $grantType,
        'client_id' => $this->client->id,
        'client_secret' => $this->client->secret,           
        'scope' => $scope
    ];

    if($grantType !== 'social'){
        $params['username'] = $request->username ?: $request->email;
    }

    $request->request->add($params);

    $proxy = Request::create('oauth/token', 'POST');

    return Route::dispatch($proxy);

}

I got same error on Register.But my user successfully registered with 500 error (Trying to get property 'id' of non-object)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire