diff --git a/app/Recipe.php b/app/Recipe.php new file mode 100644 index 0000000..98acda5 --- /dev/null +++ b/app/Recipe.php @@ -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'); + } +} diff --git a/app/RecipeIngredient.php b/app/RecipeIngredient.php new file mode 100644 index 0000000..6a0f2d7 --- /dev/null +++ b/app/RecipeIngredient.php @@ -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'); + } +} diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php new file mode 100644 index 0000000..c146cb1 --- /dev/null +++ b/database/factories/RecipeFactory.php @@ -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() + { + } +} diff --git a/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php b/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php index f02bbe3..096cfd8 100644 --- a/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php +++ b/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php @@ -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');