vendredi 29 juillet 2016

Laravel 5.1 Complicated Relationship Query Builder

Relationship: Receipt hasMany LineItems

$columns = ['rece_id','rece_user_id','rece_name','rece_date']

$builder = Receipt::select($columns)
        ->with('lineItems')
        ->where('rece_user_id', Auth::user()->id)

dd($builder->get()->toArray());

Above code gives me the receipts with their all respective related line items (all columns).

I need only first line item's one column e.g. liit_description. (I need that as another column in $columns list).

Is this even possible with Eloquent?



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

Aucun commentaire:

Enregistrer un commentaire