Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  * POST /gallery
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::only(['title', 'body']);
     $rules = ['title' => 'required', 'body' => 'required'];
     $validation = Validator::make($data, $rules);
     if ($validation->fails()) {
         return Redirect::back()->withInput()->withErrors($validation->messages());
     } else {
         $gallery = new Gallery($data);
         $gallery->available = true;
         $gallery->slug = \Str::slug($data['title']);
         $gallery->save();
     }
     return Redirect::route('gallery', [$gallery->slug, $gallery->id])->with(['confirm' => 'Se inserto el registro correctamente.']);
 }