Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

I forgot to mention that I've tried with propertyStatus.status, property_status.status, but with no result...

Last updated 2 years ago.
0

In this case where you are just retriving one single property model with all one-one relations, why are you lazy-loading ?

I mean, lazy loading or not, the number of queries will be anyway 4 !

If not can you give a view of your schema.

Last updated 2 years ago.
0

It eager loading, by the definition from here: http://laravel.com/docs/eloquent#eager-loading

Besides, the result that I'm returning to the user in through API and is in JSON format and that's why I need to select only certain columns and not all of them.

Last updated 2 years ago.
0

I'll redefine my question, in case I was not clear. This example is from the Query Builder documentation:

DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.id', 'contacts.phone', 'orders.price')
            ->get();

Can I select specific columns like that using Eloquent?

$this->users->
            with('contacts', 'orders')->
            get(array('users.id', 'contacts.phone', 'orders.price')->toArray();

I saw that it can be done using closure, but it can get messy if we have more joins using with().

Last updated 2 years ago.
0

I need that function as well. Would it be difficult to implement?

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andrejmk andrejmk Joined 28 Mar 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.