I am using MySQL as a database and Eloquent as ORM.
I have been creating a page that is of food or dishes, in which I already have related the meals with the chef that prepare it, so I have them :
Table foods
(meals)
public function up()
{
Schema::create('foods', function (Blueprint $table) {
$table->increments('id');
$table->string('title', 50);
$table->integer('creator_id')->unsigned();
$table->string('image', 300);
$table->text('description');
$table->enum('type', ['breakfast', 'lauch', 'dinner', 'snack']);
$table->enum('status', ['active', 'inactive']);
$table->timestamps();
$table->foreign('creator_id')->references('id')->on('creators');
});
}
Table menus
public function up()
{
Schema::create('menus', function (Blueprint $table) {
$table->increments('id');
$table->enum('dia_semana', [
'lunes',
'martes',
'miercoles',
'jueves',
'viernes',
'sabado',
'domingo',
]);
$table->timestamps();
});
}
What I want is to relate these two tables so that something like this remains:
3 foods
would be in menu
, but those 3 meals that are in that menu can be in several menus of the day. Example:
food1, food2, food3 would be in the menu1 which are mondays , another row: food1, food4, food5 which repeats the food1 would be from the menu2 of the days Tuesday and so on.
It has not yet occurred to me how to do it, so I need some help on how I could make that relationship in the alternating table from many to many food_menu
.