public function showLightboxs($flag = false) { if (Auth::user()->check()) { $query = Lightbox::where('user_id', '=', Auth::user()->get()->id); $query->orderBy('id', 'desc'); $data = $query->get(); $arrlightbox = array(); if ($data->count() > 0) { $i = 0; foreach ($data as $key => $value) { $arrlightbox[$i]['id'] = $value->id; $arrlightbox[$i]['name'] = $value->name; $imgdetail = LightboxImages::select('lightbox_images.lightbox_id', 'images.short_name', 'lightbox_images.image_id', 'image_details.width', 'image_details.height'); $imgdetail->leftJoin('images', 'images.id', '=', 'lightbox_images.image_id'); $imgdetail->leftJoin('image_details', 'lightbox_images.image_id', '=', 'image_details.image_id'); $imgdetail->where('lightbox_images.lightbox_id', '=', $value->id); $imgdetail->where('image_details.type', '=', 'main'); $imageDetail = $imgdetail->first(); if (is_object($imageDetail)) { $arrlightbox[$i]['path'] = '/pic/thumb/' . $imageDetail->short_name . '-' . $imageDetail->image_id . '.jpg'; $arrlightbox[$i]['width'] = $imageDetail->width; $arrlightbox[$i]['height'] = $imageDetail->height; } $i++; } } if (Request::ajax()) { $referrer = Request::server('HTTP_REFERER'); // if(substr($referrer, -13, 13) != "lightbox/show") // { // if(count($arrlightbox) > 5) // { // $arrlightbox = array_slice($arrlightbox, 0, 5); // } // } $html = View::make('frontend.lightbox.list-lightboxs')->with('arrlightbox', $arrlightbox)->render(); if ($flag) { return $html; } $arrReturn = ['status' => 'ok', 'message' => !empty($arrlightbox), 'html' => $html]; $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; } $this->layout->content = View::make('frontend.lightbox.show-lightboxs')->with('arrlightbox', $arrlightbox); return; } return Redirect::route('account-sign-in'); //return App::abort(404); }