Esempio n. 1
0
 /**
  * 检查专题栏目引用
  * @param $appId
  * @param $local
  * @throws DeepInException
  */
 protected function checkAppsListReferred($appId, $local)
 {
     $appListItem = ShopAppsList::whereRaw("appid=:appid", array(":appid" => $appId))->get();
     $data = array();
     foreach ($appListItem as $v) {
         if ($v instanceof ShopAppsList) {
             if (isset($data[$v->listType()])) {
                 $data[$v->listType()] = array();
             }
             $data[$v->listType()][] = $v->itemId();
         }
     }
     $locals = array();
     if (isset($data[1])) {
         //栏目
         $colnumList = ShopColumn::whereRaw("columnid in (:columnid)", array(":columnid" => implode(",", $data[1])))->get();
         foreach ($colnumList as $v) {
             if ($v instanceof ShopColumn) {
                 $locals[] = $v->local();
             }
         }
     }
     if (in_array($local, $locals)) {
         throw new DeepInException("无法取消,在栏目里面引用到该应用了。");
     }
     if (isset($data[2])) {
         //专题
         $topicList = ShopTopic::whereRaw("topicid=:topicid", array(":topicid" => implode(",", $data[2])))->get();
         foreach ($topicList as $v) {
             if ($v instanceof ShopTopic) {
                 $locals[] = $v->local();
             }
         }
     }
     if (in_array($local, $locals)) {
         throw new DeepInException("无法取消,在专题里面引用到该应用了。");
     }
 }
 /**
  * 删除栏目
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  * @throws DeepInException
  * @throws \Exception
  */
 public function delete($id)
 {
     try {
         $column = $this->find($id);
     } catch (DeepInException $e) {
         throw new DeepInHtmlException($e->getMessage());
     }
     if ($column->inuse() == 1) {
         throw new DeepInHtmlException("栏目属于上线状态,无法删除~!");
     }
     //删除其选择的应用列表
     ShopAppsList::whereRaw("listtype=1 and itemid=:itemid", array(":itemid" => $column->columnId()))->delete();
     if ($column->delete() == false) {
         throw new DeepInHtmlException("数据删除失败~!");
     }
     return $this->success("删除成功~!");
 }
 /**
  * 按照listType和itemId获取响应的应用列表
  * @param $type
  * @param $itemId
  * @return array
  */
 protected function findByTypeAndItem($type, $itemId)
 {
     $list = ShopAppsList::whereRaw("`listtype`=:listtype and `itemid`=:itemid", array(":listtype" => $type, ":itemid" => $itemId))->orderBy("pos", "asc")->get();
     return $list;
 }
 /**
  * 删除数据
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  * @throws DeepInException
  * @throws \Exception
  */
 public function delete($id)
 {
     try {
         $topic = $this->find($id);
     } catch (DeepInException $e) {
         throw new DeepInHtmlException($e->getMessage());
     }
     if ($topic->inuse() == 1) {
         throw new DeepInHtmlException("专题属于上线状态,无法删除~!");
     }
     //删除其选择的应用列表
     ShopAppsList::whereRaw("listtype=2 and itemid=:itemid", array(":itemid" => $topic->topicId()))->delete();
     //删除对应的背景图片数据
     ShopTopicBanner::whereRaw("topicid=:topicid", array(":topicid" => $topic->topicId()))->delete();
     if ($topic->delete() == false) {
         throw new DeepInHtmlException("删除失败~!");
     }
     return $this->success("删除成功~!");
 }