/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { if ($request['industryId'] != 0) { $retindustry = Industry::whereId($request['industryId'])->first(); if ($retindustry) { $industry = Industry::find($request['industryId']); $industry->name = $request['name']; $industry->save(); Session::flash('message', 'Industry Updated Successfully'); } } else { $industry = new Industry(); $industry->name = $request['name']; $industry->save(); Session::flash('message', 'Industry added Successfully'); } return Redirect::to('industry'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { // $v = Validator::make(Request::all(), ['name' => 'required|max:30']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } else { $id = Request::get('id'); $industry = Industry::find($id); $industry->name = Request::get('name'); $industry->save(); return redirect('industries'); } }