AdminForumController.php
3.5 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* 论坛报名
* Author : xiaojie
* DateTime: 2018/12/03 10:13
*/
namespace app\portal\controller;
use app\portal\model\ForumModel;
use cmf\controller\AdminBaseController;
/**
* Class AdminForumController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'论坛报名',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'论坛报名'
* )
*/
class AdminForumController extends AdminBaseController
{
/**
* 论坛报名
* @adminMenu(
* 'name' => '论坛报名',
* 'parent' => 'portal/AdminForum/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '论坛报名',
* 'param' => ''
* )
*/
public function index()
{
$forumModel = new ForumModel();
$param = $this->request->param();
$map = $this->search($param,'create_time','name|mobile|company');
$list = $forumModel
->where($map)
->order('id DESC')
->paginate(30);
$this->assign('list',$list);
$this->assign('page',$list->render());
return $this->fetch();
}
/**
* 编辑论坛报名
* @adminMenu(
* 'name' => '编辑论坛报名',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑论坛报名',
* 'param' => ''
* )
*/
public function edit()
{
$forumModel = new ForumModel();
$id = $this->request->param('id','','intval');
$info = $forumModel->where('id',$id)->find();
$this->assign('info',$info);
return $this->fetch();
}
/**
* 编辑论坛报名提交
* @adminMenu(
* 'name' => '编辑论坛报名提交',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑论坛报名提交',
* 'param' => ''
* )
*/
public function editPost()
{
$forumModel = new ForumModel();
$param = $this->request->param();
$res = $forumModel->isUpdate(true)->save($param);
if($res){
$this->success('保存成功');
}
$this->error('请稍后重试');
}
/**
* 删除
* @adminMenu(
* 'name' => '删除',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除',
* 'param' => ''
* )
*/
public function delete()
{
$forumModel = new ForumModel();
$res = $this->del($forumModel);
if($res){
$this->success('删除成功');
}
$this->error('请稍后重试');
}
/**
* 参展登记导出
*/
public function export()
{
$forumModel = new ForumModel();
$data = $forumModel
->field('name,mobile,email,company,post,create_time')
->select()->each(function ($item){
$item['create_time'] = date('Y-m-d',$item['create_time']);
})->toArray();
$this->exportExcel(array('联系人','手机号','邮箱','企业名称','职务','申请时间'), $data, '论坛报名', './', true);
}
}