Support the ongoing development of Laravel.io →
Blade Architecture
Last updated by @ajax30 1 year ago.
0
Solution

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 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Razvan ajax30 Joined 2 Oct 2021

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.