feat: index - 首页及顶部导航处理
This commit is contained in:
49
app/index/model/ProductModel.php
Normal file
49
app/index/model/ProductModel.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductBaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 产品模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductModel extends ProductBaseModel
|
||||
{
|
||||
// 启用软件删除
|
||||
use SoftDelete;
|
||||
// 软件删除时间字段
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
$query->where('language_id', '=', $language);
|
||||
}
|
||||
|
||||
// 启用状态范围查询
|
||||
public function scopeEnabled($query)
|
||||
{
|
||||
$query->where('status', '=', 1);
|
||||
}
|
||||
|
||||
// 在售状态范围查询
|
||||
public function scopeOnSale($query, bool $stat = true)
|
||||
{
|
||||
$query->where('is_sale', '=', (int)$stat);
|
||||
}
|
||||
|
||||
// 上架状态范围查询
|
||||
public function scopeOnShelves($query, bool $stat = true)
|
||||
{
|
||||
$query->where('is_show', '=', (int)$stat);
|
||||
}
|
||||
|
||||
// 热销状态范围查询
|
||||
public function scopeHot($query, bool $stat = true)
|
||||
{
|
||||
$query->where('is_hot', '=', (int)$stat);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user