Exemple #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  StoreGameRequest $validationRequest
  * @return \Illuminate\Http\Response
  */
 public function store(StoreGameRequest $request)
 {
     $game = new Game($request->all());
     $game->save();
     Session::flash('message', 'Game created');
     return redirect('/game');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreProductRequest $request)
 {
     // validate request further according to type
     switch ($request->type) {
         case 'MOVIE':
         case 'SERIES':
         case 'ANIME':
         case 'VIDEO':
             $valRequest = new StoreVideoRequest();
             $this->validate($request, $valRequest->rules());
             $info = new Video($request->all());
             break;
         case 'GAME':
             $valRequest = new StoreGameRequest();
             $this->validate($request, $valRequest->rules());
             $info = new Game($request->all());
             break;
     }
     if (in_array($request->type, ['MOVIE', 'SERIES', 'ANIME', 'VIDEO'])) {
         $this->StoreVideo($request, $info);
     } else {
         if ($request->type == "GAME") {
             $this->StoreGame($request, $info);
         }
     }
     // flash message
     session()->flash('flash_message', 'Product added successfully.');
     return redirect()->route('products.create', ['type' => strtolower($request->type)]);
 }