Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sort_scenes = Scene::all()->sortBy(function ($scene, $key) {
         // todo order by subscenes (a, b, c). Currently they appear before original
         if (preg_match('/a$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.1;
         }
         if (preg_match('/b$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.2;
         }
         if (preg_match('/c$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.3;
         }
         if (preg_match('/d$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.4;
         }
         if (preg_match('/e$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.5;
         }
         if (preg_match('/f$/', $scene['scn_no'])) {
             return intval($scene['scn_no']) + 0.6;
         } else {
             return intval($scene['scn_no']);
         }
     });
     // Default collection to sort by scene number
     $sort = Input::get('sort') ? Input::get('sort') : 'story';
     switch ($sort) {
         case 'location':
             $scenes = $sort_scenes->groupBy(function ($item, $key) {
                 $setting = Setting::find($item['setting_id']);
                 return $setting->location . ' ' . $setting->set_name;
             })->sortBy(function ($item, $key) {
                 return $key;
             });
             break;
         case 'shoot day':
             $scenes = Scene::all()->sortBy('setting_id')->groupBy('filming_day')->sortBy(function ($item, $key) {
                 return intval($key);
             });
             break;
         case 'story':
         default:
             $scenes['Story order'] = $sort_scenes;
             break;
     }
     return view('scenes.index', compact('scenes'));
 }
Пример #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Scenes\Setting
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Setting $setting)
 {
     $setting->fill($request->all())->save();
     Session::flash('message', 'Successfully updated Setting!');
     return Redirect::to('settings');
 }