Level 50
Also try by including id column.
Testimonial::with("media:id,name")->find(3);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So this works, I get the related just fine into Inertia
Testimonial::with("media")->find(3);
The problem is it's the full bloated media object, when all I need is just the name and url in the array of items. Is it possible to filter?
Testimonial::with("media:name")->find(3);
//or
Testimonial::with(['media' => function ($query) {
$query->select('name');
}])->find(3);
I tried this suggestion, but doesn't return anything, where without :name it returns 2 items. Any time I try to mess with the data coming back it just returns me nothing
Please or to participate in this conversation.