diff --git a/app/Http/Controllers/YeastController.php b/app/Http/Controllers/YeastController.php
index 9295973..e8ab40f 100644
--- a/app/Http/Controllers/YeastController.php
+++ b/app/Http/Controllers/YeastController.php
@@ -15,7 +15,7 @@ class YeastController extends Controller
public function index()
{
$yeasts = Yeast::orderBy('name')->get();
- return view('yeasts')->with('yeasts', $yeasts);
+ return view('yeasts.index')->with('yeasts', $yeasts);
}
public function store(Request $request){
@@ -27,7 +27,7 @@ class YeastController extends Controller
// create project
$yeast = new Yeast;
- $lastID = Yeast::orderBy('id','desc')->value('id');
+ $lastID = Yeast::orderBy('id','desc')->take(1)->value('id');
$yeast->id = number_format($lastID) + 1;
$yeast->name = $request->input('name');
if ($request->input('attenuation'))
@@ -39,10 +39,10 @@ class YeastController extends Controller
$yeast->flocculation = $request->input('flocculation');
}
if ($request->input('profile'))
- {
- $yeast->profile = '{'.$request->input('profile').'}';
- }
- if ($request->input('tolerance'))
+ {
+ $yeast->profile = '{'.$request->input('profile').'}';
+ }
+ if ($request->input('tolerance'))
{
$yeast->tolerance = $request->input('tolerance');
}
@@ -52,6 +52,54 @@ class YeastController extends Controller
}
$yeast->save();
- return redirect('/yeasts')->with('success', 'Yeast Added');
+ return redirect('/yeasts')->with('success', 'Yeast Added!');
+ }
+ public function edit($id){
+ $grain = Grain::where('id', (int)$id)->first();
+ return view('grains.edit')->with('grain', $grain);
+ }
+
+ public function update(Request $request, $id){
+ // validation
+ $this->validate($request,[
+ 'name' => 'required',
+ ]);
+
+ $yeast = Yeast::where('id', (int)$id)->first();
+ $yeast->name = $request->input('name');
+ if ($request->input('attenuation'))
+ {
+ $yeast->attenuation = $request->input('attenuation');
+ }
+ if ($request->input('flocculation'))
+ {
+ $yeast->flocculation = $request->input('flocculation');
+ }
+ if ($request->input('profile'))
+ {
+ $yeast->profile = '{'.$request->input('profile').'}';
+ }
+ if ($request->input('tolerance'))
+ {
+ $yeast->tolerance = $request->input('tolerance');
+ }
+ if ($request->input('temp_range'))
+ {
+ $yeast->temp_range = $request->input('temp_range');
+ }
+ $yeast->save();
+
+ return redirect('/yeasts')->with('success', 'Yeast Updated!');
+ }
+ public function create()
+ {
+ return view('yeasts.create');
+ }
+ public function destroy($id)
+ {
+ $yeast = Yeast::find($id);
+ $yeast->delete();
+
+ return redirect('/yeasts')->with('success', 'Yeast deleted!');
}
}
diff --git a/resources/views/yeasts.blade.php b/resources/views/yeasts.blade.php
index bae6344..9ede88a 100644
--- a/resources/views/yeasts.blade.php
+++ b/resources/views/yeasts.blade.php
@@ -1,87 +1,8 @@
@extends('layouts.app')
@section('content')
-
-
+
+@yield('main')
-
-
@endsection
diff --git a/resources/views/yeasts/create.blade.php b/resources/views/yeasts/create.blade.php
index e69de29..8f9df35 100644
--- a/resources/views/yeasts/create.blade.php
+++ b/resources/views/yeasts/create.blade.php
@@ -0,0 +1,48 @@
+@extends('yeasts')
+
+@section('main')
+
+@endsection
diff --git a/resources/views/yeasts/edit.blade.php b/resources/views/yeasts/edit.blade.php
index e69de29..adfc884 100644
--- a/resources/views/yeasts/edit.blade.php
+++ b/resources/views/yeasts/edit.blade.php
@@ -0,0 +1,47 @@
+@extends('yeasts')
+@section('main')
+@endsection
diff --git a/resources/views/yeasts/index.blade.php b/resources/views/yeasts/index.blade.php
index e69de29..c8d97ee 100644
--- a/resources/views/yeasts/index.blade.php
+++ b/resources/views/yeasts/index.blade.php
@@ -0,0 +1,49 @@
+@extends('yeasts')
+
+@section('main')
+
+
+
+
+@include('inc.navbar')
+
+
+
+@if (Auth::user()->isAdmin())
+
Add Yeast
+
+@endif
+
+
+ @include('inc.messages')
+
+
+ Name |
+ Profile |
+ @if (Auth::user()->isAdmin())Admin | @endif
+
+
+
+
+ @foreach ($yeasts as $yeast)
+
+ {{$yeast->name}} |
+ {{str_replace(' ,',',',str_replace('"',' ',str_replace(',',', ',str_replace('}', '', str_replace('{','',$yeast->profile)))))}} |
+ @if (Auth::user()->isAdmin())
+ Edit |
+ |
+ @endif
+
+ @endforeach
+
+
+
+
+
+
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index 0828717..4894966 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -26,10 +26,10 @@ Route::resource('breweries', 'App\Http\Controllers\BrewerieController');
Route::resource('beers', 'App\Http\Controllers\SummarieController');
Route::resource('grains', 'App\Http\Controllers\GrainController');
Route::resource('hops', 'App\Http\Controllers\HopController');
+Route::resource('yeasts', 'App\Http\Controllers\YeastController');
Route::get('/home', [App\Http\Controllers\SummarieController::class, 'index'])->name('home');
Route::get('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'index'])->name('adjuncts');
-//Route::get('/hops', [App\Http\Controllers\HopController::class, 'index'])->name('hops');
-Route::get('/yeasts', [App\Http\Controllers\YeastController::class, 'index'])->name('yeasts');
+//Route::get('/yeasts', [App\Http\Controllers\YeastController::class, 'index'])->name('yeasts');
Route::get('/fermentations', [App\Http\Controllers\FermentationController::class, 'index'])->name('fermentations');
Route::get('/grainbills', [App\Http\Controllers\GrainbillController::class, 'index'])->name('grainbills');
Route::get('/mashes', [App\Http\Controllers\MasheController::class, 'index'])->name('mashes');
@@ -41,8 +41,7 @@ Route::get('/grain/{grainID}', [App\Http\Controllers\GraincardController::class,
Route::get('/yeast/{yeastID}', [App\Http\Controllers\YeastcardController::class, 'index'])->name('yeast');
Route::get('/hop/{hopID}', [App\Http\Controllers\HopcardController::class, 'index'])->name('hop');
Route::get('/adjunct/{adjunctID}', [App\Http\Controllers\AdjunctcardController::class, 'index'])->name('adjunct');
-//Route::post('/hops', [App\Http\Controllers\HopController::class, 'store'])->name('hops.store');
-Route::post('/yeasts', [App\Http\Controllers\YeastController::class, 'store'])->name('yeasts.store');
+//Route::post('/yeasts', [App\Http\Controllers\YeastController::class, 'store'])->name('yeasts.store');
Route::post('/adjuncts', [App\Http\Controllers\AdjunctController::class, 'store'])->name('adjuncts.store');
Route::post('/grainbills', [App\Http\Controllers\GrainbillController::class, 'store'])->name('grainbills.store');
Route::post('/mashes', [App\Http\Controllers\MasheController::class, 'store'])->name('mash.store');