Support the ongoing development of Laravel.io →
Blade Architecture
Last updated by @ajax30 3 months ago.
0

Your query is right it's just you aren't fetching the data after joining the two tables. You simply have to use first() method at the end to retrieve the final result as shown below:

$post = Posts::select (
				"posts.id",
				"posts.description",
				"posts.body",
				"catergories.name as category_name"
			)
			->leftJoin("catergories", "posts.category_id", "=", "catergories.id")
			->where('posts.id', $id)
            ->first();
  dd($post->category_name);
0
Solution selected by @ajax30

Please help me with this question too. Thanks!

Last updated by @ajax30 4 months ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Razvan Razvan ajax30 Joined 2 Oct 2021

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.