diff --git a/application/admin/controller/BroadController.php b/application/admin/controller/BroadController.php new file mode 100644 index 0000000..b8ef041 --- /dev/null +++ b/application/admin/controller/BroadController.php @@ -0,0 +1,80 @@ +param(); + $model = $model + ->field('id,context,status,starttime,endtime') + ->order('starttime'); + $data = $model->paginate($this->admin['per_page'], false, ['query' => $request->get()])->each(function ($item){ + $item['starttime'] = date("Y-m-d H:i:s",intval($item['starttime'])); + $item['endtime'] = date("Y-m-d H:i:s",intval($item['endtime'])); + return $item; + }); +// dump($data); + $this->assign($request->get()); + $this->assign([ + 'data' => $data->toArray()['data'], + 'page' => $data->render(), + 'total' => $data->total(), + ]); + return $this->fetch(); + } + + + public function add(Request $request, Broad $model) + { + if ($request->isPost()) { + $param = $request->param(); + + $inset[] = [ + 'context' => $param['context'], + 'status' => 1, + 'starttime' => strtotime($param['starttime']), + 'endtime' => strtotime($param['endtime']), + ]; + $result = $model->saveAll($inset); + $result ? admin_success(lang('success'), URL_BACK) : admin_error(); + + } + + return $this->fetch(); + } + + //删除 + public function del($id, Broad $model) + { + if (count($model->noDeletionId) > 0) { + if (is_array($id)) { + if (array_intersect($model->noDeletionId, $id)) { + return admin_error('ID为' . implode(',', $model->noDeletionId) . '的数据无法删除'); + } + } else if (in_array($id, $model->noDeletionId)) { + return admin_error('ID为' . $id . '的数据无法删除'); + } + } + + $result = $model->whereIn('id', $id)->delete(); + + return $result ? admin_success(lang('delete_success'), URL_RELOAD) : admin_error(lang('delete_error')); + } + + + +} \ No newline at end of file diff --git a/application/admin/view/broad/add.html b/application/admin/view/broad/add.html new file mode 100644 index 0000000..4972c28 --- /dev/null +++ b/application/admin/view/broad/add.html @@ -0,0 +1,92 @@ +{extend name="public/base" /} +{block name='content'} +{include file='public/content_header' /} +
+
+
+
+ + +
+
+ + +
+ +
+ +
+
+ + + + +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ + + + +
+
+
+
+
+ + +{/block} + diff --git a/application/admin/view/broad/index.html b/application/admin/view/broad/index.html new file mode 100644 index 0000000..d9f869e --- /dev/null +++ b/application/admin/view/broad/index.html @@ -0,0 +1,87 @@ +{extend name="public/base" /} +{block name='content'} +{include file='public/content_header' /} + +
+ + + +
+
+
+ + + + + +
+ + + + + + + + + + + + + {foreach name='data' id='item' key='data_key'} + + + + + + + + + {/foreach} + +
ID内容状态开始时间结束时间操作
{$item.id}{$item.context}{$item.status}{$item.starttime}{$item.endtime} + + + + + +
+
+ + + + +
+
+
+
+ +{/block} + diff --git a/application/common/model/Broad.php b/application/common/model/Broad.php new file mode 100644 index 0000000..d58979b --- /dev/null +++ b/application/common/model/Broad.php @@ -0,0 +1,18 @@ +[ //后台名称 - 'name'=>'XX后台系统', + 'name'=>'游戏后台系统', //后台简称 'short_name'=>'后台', //后台作者