AdminLineController.php
3.4 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* 商旅服务
* Author : xiaojie
* DateTime: 2018/11/29 17:26
*/
namespace app\portal\controller;
use app\portal\model\LineModel;
use cmf\controller\AdminBaseController;
class AdminLineController extends AdminBaseController
{
//网上展厅显示
public function lines()
{
$lineModel = new LineModel();
$cate_list = $this->category();
if($this->request->isPost()){
$param = $this->request->param();
if($param['cate_id'] == 0){
$list = $lineModel
->paginate(30);
}else{
$list = $lineModel
->where($param)
->paginate(30);
}
$cate_id = $param['cate_id'];
}else{
$list = $lineModel
->paginate(30);
$cate_id = 0;
}
$this->assign('cate_id',$cate_id);
$this->assign('cate_list',$cate_list);
$this->assign('list',$list);
$this->assign('page',$list->render());
return $this->fetch();
}
//添加网上展厅
public function lines_add()
{
if($this->request->isPost()){
$lineModel = new LineModel();
$param = $this->request->param();
if($param['cate_id']==0){
$this->error('请选择分类');
}
if(empty($param['thumb'])){
$this->error('请上传缩略图');
}
// for ($i=0;$i<10;$i++){
$param['create_time'] = time();
$param['update_time'] = time();
$res = $lineModel::create($param);
//}
// $res = $showModel->save($param);
if($res){
$this->success('添加成功');
}
}else{
$cate_list = $this->category();
$this->assign('cate_list',$cate_list);
return $this->fetch();
}
}
//网上展厅分类
private function category(){
$cate_list = [
['id'=>1,'name'=>'第一天'],
['id'=>2,'name'=>'第二天'],
['id'=>3,'name'=>'第三天'],
['id'=>4,'name'=>'第四天'],
];
return $cate_list;
}
//编辑网上展厅
public function lines_detail()
{
$lineModel = new LineModel();
$id = $this->request->param('id','','intval');
if($this->request->isPost()){
$param = $this->request->param();
if($param['cate_id']==0){
$this->error('请选择分类');
}
if(empty($param['thumb'])){
$this->error('请上传缩略图');
}
$param['update_time'] = time();
$res = $lineModel::update($param);
if($res){
$this->success('更新成功');
}
}else{
$info = $lineModel->where('id',$id)->find();
$cate_list = $this->category();
$this->assign('cate_list',$cate_list);
$this->assign('info',$info);
return $this->fetch();
}
}
//删除网上展厅
public function delete(){
$lineModel = new LineModel();
$id = $this->request->param('id');
$res = $lineModel->where(['id'=>$id])->delete();
if($res){
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}
}