Here my tables migrations(4):
restaurants:
Schema::create('restaurants', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
});
foods:
Schema::create('foods', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
});
ingredients:
Schema::create('ingredients', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
});
restaurant_has_foods_with_ingredients:
Schema::create('restaurant_has_foods_with_ingredients', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('restaurant_id');
$table->unsignedInteger('food_id');
$table->unsignedInteger('ingredient_id');
$table->foreign('restaurant_id')
->references('id')
->on('restaurants')
->onDelete('cascade');
$table->foreign('food_id')
->references('id')
->on('foods')
->onDelete('cascade');
$table->foreign('ingredient_id')
->references('id')
->on('ingredients')
->onDelete('cascade');
});
How can I define my Restaurant,Food,Ingredient Models with their relations?
Here some examples of my needs:
1-All restaurants with specific ingredient in their serving dishes.
2-All ingredients of a specific dish in a specific restaurant.
3-All dishes with a specific ingredient in a restaurant.
...
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/28UZdLN
via IFTTT
Aucun commentaire:
Enregistrer un commentaire