Skip to content

Commit

Permalink
Infraestrutura de uma receita
Browse files Browse the repository at this point in the history
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
DevCapu committed Aug 3, 2020
1 parent 19d13b1 commit 2e0bcae
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function up()
$table->integer('timeToPrepare');
$table->enum('difficulty', ['FÁCIL','MÉDIO', 'DIFÍCIL']);
$table->boolean('validated');
$table->integer('photo');
$table->string('photo');
$table->timestamps();
});
}
Expand Down
32 changes: 32 additions & 0 deletions database/migrations/2020_07_25_151635_create_ingredients_table.php
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');
}
}
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 database/migrations/2020_07_26_183458_create_steps_table.php
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');
}
}
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');
}
}

0 comments on commit 2e0bcae

Please sign in to comment.