public function status($bookId, $modelType, $modelId) { $model = $modelType::find($modelId); $status_id = $model->books()->where('book_id', '=', $bookId)->first()->pivot->status_id; $status = \App\BookStatus::find($status_id); return $status; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $bookstatus = \App\BookStatus::find($id); if ($bookstatus) { $rules = \App\BookStatus::$rules; //$rules['name'] = 'required|min:2'; $validator = \Validator::make(\Input::all(), $rules); if ($validator->passes()) { $bookstatus = \App\BookStatus::find($id); $bookstatus->name = \Input::get('name'); $bookstatus->save(); flash('Book Status updated'); return \Redirect::back(); } return \Redirect::back()->withInput()->withErrors($validator); } flash()->error('Book Status does not exist.'); return \Redirect::back(); }