I have three tables, stores, store_categories and product_categories. Structure of each table is below
stores
id name
1 Mystore
store_categories
id store_id product_category_id
1 1 1
2 1 2
product_categories
id name
1 Grocery
2 Vegetable
In my Store model, I write the relation
public function store_categories(){
return $this->hasMany('App\StoreCategory');
}
So to get all data of a store, I write i StoresController
$res = Store::with('store_categories')->get(); dump($res);
But the dump shows store_id and product_category_id in relations. How can I display their names( ie store name, product category name etc ) ?