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.
|
|
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request; use App\Models\Yeast; class YeastController extends Controller { public function __construct() { $this->middleware('auth'); }
public function index() { $yeasts = Yeast::orderBy('name')->get(); return view('yeasts')->with('yeasts', $yeasts); }
public function store(Request $request){ // validation
$this->validate($request,[ 'name' => 'required', ]);
// create project
$yeast = new Yeast; $lastID = Yeast::orderBy('id','desc')->value('id'); $yeast->id = number_format($lastID) + 1; $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 Added'); } }
|