middleware('auth'); } public function index() { $adjuncts = Adjunct::orderBy('name')->get(); return view('adjuncts.index')->with('adjuncts', $adjuncts); } public function store(Request $request){ // validation $this->validate($request,[ 'name' => 'required', ]); // create project $adjunct = new Adjunct; $lastID = Adjunct::orderBy('id','desc')->take(1)->value('id'); $adjunct->id = number_format($lastID) + 1; $adjunct->name = $request->input('name'); $adjunct->save(); return redirect('/adjuncts')->with('success', 'Adjunct Added!'); } public function edit($id){ $adjunct = Adjunct::where('id', (int)$id)->first(); return view('adjuncts.edit')->with('adjunct', $adjunct); } public function update(Request $request, $id){ // validation $this->validate($request,[ 'name' => 'required', ]); $adjunct = Adjunct::where('id', (int)$id)->first(); $adjunct->name = $request->input('name'); $adjunct->save(); return redirect('/adjuncts')->with('success', 'Adjunct Updated!'); } public function create() { return view('adjuncts.create'); } public function destroy($id) { $adjunct = Adjunct::find($id); $adjunct->delete(); return redirect('/adjuncts')->with('success', 'Adjunct deleted!'); } }