Add IngredientAmount model

This commit is contained in:
Christopher C. Wells 2020-12-21 13:59:05 -08:00
parent 18543c4971
commit a4cc3c3f65
6 changed files with 191 additions and 2 deletions

View File

@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers;
use App\Models\IngredientAmount;
use Illuminate\Http\Request;
class IngredientAmountController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Models\IngredientAmount $ingredientAmount
* @return \Illuminate\Http\Response
*/
public function show(IngredientAmount $ingredientAmount)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\IngredientAmount $ingredientAmount
* @return \Illuminate\Http\Response
*/
public function edit(IngredientAmount $ingredientAmount)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\IngredientAmount $ingredientAmount
* @return \Illuminate\Http\Response
*/
public function update(Request $request, IngredientAmount $ingredientAmount)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\IngredientAmount $ingredientAmount
* @return \Illuminate\Http\Response
*/
public function destroy(IngredientAmount $ingredientAmount)
{
//
}
}

View File

@ -11,8 +11,6 @@ class Ingredient extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
*
* @var array
*/ */
protected array $fillable = [ protected array $fillable = [
'name', 'name',

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
class IngredientAmount extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'amount',
];
/**
* Get the Ingredient this amount pertains to.
*/
public function ingredient(): HasOne {
return $this->hasOne(Ingredient::class);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\IngredientAmount;
use Illuminate\Database\Eloquent\Factories\Factory;
class IngredientAmountFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = IngredientAmount::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
//
];
}
}

View File

@ -0,0 +1,34 @@
<?php
use App\Models\Ingredient;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateIngredientAmountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ingredient_amounts', function (Blueprint $table) {
$table->id();
$table->unsignedFloat('amount');
$table->foreignIdFor(Ingredient::class);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ingredient_amounts');
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class IngredientAmountSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}