mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-05-22 06:49:15 +08:00
修改数据
This commit is contained in:
parent
b5da654cd4
commit
fa46967111
@ -24,7 +24,7 @@ class Goods extends Controller
|
|||||||
*/
|
*/
|
||||||
public function getCate()
|
public function getCate()
|
||||||
{
|
{
|
||||||
$this->success('获取分类成功', ShopGoodsCate::treeJson());
|
$this->success('获取分类成功', ShopGoodsCate::treeData());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,9 +41,9 @@ class ShopGoodsCate extends Model
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function treeJson(): array
|
public static function treeData(): array
|
||||||
{
|
{
|
||||||
$query = static::mk()->where(['deleted' => 0, 'status' => 1])->order('sort desc,id desc');
|
$query = static::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc');
|
||||||
return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
|
return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class ShopGoodsCate extends Model
|
|||||||
*/
|
*/
|
||||||
public static function treeTable(bool $simple = false): array
|
public static function treeTable(bool $simple = false): array
|
||||||
{
|
{
|
||||||
$query = static::mk()->where(['status' => 1])->order('sort desc,id asc');
|
$query = static::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id asc');
|
||||||
$cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');
|
$cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');
|
||||||
foreach ($cates as $cate) isset($cates[$cate['pid']]) && $cates[$cate['id']]['parent'] =& $cates[$cate['pid']];
|
foreach ($cates as $cate) isset($cates[$cate['pid']]) && $cates[$cate['id']]['parent'] =& $cates[$cate['pid']];
|
||||||
foreach ($cates as $key => $cate) {
|
foreach ($cates as $key => $cate) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user