コード例 #1
0
 public function deleteImageLightBox()
 {
     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();
                 $delete = LightboxImages::whereIn('image_id', $list_image)->where('lightbox_id', '=', $id)->delete();
                 $arrReturn = array('result' => 'success', 'message' => $delete);
             } 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');
 }