forked from acearo/base-laravel
Added order and alternative to recipe_ingredient and created models
This commit is contained in:
parent
c067326af0
commit
2a559cb381
4 changed files with 53 additions and 0 deletions
17
app/Recipe.php
Normal file
17
app/Recipe.php
Normal 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
17
app/RecipeIngredient.php
Normal 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');
|
||||
}
|
||||
}
|
17
database/factories/RecipeFactory.php
Normal file
17
database/factories/RecipeFactory.php
Normal 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()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -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');
|
||||
|
|
Loading…
Add table
Reference in a new issue