marcreichel / igdb-laravel

Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
https://marcreichel.dev/docs/igdb-laravel
MIT License
107 stars 22 forks source link

Polymorphic #26

Closed TartanLeGrand closed 3 years ago

TartanLeGrand commented 3 years ago

I create this ticket for a probable improvement. The other day I tried to create a pivot table with a polymorphic relationship, unfortunately the basic functions of the Eloquent model are not available because igdb-laravel uses a custom builder.

It would be really interesting to be able to retrieve objects directly from a polymorphic relationship.

marcreichel commented 3 years ago

Hi, could you please clarify what you would like to achieve exactly? 🤔

The models in igdb-laravel are no real eloquent models and just refer to their corresponding api endpoint. How you store the data in your database then is totally up to you. If this is what you would like to achieve? 😅

TartanLeGrand commented 3 years ago

Hello, the objective would be, for example, to have a polymorphic activity system. This would allow us to know which game users have played, which game has been added to their library, etc.

I understood that they are not really eloquent models. I'm trying to get my MarcReichel\IGDBLaravel\Models\Game or a collection of objects by storing the id and the model in the database. Unfortunately, native Eloquents methods are not implemented in IGDBLaravel, which complicates the task... 😅

No worries for me I wrote my code to get them, but it doesn't look clean so I thought that integrating the relationship system directly into IGDBLaravel would be cool. 😋

Hoping to have been clear enough in my issue. 😁

marcreichel commented 3 years ago

Sorry for the (very) late answer. Got a bit busy around here 😅

If you already got a solution feel free to make a pull request with your changes. We could then clean up your code together 🙂