Added order and alternative to recipe_ingredient and created models

This commit is contained in:
Beth Parker 2022-02-07 19:10:11 -06:00
parent c067326af0
commit 2a559cb381
4 changed files with 53 additions and 0 deletions

17
app/Recipe.php Normal file
View file

@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Recipe extends Model
{
use HasFactory;
protected $fillable = ['name','maintainer','author','servings','date_entered','date_modified','instructions'];
public function ingredients()
{
return $this->hasMany('App\RecipeIngredient');
}
}

17
app/RecipeIngredient.php Normal file
View file

@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RecipeIngredient extends Model
{
use HasFactory;
protected $fillable = ['recipe_id','order','alternative','name','quantity','measurement','special_notes'];
public function recipe()
{
return $this->belongsTo('App\Recipe');
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class RecipeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
}
}

View file

@ -16,6 +16,8 @@ class CreateRecipeIngredientTable extends Migration
Schema::create('recipe_ingredient', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('recipe_id');
$table->unsignedInteger('order');
$table->boolean('alternative');
$table->string('name');
$table->float('quantity');
$table->string('measurement');