public function doDelete($id) { $input = Request::all(); $rules = array('lokasi' => 'required|exists:lokasi,id'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return view('error'); } else { $penyimpanan = Penyimpanan::where('id_lokasi', $id)->update(["id_lokasi" => $input['lokasi']]); $lokasi = Lokasi::find($id); $lokasi->delete(); return redirect('/lokasi'); } }
public function add() { $input = Request::all(); $rules = array('lokasi' => 'required|exists:lokasi,id', 'nama' => 'required', 'kode' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return view('error'); } else { $alat = new Alat(); $alat->fill($input); $alat->save(); $penyimpanan = new Penyimpanan(); $penyimpanan->id_alat = $alat->id; $penyimpanan->id_lokasi = $input['lokasi']; $penyimpanan->save(); return redirect('/'); } }