/**
  * 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);
 }
 /**
  * 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();
     });
 }
 /**
  * live search
  */
 public function search(Request $request)
 {
     return Gallery::where('title', 'like', '%' . $request->keyword . '%')->orderBy('gallery.created_at', 'desc')->with('GalleryImages')->paginate(50);
 }
Beispiel #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Gallery::where('user_id', Auth::user()->id)->with('user')->get();
 }
Beispiel #5
0
 public function postUpdatePicture(AddPictureRequest $request)
 {
     if (null !== $request->file('url_img')) {
         $name = uniqid() . ".jpg";
         $request->file('url_img')->move(public_path('media/img/gallery/'), $name);
         Gallery::where('id', '=', $request['id'])->update(['title' => $request['title'], 'url_img' => $name]);
     } else {
         Gallery::where('id', '=', $request['id'])->update(['title' => $request['title']]);
     }
     return redirect()->action('AdminController@getIndex');
 }
Beispiel #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id_event, $id_photo)
 {
     if (Request::isMethod('get')) {
         $this->data = array();
         $this->data['event'] = Event::find($id_event);
         $this->data['gallery'] = Gallery::find($id_photo);
         return View::make('admin.event.konten.gallery.delete', $this->data);
     } else {
         if (Request::isMethod('post')) {
             $data = Input::all();
             Gallery::where('id', '=', $id_photo)->delete();
             return redirect('admin/event/update/' . $id_event);
         }
     }
 }
Beispiel #7
0
 public function addGallery(Request $request, Skill $skill)
 {
     //        if(!$request->hasFile('sample_file')) return response('No file was sent',404);
     $validator = Validator::make($request->all(), ['sample_file' => 'required | image']);
     if ($validator->fails()) {
         return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => trans('profile.invalidGallery'), 'msgType' => 'danger', 'returns' => ''];
     }
     $file = $request->file('sample_file');
     $input = $request->except('sample_file');
     $user = Auth::user();
     $imageName = $user->id . str_random(20) . '.' . $file->getClientOriginalExtension();
     $file->move(public_path() . '/img/files/' . $user->id . '/', $imageName);
     $real_name = $file->getClientOriginalName();
     $size = $file->getClientSize() / (1024 * 1024);
     //calculate the file size in MB
     $gallery = $skill->galleries()->create($input);
     $user->usage->add(filesize(public_path() . '/img/files/' . $user->id . '/' . $imageName) / (1024 * 1024));
     // storage add
     Gallery::where('id', $gallery->id)->first()->files()->create(['user_id' => $user->id, 'real_name' => $real_name, 'name' => $user->id . '/' . $imageName, 'size' => $size]);
     $input['file'] = $imageName;
     return ['hasCallback' => '1', 'callback' => 'skill_galleries', 'hasMsg' => 0, 'msg' => '', 'returns' => $skill->galleries()->with('files')->get()];
 }