-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criando a infraetrutura de uma receita. Onde é possível visualizar uma receita Ver seus ingredientes Avaliar e ver a avaliação geral E ver o passo a passo
- Loading branch information
Showing
5 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
database/migrations/2020_07_25_151635_create_ingredients_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateIngredientsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('ingredients', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('ingredients'); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
database/migrations/2020_07_25_151736_create_recipes_and_ingredients_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateRecipesAndIngredientsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('recipesAndIngredients', function (Blueprint $table) { | ||
$table->bigInteger('recipe_id')->unsigned(); | ||
$table->bigInteger('ingredient_id')->unsigned(); | ||
$table->integer('quantity')->unsigned(); | ||
$table->string('measure'); | ||
|
||
$table->foreign('recipe_id')->references('id')->on('recipes'); | ||
$table->foreign('ingredient_id')->references('id')->on('ingredients'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('recipesAndIngredients'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
database/migrations/2020_07_26_183458_create_steps_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateStepsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('steps', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->bigInteger('recipe_id')->unsigned(); | ||
$table->string('description'); | ||
$table->string('videoUrl'); | ||
|
||
$table->foreign('recipe_id')->references('id')->on('recipes'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('steps'); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
database/migrations/2020_08_01_154014_create_recipes_rates_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateRecipesRatesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('recipesRates', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->bigInteger('user_id')->unsigned(); | ||
$table->bigInteger('recipe_id')->unsigned(); | ||
$table->smallInteger('rate')->unsigned(); | ||
$table->timestamps(); | ||
|
||
$table->foreign('user_id')->references('id')->on('users'); | ||
$table->foreign('recipe_id')->references('id')->on('recipes'); | ||
|
||
$table->index(['user_id', 'recipe_id']); | ||
$table->unique(['user_id', 'recipe_id']); | ||
|
||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('recipesRates'); | ||
} | ||
} |