| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\common\model;
- use think\Cache;
- /**
- * Class Certificate
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 13:37
- * @package app\common\model
- */
- class Certificate extends BaseModel
- {
- protected $name = 'certificate';
- /**
- * 文章详情
- * @param $id
- * @return null|static
- * @throws \think\exception\DbException
- */
- public static function detail($id)
- {
- return self::get($id, ['file', 'category']);
- }
- /**
- * 软删除
- *
- * @return false|int
- */
- public function setDelete()
- {
- return $this->save(['is_delete' => 1]);
- }
- /**
- * [category]
- * 关联分类
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:38
- * @return \think\model\relation\BelongsTo
- */
- public function category()
- {
- return $this->belongsTo(CertificateCategory::class, 'certificate_category_id', 'id');
- }
- /**
- * [file]
- * 关联文件
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:48
- * @return \think\model\relation\BelongsTo
- */
- public function file()
- {
- return $this->belongsTo('UploadFile', 'file_id', 'file_id')
- ->bind(['file_path', 'file_name', 'file_url']);
- }
- /**
- * [getCertificateList]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/27 10:43
- * @param array $where
- * @param string $field
- * @return bool|\PDOStatement|string|\think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getCertificateList($where = [], $field = '*')
- {
- $model = new static;
- !empty($where) && $model->where($where);
- return $model->field($field)->where('is_delete', '=', 0)->select();
- }
- }
|