/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $images = $request->input('images');
     $gallery_name = 'gallery_' . time();
     $directory = 'uploads/' . $gallery_name . '/';
     mkdir($directory, 0755);
     $gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
     foreach ($images as $image) {
         $url = $image['url'];
         $img = Image::make($url);
         $img->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         preg_match('/\\.[^\\.]+$/i', $url, $ext);
         $filename = $directory . time() . $ext[0];
         $stream = $img->stream();
         $s3 = Storage::disk('s3');
         $s3->put($filename, $stream->__toString(), 'public');
         $client = $s3->getDriver()->getAdapter()->getClient();
         $public_url = $client->getObjectUrl(env('S3_BUCKET'), $filename);
         $gallery->images()->create(['url' => $public_url]);
     }
     $response = ['message' => 'Images successfully uploaded', 'redirect' => url('gallery', $gallery_name)];
     return response()->json($response);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:3|max:100', 'date' => 'required', 'visible' => 'required']);
     $data = $request->all();
     if ($request->file) {
         $validate = ImageHelper::validate($request->file, 2000000);
         if (!$validate['success']) {
             return response()->json([$validate['message']], 422);
         }
     }
     if (isset($data['files'])) {
         $validate_multiple = ImageHelper::validateMultiple($data['files'], 20000000);
         if (!$validate_multiple['success']) {
             return response()->json([$validate_multiple['message']], 422);
         }
     }
     if ($request->file) {
         $image = ImageHelper::create($data['file'], 600, 'admin/images/gallery/');
         $data['image'] = $image['filename'];
     }
     $gallery = Gallery::create($data);
     if (isset($data['files'])) {
         $image_multiple = ImageHelper::createMultiple($data['files'], 600, 'admin/images/gallery/');
         for ($i = 0; $i < count($data['files']); $i++) {
             $gallery->galleryImages()->save(new GalleryImages(['name' => $image_multiple['filenames'][$i]]));
         }
     }
     return response()->json(['message' => 'Gallery successfully Created']);
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validaor = Validator::make($request->all(), ['name' => 'required|min:3']);
     if ($validaor->fails()) {
         return response($validaor->errors()->all(), 422);
     }
     $gallery = Gallery::create(['name' => $request->input('name'), 'user_id' => Auth::user()->id]);
     return response($gallery, 201);
 }
Example #4
0
 public function store()
 {
     $file = Input::file('image');
     $destinationPath = 'uploads';
     // give path of directory where you want to save your files
     $filename = rand(1111, 9999) . '.' . Input::file('image')->guessExtension();
     $image = Input::file('image')->move($destinationPath, $filename);
     Gallery::create(['image' => '/' . $image]);
     return redirect()->route('gallery.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function saveGallery(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:3']);
     //Auth::user();
     $request['created_by'] = Auth::user()->id;
     $request['published'] = Auth::user()->id;
     $galleryData = Gallery::create($request->all());
     return redirect()->back();
     //
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CustomRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(CustomRequest $request)
 {
     if (!$request->hasFile('image')) {
         return redirect(route('admin.galleries.create'))->with('error', 'Veuillez choisir une image');
     }
     $id = Gallery::max('id');
     if ($request->hasFile('image') && $request->file('image')->move(base_path() . '/public/images/galleries', $id . '.' . $request->file('image')->getClientOriginalExtension())) {
         $request->merge(['picture' => $id . '.' . $request->file('image')->getClientOriginalExtension()]);
         $gallery = Gallery::create($request->all());
         mkdir(base_path() . '/public/images/galleries/' . $gallery->id);
         return redirect(route('admin.galleries.index'))->with('success', 'La galerie photo a bien été ajoutée');
     }
     return redirect(route('admin.galleries.index'))->with('error', 'Une erreur est survene lors de l\'upload de l\'image. Veuillez réessayer');
 }
Example #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $faker = Faker\Factory::create('it_IT');
     $galleryCount = 10;
     $imgs = $captions = "";
     for ($i = 0; $i <= 5; $i++) {
         $imgs .= $faker->imageUrl($width = 640, $height = 480) . ", ";
         $captions .= $faker->sentence($nbWords = 3) . ", ";
     }
     for ($c = 0; $c <= $galleryCount; $c++) {
         Gallery::create(['description_id' => 1, 'name' => $faker->sentence(), 'image' => $imgs, 'caption' => $captions, 'is_published' => 1, 'published_at' => $faker->dateTimeThisYear($max = 'now')]);
     }
 }
Example #8
0
 public function ajaxtest(Request $request)
 {
     $file_nums = count($request->file("images"));
     $rules = ['captions' => 'required'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return $validator->errors()->all();
     } else {
         for ($i = 0; $i < $file_nums; $i++) {
             $file = $request->file("images")[$i];
             $file->move("galleryimages", $file->getClientOriginalName());
             $data = ["caption" => $request->input('captions')[$i], "image_name" => $file->getClientOriginalName()];
             Gallery::create($data);
         }
         return response()->json(["msg" => "success"]);
     }
 }
Example #9
0
 public function uploadImages(Request $request)
 {
     $images = $request->input('images');
     $gallery_name = 'gallery_' . time();
     $directory = 'uploads/' . $gallery_name . '/';
     mkdir($directory, 0755);
     $gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
     foreach ($images as $image) {
         $url = $image['url'];
         $img = Image::make($url);
         $img->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         preg_match('/\\.[^\\.]+$/i', $url, $ext);
         $filename = $directory . time() . $ext[0];
         $img->save($filename);
         $gallery->images()->create(['url' => $filename]);
     }
     $response = ['message' => 'Images successfully uploaded'];
     return response()->json($response);
 }
Example #10
0
 public function run()
 {
     DB::table('galleries')->delete();
     Gallery::create(array('title' => 'Название1', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название2', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название3', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название4', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название5', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название5', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название7', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название8', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название9', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название10', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название11', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название12', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название13', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название14', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
     Gallery::create(array('title' => 'Название15', 'url_img' => 'test.jpg', "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(GalleryRequest $request)
 {
     Gallery::create($request->all());
     flashMessage("The gallery has been added.", "alert-success");
     return redirect('galleries');
 }
Example #12
0
 public function postAddPicture(AddPictureRequest $request)
 {
     if (null !== $request->file('url_img')) {
         $name = uniqid() . ".jpg";
         $request->file('url_img')->move(public_path('media/img/gallery/'), $name);
     } else {
         $name = "test.jpg";
     }
     Gallery::create(['title' => $request['title'], 'url_img' => $name]);
     return redirect()->action('AdminController@getIndex');
 }
Example #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $gallery = \App\Gallery::create(['name' => 'blalba']);
 }