61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\common\model\community;
|
|
|
|
use app\common\model\BaseModel;
|
|
|
|
class CommunityCategory extends BaseModel
|
|
{
|
|
|
|
/**
|
|
* TODO
|
|
* @return string
|
|
* @author Qinii
|
|
* @day 10/26/21
|
|
*/
|
|
public static function tablePk(): string
|
|
{
|
|
return 'category_id';
|
|
}
|
|
|
|
/**
|
|
* TODO
|
|
* @return string
|
|
* @author Qinii
|
|
* @day 10/26/21
|
|
*/
|
|
public static function tableName(): string
|
|
{
|
|
return 'community_category';
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(CommunityTopic::class,'category_id','category_id')
|
|
->where('status',1)
|
|
->where('is_del',0)
|
|
->field('category_id,topic_id,topic_name,pic,sort,count_use')
|
|
->order('sort DESC,create_time DESC');
|
|
}
|
|
|
|
|
|
public function searchCateNameAttr($query, $value)
|
|
{
|
|
$query->whereLike('cate_name', "%{$value}%");
|
|
}
|
|
|
|
public function searchCategoryIdAttr($query, $value)
|
|
{
|
|
$query->where('category_id', $value);
|
|
}
|
|
|
|
public function searchIsShowAttr($query, $value)
|
|
{
|
|
$query->where('is_show', $value);
|
|
}
|
|
|
|
}
|