where([ ['del', '=', 0], ['is_show', '=', 1] ])->order('sort asc')->select()->toArray(); } catch (\Exception $e) { return ['error'=>$e->getMessage()]; } } // 获取列表 public static function lists($get) { try { $where = [ ['a.del', '=', 0], ['a.is_show', '=', 1], ['c.del', '=', 0], ['c.is_show', '=', 1], ]; if(isset($get['cid']) && !empty($get['cid'])) { $where[] = ['cid', '=', $get['cid']]; } $order = [ 'a.sort' => 'asc', 'a.id' => 'desc' ]; $model = new BusinessSchool(); $count = $model->alias('a')->join('business_school_category c', 'c.id = a.cid')->where($where)->count(); $list = $model->alias('a') ->join('business_school_category c', 'c.id = a.cid') ->field(['a.id', 'a.title', 'a.video', 'a.intro']) ->where($where) ->order($order) ->page($get['page_no'], $get['page_size']) ->select() ->toArray(); $more = is_more($count, $get['page_no'], $get['page_size']); $data = [ 'list' => $list, 'page_no' => $get['page_no'], 'page_size' => $get['page_size'], 'count' => $count, 'more' => $more ]; return $data; } catch (\Exception $e) { return ['error'=>$e->getMessage()]; } } // 获取详情 public static function detail($id) { $article = BusinessSchool::field('id, title, video, content, intro')->where([ 'id' => $id, 'del' => 0, 'is_show' => 1 ])->findOrEmpty(); if($article->isEmpty()) { $article = []; }else{ $article = $article->toArray(); $file = BusinessSchoolFile::where('bsid', $id)->select()->toArray(); foreach ($file as $k => &$v) { if ($v['type'] == 1) { $article['image'][] = $v['src']; } else if($v['type'] == 2) { $article['file'][$k]['src'] = $v['src']; $article['file'][$k]['name'] = basename($v['src']); } } } return $article; } }