コード例 #1
0
ファイル: Book.php プロジェクト: atindermann08/readr
 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;
 }
コード例 #2
0
 /**
  * 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();
 }