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

you can bed one by passing a closure function in with() as second index of an argument array I believe...

Try this:

Post::with(array('user'=>function($query){
        $query->select('id','username');
    }))->get();

This should retrieve the necessary results if the code is solid, the id is absolutely necessary to retrieve the singled out column though, so make sure to include that.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.