samedi 29 octobre 2016

Laravel 5.3 Eloquent - select from 3 tables

in addition to my last question Laravel 5.3 Eloquent Relationships

i added a new table called Labels and of course create a new model for this table.

Languages

id
name
short_name

Dictionary

id
label_id
value
language_id

Labels

id
label_name

and i have this code:

$lables = Dictionary::whereHas('language', function($query) {
        $short_name = basename(__DIR__);
        $query->where('short_name', $short_name);
    })->pluck('value', 'label_id')->toArray();

i want to pull out the label_name field instead of the label_id

but i dont know how to make this join

thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire