Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  * POST /series
  *
  * @return Response
  */
 public function store()
 {
     $path = public_path() . '/uploads';
     //
     $seriesTitle = Input::get('SeriesTitle');
     $seriesDescription = Input::get('SeriesDesc');
     $episodeTitle = Input::get('EpisodeTitle');
     $episodeDesc = Input::get('EpisodeDesc');
     $seriesType = Input::get('EpisodeType');
     $episodeFile = Input::file('EpisodeFile');
     $file = [];
     foreach ($episodeFile as $key => $value) {
         # code...
         $file[] = $value->getClientOriginalName();
         $value->move($path, $value->getClientOriginalName());
     }
     $tmp = array('epsTitle' => $episodeTitle, 'EpsDescription' => $episodeDesc, 'filename' => $file);
     $keys = array_keys($tmp);
     $iteration = count($tmp[$keys[0]]);
     $eps = [];
     for ($i = 0; $i < $iteration; $i++) {
         $data = array();
         foreach ($tmp as $key => $value) {
             # code...
             $data[$key] = $value[$i];
             // $data['file'] = $value->getClientOriginalName();
         }
         $eps[] = array_merge($data);
     }
     // echo "<pre>";
     // var_dump($eps);
     // echo "</pre>";
     // Create Series
     $series = new Series();
     $series->title = strtolower($seriesTitle);
     $series->description = strtolower($seriesTitle);
     $series->type = $seriesType;
     $series->user_id = Auth::id();
     $series->category_id = 1;
     $series->save();
     // //Create Document
     $input = array();
     foreach ($eps as $key => $value) {
         # code...
         $input[] = new Documents(['title' => $value['epsTitle'], 'description' => $value['EpsDescription'], 'path' => $path . '/' . $value['filename']]);
     }
     $ser = Series::find($series->id);
     $ser->document()->saveMany($input);
     return Redirect::to('home');
 }
 public function actionArtistworks3()
 {
     $id = \Yii::$app->request->post('id');
     $series = Series::find()->joinWith('works')->where(['artist_id' => $id])->all();
     //return $series;
     return new ActiveDataProvider(['query' => Series::find()->joinWith('works')->where(['artist_id' => $id])->all()]);
 }
Ejemplo n.º 3
0
 /**
  * Remove the specified series from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Series::find($id)->xcast()->detach();
     Series::destroy($id);
     return Redirect::route('admin.series.index');
 }
Ejemplo n.º 4
0
 public function seriesDetail($id)
 {
     $series = Series::find($id);
     return View::make('site.series-detail', compact('series'));
 }