TaoLer/app/common/model/Cate.php

45 lines
890 B
PHP
Raw Normal View History

2020-01-01 13:17:19 +08:00
<?php
2022-08-16 15:21:08 +08:00
/*
* @Author: TaoLer <317927823@qq.com>
* @Date: 2021-12-06 16:04:50
2022-08-16 15:29:04 +08:00
* @LastEditTime: 2022-08-14 07:33:14
2022-08-16 15:21:08 +08:00
* @LastEditors: TaoLer
2022-08-16 15:29:04 +08:00
* @Description: 分类模型
2022-08-16 15:21:08 +08:00
* @FilePath: \github\TaoLer\app\common\model\Cate.php
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
*/
2020-01-01 13:17:19 +08:00
namespace app\common\model;
use think\Model;
use think\model\concern\SoftDelete;
class Cate extends Model
{
//软删除
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
2022-08-16 15:21:08 +08:00
// 查询类别信息
public function getCateInfo(string $ename)
{
//
return $this::field('ename,catename,detpl,desc')->where('ename',$ename)->cache('cate_'.$ename,600)->find();
}
// 删除类别
2021-08-03 17:33:48 +08:00
public function del($id)
2020-01-01 13:17:19 +08:00
{
2021-08-03 17:33:48 +08:00
$cates = $this->find($id);
2020-01-01 13:17:19 +08:00
$res = $cates->delete();
if($res){
return 1;
}else{
2021-08-03 17:33:48 +08:00
return '删除分类失败';
2020-01-01 13:17:19 +08:00
}
}
}