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.
 
 
 
 
 
 

46 lines
1.1 KiB

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Grainbill;
class GrainbillController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$project = Grainbill::get();
return view('grainbills')->with('grainbills', $project);
}
public function store(Request $request){
// validation
$this->validate($request,[
'beer_id' => 'required',
'grain_id' => 'required',
'amount' => 'required',
'grain_bill' => 'required',
]);
// create project
$grain = new Grainbill;
$lastID = Grainbill::orderBy('id','desc')->value('id');
$grain->id = number_format($lastID) + 1;
$grain->beer_id = $request->input('beer_id');
$grain->grain_id = $request->input('grain_id');
$grain->amount = $request->input('amount');
$grain->grain_bill = $request->input('grain_bill');
$grain->save();
return redirect('/grainbills')->with('success', 'Grain Bill Added');
}
}