public function copyImageLightBox() { if (Request::ajax()) { if (Auth::user()->check()) { $id = Input::has('id') ? Input::get('id') : 0; $check = Lightbox::where('id', '=', $id)->where('user_id', '=', Auth::user()->get()->id)->count(); if ($check) { $list_image = Input::has('list_image') ? Input::get('list_image') : array(); foreach ($list_image as $key => $image) { $check = LightboxImages::where('image_id', '=', $image)->where('lightbox_id', '=', $id)->count(); if ($check == 0) { $lightbox_image = new LightboxImages(); $lightbox_image->lightbox_id = $id; $lightbox_image->image_id = $image; $lightbox_image->save(); } } $arrReturn = array('result' => 'success'); } else { $arrReturn = array('result' => 'failed', 'message' => 'You do not have permission to edit this lightbox.'); } } else { $arrReturn = array('result' => 'failed', 'message' => 'Please login first.'); } $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; } return Redirect::route('home'); }