refactor: 附件
This commit is contained in:
@@ -22,4 +22,16 @@ class AttachmentCategoryModel extends AttachmentCategoryBaseModel
|
||||
{
|
||||
return $query->where('language_id', '=', $language);
|
||||
}
|
||||
|
||||
// 上级id范围查询
|
||||
public function scopeParent($query, $pid)
|
||||
{
|
||||
return $query->where('pid', '=', $pid);
|
||||
}
|
||||
|
||||
// 是否显示状态范围查询
|
||||
public function scopeIsShow($query, bool $is_show)
|
||||
{
|
||||
return $query->where('is_show', '=', (int)$is_show);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,24 @@ class AttachmentModel extends AttachmentBaseModel
|
||||
use SoftDelete;
|
||||
// 软删除时间字段名
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 设置JSON字段
|
||||
protected $json = ['attach'];
|
||||
// 设置JSON数据返回数组
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
$query->where('language_id', '=', $language);
|
||||
}
|
||||
|
||||
// 所属分类范围查询
|
||||
public function scopeCategory($query, $category)
|
||||
{
|
||||
if (is_null($category)) {
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $category);
|
||||
}
|
||||
}
|
||||
|
||||
14
app/index/model/VideoCategoryModel.php
Normal file
14
app/index/model/VideoCategoryModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoCategoryModel extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
14
app/index/model/VideoModel.php
Normal file
14
app/index/model/VideoModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoModel extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user