chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace addon\forum\controller\backend;
|
||||
|
||||
use addon\forum\model\ForumBoard;
|
||||
use ywxapp\controller\BackendBase;
|
||||
|
||||
class Board extends BackendBase
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedVerify = ['*'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
$list = ForumBoard::order('sort asc,id asc')->select();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch('board/index');
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
return $this->fetch('board/add');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = time();
|
||||
ForumBoard::insert($data);
|
||||
return $this->success([], '保存成功');
|
||||
}
|
||||
|
||||
public function edit($id = 0)
|
||||
{
|
||||
$row = ForumBoard::find($id);
|
||||
$this->assign('row', $row);
|
||||
return $this->fetch('board/edit');
|
||||
}
|
||||
|
||||
public function update($id = 0)
|
||||
{
|
||||
$row = ForumBoard::find($id);
|
||||
if (!$row) {
|
||||
return $this->error('记录不存在');
|
||||
}
|
||||
$row->save($this->request->post());
|
||||
return $this->success([], '更新成功');
|
||||
}
|
||||
|
||||
public function delete($id = 0)
|
||||
{
|
||||
ForumBoard::where('id', $id)->delete();
|
||||
return $this->success([], '删除成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user