My beer compendium
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.0 KiB

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Hop;
class HopController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$project = Hop::orderBy('name')->get();
return view('hops')->with('hops', $project);
}
public function store(Request $request){
// validation
$this->validate($request,[
'name' => 'required',
]);
// create project
$hop = new hop;
$lastID = Hop::orderBy('id','desc')->value('id');
$hop->id = number_format($lastID) + 1;
$hop->name = $request->input('name');
if ($request->input('alpha_acid'))
{
$hop->alpha_acid = $request->input('alpha_acid');
}
$hop->bitter = $request->input('bitter');
$hop->aroma = $request->input('aroma');
if ($request->input('beta_acid'))
{
$hop->beta_acid = $request->input('beta_acid');
}
if ($request->input('myrcene'))
{
$hop->myrcene = $request->input('myrcene');
}
if ($request->input('profile'))
{
$hop->profile = '{'.$request->input('profile').'}';
}
if ($request->input('humulene'))
{
$hop->humulene = $request->input('humulene');
}
if ($request->input('total_oil'))
{
$hop->total_oil = $request->input('total_oil');
}
if ($request->input('cohumulone'))
{
$hop->cohumulone = $request->input('cohumulone');
}
if ($request->input('farnesene'))
{
$hop->farnesene = $request->input('farnesene');
}
if ($request->input('caryophyllene'))
{
$hop->caryophyllene = $request->input('caryophyllene');
}
$hop->save();
return redirect('/hops')->with('success', 'Hop Added');
}
}