Level 75
$data = Build::with('website')->find($id);
Docs: https://laravel.com/docs/8.x/eloquent-relationships#eager-loading
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
If i perform the following query I get the attributes from table 1.
$data = Build::find($id)->get();
If I perform the following query I get the attributes from table 2.
$data = Build::find($id)->website;
I'm struggling to find the syntax to get the attributes from table 1 and table 2 at the same time.
Thanks.
$data = Build::with('website')->find($id);
Docs: https://laravel.com/docs/8.x/eloquent-relationships#eager-loading
Please or to participate in this conversation.