123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\user\model;
- use think\Model;
- use think\Db;
- use think\Request;
- /**
- * 权限管理
- * @author Superbee
- *
- */
- class Rule extends Model{
-
- protected $updateTime = 'update_time'; // 每次更新时间
- protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
-
- public function initialize() {
- parent::initialize();
- }
-
- public function getInfo(){
- return $this->db()->getTreeData('tree', 'id', 'title');
- }
-
- /**
- * 根据id找到对象
- * @param int $id
- */
- public function getRuleById($id){
- return $this->db()->where(['id'=>$id])->find();
- }
-
- public function addAndSave(){
- $data = request()->post();
- return $this->allowField(true)->isUpdate($data['id']?true:false)->save($data);
- }
-
- public function remove(){
- $request = Request::instance();
-
- if($request->isPost()) $this->data = $request->post();
- if($request->isGet()) $this->data = $request->get();
-
- return $this->delete();
- }
-
- }
|