public function index() { if (Auth::user()->check()) { $page = Input::has('page') ? Input::get('page') : 1; $take = Input::has('take') ? Input::get('take') : 20; $skip = ($page - 1) * $take; $data = VIImage::select('images.id', 'image_details.detail_id', 'image_details.width', 'image_details.height', 'image_details.dpi', 'image_details.size', 'image_details.size_type', 'image_details.path', 'images.name', 'images.short_name', 'images.description', 'images.store')->leftJoin('image_details', function ($join) { $join->on('image_details.image_id', '=', 'images.id'); })->where('images.author_id', Auth::user()->get()->id)->orderBy('images.id', 'desc')->groupBy('images.id'); $total_image = $data->get()->count(); $total_page = ceil($total_image / $take); $from = $page - 2 > 0 ? $page - 2 : 1; $to = $page + 2 <= $total_page ? $page + 2 : $total_page; $data = $data->skip($skip)->take($take)->get(); $arrImages = array(); if ($data->count() > 0) { $i = 0; foreach ($data as $key => $value) { $arrImages[$i]['image_id'] = $value->id; $arrImages[$i]['detail_id'] = $value->detail_id; $arrImages[$i]['name'] = $value->name; $arrImages[$i]['short_name'] = $value->short_name; $arrImages[$i]['description'] = $value->description; $arrImages[$i]['store'] = $value->store; $arrImages[$i]['path'] = '/pic/with-logo/' . $value->short_name . '-' . $value->id . '.jpg'; $i++; } } $this->layout->metaTitle = Auth::user()->get()->first_name . '\'s Uploads'; $this->layout->content = View::make('frontend.upload.index', ['files' => $arrImages, 'categories' => Category::getSource(), 'total_image' => $total_image, 'total_page' => $total_page, 'current' => $page, 'from' => $from, 'to' => $to]); return; } return Redirect::route('account-sign-in'); }
public function index() { if (!Input::has('page')) { $pageNum = 1; } else { $pageNum = (int) Input::get('page'); } $admin_id = Auth::admin()->get()->id; $arrCategories = []; $name = ''; $take = $this->take; $skip = floor(($pageNum - 1) * $take); $images = VIImage::select('id', 'name', 'short_name', 'description', 'keywords', 'artist', 'model', 'gender', 'age_from', 'age_to', 'number_people', DB::raw('(SELECT COUNT(*) FROM notifications WHERE notifications.item_id = images.id AND notifications.item_type = "Image" AND notifications.admin_id = ' . $admin_id . ' AND notifications.read = 0 ) as new'))->withType('main')->with('categories')->with('collections'); if (Input::has('categories')) { $arrCategories = (array) Input::get('categories'); $images->whereHas('categories', function ($query) use($arrCategories) { $query->whereIn('id', $arrCategories); }); } if (Input::has('name')) { $name = Input::get('name'); $nameStr = '*' . $name . '*'; $images->search($nameStr); } $images = $images->take($take)->skip($skip)->orderBy('id', 'desc')->get(); $arrImages = []; if (!$images->isempty()) { $arrImages = $arrRemoveNew = []; foreach ($images as $image) { $image->path = URL . '/pic/large-thumb/' . $image->short_name . '-' . $image->id . '.jpg'; $image->dimension = $image->width . 'x' . $image['height']; if ($image->new) { $arrRemoveNew[] = $image->id; } $arrImages[$image->id] = $image; foreach (['arrCategories' => ['name' => 'categories', 'id' => 'id'], 'arrCollections' => ['name' => 'collections', 'id' => 'id']] as $key => $value) { $arr = []; foreach ($image->{$value}['name'] as $v) { $arr[] = $v[$value['id']]; } $arrImages[$image->id][$key] = $arr; } unset($arr); } if (!empty($arrRemoveNew)) { Notification::whereIn('item_id', $arrRemoveNew)->where('item_type', 'Image')->where('admin_id', $admin_id)->update(['read' => 1]); } } if (Request::ajax()) { return $arrImages; } $this->layout->title = 'Images'; $this->layout->content = View::make('admin.images-all')->with(['images' => $arrImages, 'pageNum' => $pageNum, 'categories' => Category::getSource(), 'name' => $name, 'arrCategories' => $arrCategories, 'collections' => Collection::getSource(), 'apiKey' => Configure::getApiKeys()]); }
public function index() { $this->layout->title = 'Collection'; $this->layout->pageBar = false; $this->layout->content = View::make('admin.collections-all')->with(['collections' => Collection::getAll(), 'types' => Type::getSource(false), 'categories' => Category::getSource(false), 'maxHeight' => 500]); }