Route::get('/postcountry/{id}',function($id){
$post_id = Post::where('id',$id)->get();
$user_id= '';
$country_id= '';
foreach ($post_id as $post){
$user_id = $post->user_id;
}
$country = User::where('id',$user_id)->get();
foreach ($country as $value){
$country_id = $value->country_id;
}
$country = Country::find($country_id);
echo $country->country_name;
});
i used this code in my App its work
but its not professional way i think
i have two oneToMany relation ship in my app
first_one is Country
hasMany User
and another one is User
hasMany Post
relation ship
and in last , Country
hasManyTrough relation with Post
actually
I hope u understand
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community