Added recipe page
This commit is contained in:
parent
f4e9e87335
commit
a6e28a64aa
7 changed files with 62 additions and 8 deletions
|
@ -17,8 +17,8 @@ class RecipeController extends Controller
|
|||
}
|
||||
public function show($id)
|
||||
{
|
||||
$recipe=Recipe::with('user')->with('ingredients')->findOrFail($id);
|
||||
return $ingredients;
|
||||
$recipe=Recipe::with('user')->with('ingredients')->findOrFail($id);
|
||||
return view('recipes.show')->with('recipe', $recipe);
|
||||
}
|
||||
public function edit($id){
|
||||
$recipe=Recipe::with('user')->with('ingredients')->findOrFail($id);
|
||||
|
|
|
@ -4,11 +4,20 @@ namespace App;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Recipe extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['name','maintainer','author','servings','date_entered','date_modified','instructions'];
|
||||
protected $dates = ['date_entered','date_modified'];
|
||||
|
||||
public function setDateEnteredAttribute($value){
|
||||
$this->attributes['date_entered']=Carbon::parse($value);
|
||||
}
|
||||
|
||||
public function setDateModifiedAttribute($value){
|
||||
$this->attributes['date_modified']=Carbon::parse($value);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ class CreateRecipesTable extends Migration
|
|||
$table->unsignedInteger('user_id');
|
||||
$table->string('author');
|
||||
$table->unsignedInteger('servings');
|
||||
$table->string('serving_size');
|
||||
$table->datetime('date_entered');
|
||||
$table->datetime('date_modified');
|
||||
$table->longtext('instructions');
|
||||
|
|
|
@ -18,20 +18,20 @@ class RecipeSeeder extends Seeder
|
|||
{
|
||||
$first_user = User::orderBy('id')->first();
|
||||
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test','user_id'=>$first_user['id'],'author'=>'Jayne','servings'=>1,'date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test','user_id'=>$first_user['id'],'author'=>'Jayne','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'hamburger','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>true,'name'=>'sausage','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test2','user_id'=>$first_user['id'],'author'=>'Karen','servings'=>1,'date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test2','user_id'=>$first_user['id'],'author'=>'Karen','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'chicken','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
|
||||
$jayne=User::updateOrCreate(['name'=>'Jayne','email'=>'jayne.passmore@actcur.com','password'=>bcrypt('temp'),'created_at'=>NOW()]);
|
||||
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test3','user_id'=>$jayne['id'],'author'=>'Jayne','servings'=>1,'date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
$recipe=Recipe::updateOrCreate(['name'=>'Test3','user_id'=>$jayne['id'],'author'=>'Jayne','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
|
||||
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'chicken','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
|
||||
|
|
5
public/css/layout.css
vendored
5
public/css/layout.css
vendored
|
@ -11,6 +11,7 @@
|
|||
--primary-highlight: #0000df;/*red*/
|
||||
--primary-highlight-dark: #000064;/*20% darker*/
|
||||
--secondary-highlight: #f80049;/*orange*/
|
||||
--input-color: #000000;
|
||||
}
|
||||
|
||||
/***this is background***/
|
||||
|
@ -269,3 +270,7 @@ list {
|
|||
.operations{
|
||||
width:132px;
|
||||
}
|
||||
|
||||
input {
|
||||
color: var(--input-color);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</tr>
|
||||
@foreach ($recipes as $recipe)
|
||||
<tr class="rows">
|
||||
<td class="name">{{ $recipe->name }}</td>
|
||||
<td class="name"><a href="{{ route('recipes.show', $recipe->id) }}">{{ $recipe->name }}</a></td>
|
||||
<td class="author">{{ $recipe->author }}</td>
|
||||
<td class="user">{{ $recipe->user ->name}}</td>
|
||||
<td>
|
||||
|
|
39
resources/views/recipes/show.blade.php
Normal file
39
resources/views/recipes/show.blade.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
@extends('layouts.default')
|
||||
@extends('content_wrappers.md-10')
|
||||
|
||||
@section('title', ' | '.$recipe->name)
|
||||
@section('heading', $recipe->name)
|
||||
|
||||
@section('content')
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3 text-center">Created By: {{$recipe->author}}</div>
|
||||
<div class="col-md-3 text-center">Maintained By: {{$recipe->user->name}}</div>
|
||||
|
||||
<div class="col-md-3 text-center">Entered On: {{$recipe->date_entered->format('Y/m/d') }}</div>
|
||||
<div class="col-md-3 text-center">Last Changed: {{$recipe->date_modified->format('Y/m/d') }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-3 col-sm-3 text-center">Servings: {{$recipe->servings}}</div>
|
||||
<div class="col-sm-3 text-center">Serving Size: {{$recipe->serving_size}}</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="row"><div class="panel-heading"><h1>Ingredients</h1></div></div>
|
||||
|
||||
@foreach ($recipe->ingredients as $index => $ingredient)
|
||||
@if ($ingredient->alternative)
|
||||
OR {{$ingredient->quantity}} {{$ingredient->measurement}} {{$ingredient->name}}
|
||||
@else
|
||||
@if($index != 0) </div> @endif
|
||||
<div class="col-sm-offset-2 col-lg-4">{{$ingredient->quantity}} {{$ingredient->measurement}} {{$ingredient->name}}
|
||||
@endif
|
||||
@endforeach
|
||||
@if(count($recipe->ingredients) > 0)
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<br /><br />
|
||||
<div class="row"><div class="panel-heading"><h1>Instructions</h1></div></div>
|
||||
<div class="row"><div class="col-lg-12">{{$recipe->instructions}}</div>
|
||||
</div>
|
||||
@endsection
|
Loading…
Add table
Reference in a new issue