示例#1
0
 /**
  * view pics for a particular gallery
  */
 public function viewGalleryPics($id)
 {
     // a gallery is specific to a user id
     $gallery = Gallery::findOrFail($id);
     // should catch the exception and redirect to proper page
     return view('gallery.gallery-view')->with('gallery', $gallery);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users_count = User::count();
     $posts_count = Post::count();
     $galleries_count = Gallery::count();
     return response()->json(['users_count' => $users_count, 'posts_count' => $posts_count, 'galleries_count' => $galleries_count]);
 }
 /**
  * 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);
 }
 public function gallery()
 {
     $galleries = Gallery::orderBy('id', 'DESC')->paginate(8);
     $galleries->setPath('');
     $setting = Setting::first();
     return view('sites.gallery', compact('galleries', 'setting'));
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $galleriesQueryBuilder = Gallery::where('ignore_this_site', '=', 0);
     $narrowColumns = [(new FieldConfig('id'))->setLabel('Actions')->setSortable(true)->setCallback(function ($val) {
         $iconShow = '<span class="fa fa-eye"></span>&nbsp;';
         $hrefShow = action('GalleriesController@show', [$val]);
         $iconUpdate = '<span class="fa fa-pencil"></span>&nbsp;';
         $hrefUpdate = action('GalleriesController@edit', [$val]);
         $iconDelete = '<span class="fa fa-times"></span>&nbsp;';
         $hrefDelete = action('GalleriesController@delete', [$val]);
         return '<a href="' . $hrefShow . '">' . $iconShow . '</a>&emsp;' . '<a href="' . $hrefUpdate . '">' . $iconUpdate . '</a>&emsp;' . '<a href="' . $hrefDelete . '">' . $iconDelete . '</a>';
     }), (new FieldConfig('name'))->setSortable(true)->setSorting(Grid::SORT_ASC), (new FieldConfig('url'))->setCallback(function ($val) {
         return '<a href="' . $val . '" target="_blank">' . $val . '</a>';
     })];
     $additionalColumns = [(new FieldConfig('accepts_submissions'))->setLabel('AS')->setCallback(function ($val) {
         if ($val) {
             return '<span class="fa fa-check"></span>&nbsp;';
         }
     }), (new FieldConfig('reblog_posts'))->setLabel('RP')->setCallback(function ($val) {
         if ($val) {
             return '<span class="fa fa-check"></span>&nbsp;';
         }
     }), (new FieldConfig('reblogs'))->setSortable(true)];
     $wideColumns = array_merge($narrowColumns, $additionalColumns);
     $narrowCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($galleriesQueryBuilder))->setColumns($narrowColumns);
     $narrowGrid = new Grid($narrowCfg);
     $wideCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($galleriesQueryBuilder))->setColumns($wideColumns);
     $grid = new Grid($wideCfg);
     return array('narrowGrid' => $narrowGrid, 'grid' => $grid);
 }
 public function getGalleryImages($galleryId)
 {
     $gallery = Gallery::findOrFail($galleryId);
     $set = $gallery->getOrdered()->map(function ($item) {
         return ['image_id' => $item->id, 'src' => $item->getUrl(), 'thumb_src' => $item->getUrl('thumb')];
     });
     return response()->json($set);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('gallery', function ($name) {
         return \App\Gallery::where('name', $name)->firstOrFail();
     });
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $submission = Submission::findOrFail($id);
     $photoSrc = '/photo_files/normal/' . $submission->photo->file_name;
     $galleryList = array();
     $galleries = Gallery::orderBy('name', 'asc')->get();
     foreach ($galleries as $gallery) {
         $galleryList[strval($gallery->id)] = $gallery->name;
     }
     return view('submissions.edit')->with(['submission' => $submission, 'photoSrc' => $photoSrc, 'photoId' => $submission->photo_id, 'galleryList' => $galleryList, 'galleryId' => null]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         $gallery = Gallery::with('pictures')->findOrFail($id);
     } catch (Exception $e) {
         return back()->with('error', trans('default.gallerynotfound'));
     }
     $title = $gallery->{'name_' . App::getLocale()};
     //$pictures = File::files(base_path() . '/public/images/galleries/' . $gallery->id);
     return view('galleries.show', compact('title', 'gallery'));
 }
示例#10
0
 public function deleteGallery($id)
 {
     $user = Auth::user();
     $gallery = Gallery::whereIn('user_id', function ($query) use($user) {
         $query->select('id')->from('users')->where('id', $user->id);
     })->where('id', $id)->first();
     if (!$gallery) {
         return response()->json(['status' => 'error']);
     }
     $gallery->delete();
     $galleries = Auth::user()->galleries()->with('pictures')->get();
     return response()->json(['data' => $galleries->toArray()], 200);
 }
示例#11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['image' => 'required']);
     if ($validator->fails()) {
         return redirect('galery')->withErrors($validator)->withInput();
     }
     $gallery_name = $request->input('gallery_name');
     $files = $request->file('myfile');
     //$captions     =   $request->input('caption');
     if (empty($gallery_name)) {
         //if no gallery is named, then
         $gallery_name = 'Timeline Photos';
     }
     $gallery = new Gallery();
     $gallery->name = $gallery_name;
     $gallery->save();
     //save gallery for once in gallery table
     //for image counting, files is in array so used array_filter($files)
     for ($i = 0; $i < count(array_filter($files)); $i++) {
         $filename = uniqid() . $files[$i]->getClientOriginalName();
         if (!file_exists('gallery/images')) {
             //create file
             mkdir('gallery/images', 077, true);
         }
         $files[$i]->move('gallery/images', $filename);
         //upload image to folder
         $image = new ImageModel();
         //$image->caption     =  $captions[$i];
         $image->file_name = $filename;
         $image->file_size = $files[$i]->getClientSize();
         $image->file_mime = $files[$i]->getClientMimeType();
         $image->file_path = 'gallery/images/' . $filename;
         $gallery->image()->save($image);
     }
     //saving images to image table with eloquent relationship
     //gallery id is passed automatically to image table
     //Session::flash('flash_message','Image succesfully Updated');
     //return redirect('/galery');
 }
示例#12
0
 public function postAddPhotos($id, Request $request)
 {
     $files = $request->files;
     foreach ($files as $file) {
         $path = '' . base_path() . '/pics/' . $id;
         $name = $file->getClientOriginalName();
         $filename = $file->move($path, $name);
         $picture = Gallery::find($id)->pictures()->create(['url' => $file->getClientOriginalName()]);
     }
     $gallery = Gallery::find($id);
     $pics = $gallery->pictures;
     return response()->json(['data' => $pics->toArray()]);
     return response()->json(['status' => 'done']);
 }
示例#13
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')]);
     }
 }
 /**
  * Дейстиве для отображения страницы галереи компании.
  *
  * @param $company
  * @return \Illuminate\View\View
  */
 public function getShow($company)
 {
     // Статья
     Model::unguard();
     $data['article'] = Article::firstOrCreate(['type' => 'gallery_' . $company . '_description']);
     Model::reguard();
     // Фотографии
     $data['photos'] = Gallery::whereHas('company', function ($query) use($company) {
         $query->where('short_title', '=', $company);
     })->orderBy('created_at', 'DESC')->paginate(9);
     // Компания
     $data['company'] = Company::whereShortTitle($company)->first(['title']);
     // Отображаем
     return view('marketing.galleries.show', $data);
 }
