vendredi 22 janvier 2016

laravel model "case" or if statement

so i'm newer to laravel models and have searched pretty extensively and wondering how to do the following in the model.

i have a master table (primary key=id) with a fields of type and type_id.

if the value of type=1, i want to reference table1 and the records master.type_id=table1.primarykey. this table has field abc

if the value of type=2, i want to reference table2 and the records master.type_id=table2.primarykey. this table has field def

i'm wondering what the model is that would do this and i'd be able to reference fields abc and def.

thanks for your help

Aucun commentaire:

Enregistrer un commentaire