Esempio n. 1
0
 public function save()
 {
     $recordId = Input::get('record');
     $muId = Input::get('mu_id');
     $locked = Input::get('locked');
     $delete = Input::get('delete');
     $update = Input::get('update');
     $comment = Input::get('comment');
     // load record
     $record = PathRecord::findOrFail($recordId);
     // remove series link
     if ($delete) {
         $record->series_id = null;
     } else {
         if ($update) {
             // download new data from MU
             if ($record->series) {
                 $record->series->updateMuData();
             }
         } elseif ($muId) {
             // get series
             $series = Series::getCreateFromMuId($muId);
             if (!$series) {
                 Session::flash('error', 'Failed to find series for MU ID');
                 return Redirect::back();
             }
             $record->series_id = $series->id;
         }
         $record->comment = $comment;
         $user = Auth::user();
         if ($user && $user->hasSuper()) {
             $record->locked = !!$locked;
         }
     }
     $record->save();
     Session::flash('success', 'Saved path details successfully');
     return Redirect::back();
 }