示例#15
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);
 }
 public function index(Gallery $gallery)
 {
     $this->data['gallery'] = $gallery->getPhotos();
     return view('pages.gallery', $this->data);
 }
示例#17
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Gallery::with('user')->where('id', $id)->first();
 }
示例#18
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"));
 }
示例#19
0
 public function destroy($id)
 {
     $gallery = Gallery::find($id);
     $gallery->delete();
     return redirect()->route('gallery.index');
 }
 public function destroy(Gallery $gallery)
 {
     //
     $gallery->delete();
     return redirect('galleries');
 }
示例#21
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $galleryObj = new Gallery();
     return $galleryObj->getSingleGallery($id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function doImageUpload(Request $request)
 {
     //get the file from post request
     $file = $request->file('file');
     //set my filename
     $filename = uniqid() . $file->getClientOriginalName();
     //move file to corect location
     $file->move('gallery/images/', $filename);
     //save in db
     $gallery = Gallery::find($request->input('gallery_id'));
     $image = $gallery->images()->create(['gallery_id' => $request->input('gallery_id'), 'file_name' => $filename, 'file_size' => $file->getClientSize(), 'file_mime' => $file->getClientMimeType(), 'file_path' => 'Gallery/images/' . $filename, 'created_by' => Auth::user()->id]);
     return $image;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $gallery = Gallery::findOrFail($id);
     $name = $gallery->name;
     $gallery->delete();
     flashMessage("'{$name}' has been deleted.", "alert-success");
     return redirect('galleries');
 }
 /**
  * live search
  */
 public function search(Request $request)
 {
     return Gallery::where('title', 'like', '%' . $request->keyword . '%')->orderBy('gallery.created_at', 'desc')->with('GalleryImages')->paginate(50);
 }
 /**
  * Удаление фотографии.
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getDelete($id)
 {
     $photo = Gallery::find($id);
     if (empty($photo)) {
         abort(404);
     }
     // Удаляем изображение
     File::delete(public_path('assets' . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'galleries' . DIRECTORY_SEPARATOR . $photo->file_name));
     $photo->delete();
     return redirect()->back()->with('success', 'Фотография успешно удалена.');
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function getShow($id)
 {
     //
     $photo = Gallery::find($id);
     return view('gallery.show', compact('photo'));
 }
示例#27
0
 public function getSingleGallery($id)
 {
     $gallery = Gallery::with('user')->where('id', $id)->first();
     $gallery->images = $this->getGalleryImageUrls($id, $gallery->id);
     return $gallery;
 }
示例#28
0
 public function getGallery($gallery_id)
 {
     $gallery = Gallery::findOrFail($gallery_id);
     $pictures = $gallery->pictures;
     return response()->json(['data' => $pictures->toArray(), 'gallery_title' => $gallery->title, 'description' => $gallery->description]);
 }
 public function viewGalleryPics($id)
 {
     $gallery = Gallery::findOrFail($id);
     return view('gallery.gallery-view')->with('gallery', $gallery);
 }
示例#30
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Gallery::destroy($id);
     $showDefault = cmsHelp('App\\Gallery', 'galleries');
     return Redirect('galleryAdmin')->with($showDefault);
 }