Browse Source

beers refactor mkVIII

master
jk 3 years ago
parent
commit
c348699a42
  1. 9
      app/Http/Controllers/SummarieController.php
  2. 3
      resources/views/beers/create.blade.php

9
app/Http/Controllers/SummarieController.php

@ -36,14 +36,14 @@ class SummarieController extends Controller
'og' => 'required',
'source' => 'required',
'batch' => 'required',
'beer_id' => 'required',
'brewery_id' => 'required'
]);
// create project
$beer = new Summarie;
$lastID = Summarie::orderBy('beer_id','desc')->value('beer_id');
$beer->beer_id = number_format($lastID) + 1;
$beer->beer_id = $request->input('beer_id')
$beer->name = $request->input('name');
$beer->type = $request->input('type');
$beer->abv = $request->input('abv');
@ -116,7 +116,10 @@ class SummarieController extends Controller
}
public function create()
{
return view('beers.create');
$lastID = Summarie::orderBy('beer_id','desc')->value('beer_id');
$beer_id = number_format($lastID) + 1;
return view('beers.create')->with('beer_id', $beer_id);
}
public function destroy($id)
{

3
resources/views/beers/create.blade.php

@ -17,6 +17,9 @@
<form method="post" action="{{ route('beers.store') }}">
@csrf
<div class="form-group">
<label for="beer_id">Beer ID</label>
<input type="text" class="form-control" name="beer_id" vale="{{$beer_id}}">
</div>
<label for="name">Name</label>
<input type="text" class="form-control" name="name">
</div>

Loading…
Cancel
Save