CristalTeam / php-api-wrapper

:rainbow: Work with APIs like with Laravel Eloquent or Doctrine (no longer a dream)
MIT License
119 stars 32 forks source link

Implement getQualifiedKeyName method on Laravel Bridge Model #10

Open mathieufrh opened 4 years ago

mathieufrh commented 4 years ago

Hello,

I want to use the getQualifiedKeyName on the model but it is failing when using a model extending Cristal\ApiWrapper\Bridges\Laravel\Model.

The "User" model is a standard Model class and the "Request" model is a model extending Cristal\ApiWrapper\Bridges\Laravel\Model.

I expect the result to be "requests.id".

>>> $u = new App\User;
=> App\User {#3752}
>>> $u->getQualifiedKeyName()
=> "users.id"
>>> $r = new App\Request;
=> App\Request {#4534
     +exists: false,
     +wasRecentlyCreated: false,
   }
>>> $r->getQualifiedKeyName()
Exception with message 'Call to a member function getQualifiedKeyName() on array'
mathieufrh commented 4 years ago

Ok I have declared the functions in the Model.php and it is working now.

camillebaronnet commented 4 years ago

Hi @mathieufrh, thank you for taking the time to share your experience, If you want, you can add this method on Cristal\ApiWrapper\Bridges\Laravel\Model and open a pull request about it :)