I have a database table categories having columns:
- Category_id
- CategoryName
And other table is Food with:
- Food_id
- FoodName
- Category_id
I want to show the food items according to category on webpage.
I'm using laravel 5.2 and I'm newbie.
I have a database table categories having columns:
And other table is Food with:
I want to show the food items according to category on webpage.
I'm using laravel 5.2 and I'm newbie.
Join those two tables and fetch the data, here is an example on how you do it without creating a model.
$rows = DB::table('food')->select('food.food_id','food.foodName','categories.categoryName')->join('categories','categories.category_id','=','food.category_id')->where('categories.categoryName', '=', 'breakfast')->get();
you can remove the where('','','') part if you dont want to filter
good luck