private function delMobileHomepage($c_id) { $cus_id = Auth::id(); @MobileHomepage::where('cus_id', $cus_id)->where('c_id', $c_id)->delete(); }
public function homepageBatchModify() { $ids = Input::get('id'); $index_show = Input::get('show'); $show_num = Input::get('total'); $show_type = Input::get('showtype'); $star_only = Input::get('star_only'); $cus_id = Auth::id(); if (is_array($ids)) { $err = false; $data = array(); foreach ($ids as $id) { $m_i_config = MobileHomepage::where('c_id', '=', $id)->first(); if (!$m_i_config) { $m_i_config = new MobileHomepage(); $m_i_config->c_id = $ids; $m_i_config->cus_id = $cus_id; } if ($index_show != NULL) { $m_i_config->index_show = $index_show; } if ($show_num != NULL) { $m_i_config->show_num = $show_num; } if ($star_only != NULL) { $m_i_config->star_only = $star_only; } if ($show_type != NULL) { $m_i_config->m_index_showtype = $show_type; } $result = $m_i_config->save(); if ($result) { $data[] = $id; } else { $err = true; } } if ($err) { $return_msg = array('err' => 3001, 'msg' => '操作失败', 'data' => $data); } else { $return_msg = array('err' => 0, 'msg' => '操作成功'); } } else { $m_i_config = MobileHomepage::where('c_id', '=', $ids)->first(); if (!$m_i_config) { $m_i_config = new MobileHomepage(); $m_i_config->c_id = $ids; $m_i_config->cus_id = $cus_id; } if ($index_show != NULL) { $m_i_config->index_show = $index_show; } if ($show_num != NULL && is_numeric($show_num)) { $m_i_config->show_num = $show_num; } if ($show_type != NULL && is_numeric($show_type)) { $m_i_config->m_index_showtype = $show_type; } if ($star_only != NULL) { $m_i_config->star_only = $star_only; } $result = $m_i_config->save(); if ($result) { $return_msg = array('err' => 0, 'msg' => '操作成功'); } else { $return_msg = array('err' => 3001, 'msg' => '操作失败', 'data' => array()); } } return Response::json($return_msg); }
/** * 判断一个用户是否需要推送并返回修改的次数 */ public function isNeedPush() { $count = Classify::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += Articles::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += WebsiteConfig::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += WebsiteInfo::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += MobileHomepage::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += CustomerInfo::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $data_final = ['err' => 0, 'msg' => '', 'data' => ['cache_num' => $count]]; return Response::json($data_final); }