/** * Store a newly created resource in storage. * * @return Response */ public function store($gallery_id) { $input = \Input::all(); $validation = new \Itestense\LaravelPhotogallery\Validators\Photo(); if ($validation->passes()) { $filename = str_random(10) . time() . "." . \Input::file('path')->getClientOriginalExtension(); $destination = public_path() . \Config::get('upload_dir') . "/"; $upload = \Input::file('path')->move($destination, $filename); $img = \Image::make($destination . $filename); $formats = \Config::get('laravel-photogallery::formats'); foreach ($formats as $name => $format) { $img->resize($format['w'], $format['h'], function ($constraint) { $constraint->aspectRatio(); }); $img->save($destination . $name . '/' . $filename, $format['q']); } if ($upload == false) { return \Redirect::to('gallery.photo.create')->withInput()->withErrors($validation->errors)->with('message', 'Errori'); } $photo = new Photo(); $photo->name = \Input::get('name'); $photo->description = \Input::get('description'); $photo->path = $filename; $photo->save(); $g = Gallery::findOrFail(1); $photo->galleries()->attach($g); //return \Redirect::route("gallery.photo.show", array('id' => $photo->id)); } else { return \Redirect::route('gallery.photo.create')->withInput()->withErrors($validation->errors)->with('message', \Lang::get('gallery::gallery.errors')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = \Input::all(); $validation = new \Itestense\LaravelPhotogallery\Validators\Photo(); if ($validation->passes()) { $files = \Input::file('images'); foreach ($files as $file) { $this->save_file($file); } return \Redirect::route(Utils::routeprefix("photo.index")); } else { return \Redirect::route('gallery.photo.create')->withInput()->withErrors($validation->errors)->with('message', \Lang::get('gallery::gallery.errors')); } }