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);
Please help me with this question too. Thanks!
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.