61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?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([], '删除成功');
|
|
}
|
|
}
|