Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

If you want to select columns from related tables like this you have to join the tables manually - doing with() does not work for this. Also, when selecting from another table you need to add the other table in front of the column, i.e. get(['other_table.column'])

Last updated 1 year ago.
0

anlutro, do mean something like this?

https://gist.github.com/hodaddy/8739373

Last updated 1 year ago.
0

That should work, yes. You can also replace DB::table(..)-> with Model::

Last updated 1 year ago.
0

How would I specify ('invoice AS i') if I switch DB::table(..)-> with Model:: ?

Last updated 1 year ago.
0

hodaddy said:

How would I specify ('invoice AS i') if I switch DB::table(..)-> with Model:: ?

have you try Invoice:: ?

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

hodaddy hodaddy Joined 30 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.