Basedisplay.php
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\model\TemplateView;
use think\Db;
class Basedisplay extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = 'default';
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$template = TemplateView::getSchoolTemplate( $this->school_id);
$this->layout = $template->layout ?? 'default';
$this->template = $template->template_url;
}
public function index(){
$param = $this->request->param();
$base_list = null;
$achievements=null;
$base_render = null;
$achievements_render = null;
$where = [
'school_id' => $this->school_id,
'category_id' => $param['id']
];
$info = [];
if($param['type'] == 1){
$info = Db::name("base_display")->where($where)->paginate(5);
$render = $info->render();
}else{
$info = Db::name("achievements")->where($where)->paginate(5);
$render = $info->render();
}
if($param['type'] == 1) {
$tab = Db::name("basedisplay_category")->where("school_id", $this->school_id)->select();
}else{
$tab = Db::name("achievements_category")->where("school_id", $this->school_id)->select();
}
// dump(collection($info)->toArray());die;
$this->assign("type",$param['type']);
$this->assign("base_list",$base_list);
$this->assign("category_id",$param['id']);
// $this->assign("base_render",$base_render);
// $this->assign("achievements",$achievements);
$this->assign('info',$info);
$this->assign("tab",$tab ? $tab : []);
$this->assign("render",$render);
return $this->view->fetch();
}
public function detail(){
$param = $this->request->param();
$base_info = null;
$achievements=null;
if($param['type']==1){
$base_info = Db::name("base_display")->where("base_id",$param['id'])->find();
}else{
$achievements = Db::name("achievements")->where("achievements_id",$param['id'])->find();
}
if($param['type'] == 1) {
$tab = Db::name("basedisplay_category")->where("school_id", $this->school_id)->select();
}else{
$tab = Db::name("achievements_category")->where("school_id", $this->school_id)->select();
}
$id = $param['type'] == 1 ? $base_info['category_id'] : $achievements['category_id'];
$this->assign("type",$param['type']);
$this->assign("base_info",$base_info);
$this->assign("tab",$tab);
$this->assign("id",$id);
$this->assign("achievements",$achievements);
return $this->view->fetch();
}
}