I have two models. Business and City.
Business:
-some columns--
City:
How to display the city name, when I get business data to view
I was able to display cities using the laravel voyager lessons
If you are using models, you can create a relationship by adding hasOne or hasMany to your model codes. When you call it from your controller, you can call the relationship you wrote in your model with the 'with' query.
Model
public function city()
{
return $this->hasOne(City::class,'id','cityid');
}
Controller
$business=Business::with('city')->first();
$cityname=$business->city->name;
If you don't use model, you can connect with 'join'