53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model;
|
|
|
|
/**
|
|
* 设置模型
|
|
*/
|
|
class Category extends \think\Model{
|
|
|
|
protected $name = "Category";
|
|
protected $auto = array('update_time', 'status' => 1);
|
|
|
|
protected $type = array(
|
|
'icon' => 'integer',
|
|
);
|
|
|
|
public static function getCategoryTree($map = []){
|
|
$list = self::where($map)->select();
|
|
|
|
if (!empty($list)) {
|
|
$tree = new \sent\tree\Tree();
|
|
$list = $tree->toFormatTree($list->toArray());
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
public function change() {
|
|
$data = input('post.');
|
|
if ($data['id']) {
|
|
$result = $this->save($data, array('id' => $data['id']));
|
|
} else {
|
|
unset($data['id']);
|
|
$result = $this->save($data);
|
|
}
|
|
if (false !== $result) {
|
|
return true;
|
|
} else {
|
|
$this->error = "失败!";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function info($id, $field = true) {
|
|
return $this->db()->where(array('id' => $id))->field($field)->find();
|
|
}
|
|
} |