mardi 27 mars 2018

laravel 5 polymorphic pivot

I want to ask whether is a option to make polymorphic connections between 2 tables based on id and type with pivot table like this:

Where table TABLE_* can be for example TABLE_BOOKS or TABLE_MAGAZINE or whatever.

description:

=> - "has"
... - "other attributes"
FK - "foreign key"

database:

TABLE_* => ID, FK_TYPE_ID,...
SHELFS_WINDOW => ID, FK_TABLE_*_ID, FK_TYPE_ID,...
TYPE => ID,...

Where is SHELFS_WINDOW for one book so there is polymorphic One to One relationshop. I'm able to reach the TABLE_* only with ID and type of the table from document for example. But the type of TABLE_* is in another table with some other informations.

Now I want to know whether is there any posibility to create this relationship with a clean way. Yes, I know, I can do it with \DB:: class. I want to stay in database with SELECTion and I don't want to lose functionality from the returned object Builder.

So I'm just asking whether is there any possibility to do it or not. Or maybe another approach.

Thank You for help!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2IXlzNA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire