Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  * POST /admin\gallery
  *
  * @return Response
  */
 public function store()
 {
     try {
         $rules = array('name' => 'required|unique:gallery');
         $validation = Validator::make(Input::all(), $rules);
         if ($validation->fails()) {
             return Redirect::back()->withInput()->withErrors($validation->messages());
         }
         $gallery = new Gallery();
         $gallery->name = Input::get('name');
         $gallery->description = Input::get('description');
         if ($gallery->save()) {
             return Redirect::to('admin/galeria/kep/' . $gallery->id . '/upload')->with('message', 'A galéria feltöltése sikerült!');
         } else {
             return Redirect::back()->withInput()->withErrors('A galéria feltöltése nem sikerült!');
         }
     } catch (Exception $e) {
         if (Config::get('app.debug')) {
             return Redirect::back()->withInput()->withErrors($e->getMessage());
         } else {
             return Redirect::back()->withInput()->withErrors('A galéria feltöltése nem sikerült!');
         }
     }
 }