123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- // +----------------------------------------------------------------------
- // | Niucloud-admin 企业快速开发的多应用管理平台
- // +----------------------------------------------------------------------
- // | 官方网址:https://www.niucloud.com
- // +----------------------------------------------------------------------
- // | niucloud团队 版权所有 开源版本可自由商用
- // +----------------------------------------------------------------------
- // | Author: Niucloud Team
- // +----------------------------------------------------------------------
- namespace app\model\shop;
- use core\base\BaseModel;
- use think\model\relation\HasOne;
- /**
- * 店铺扩展模型
- * Class Shop
- * @package addon\mall\app\model\shop
- */
- class Shop extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'site_shop';
- /**
- * 分类名称
- * @return HasOne
- */
- public function categoryName()
- {
- return $this->hasOne(ShopCategory::class, 'category_id', 'category_id')->joinType('left')->withField('category_id, category_name')->bind(['category_name' => 'category_name']);
- }
- /**
- * 是否自营
- * @param $query
- * @param $value
- * @param $data
- */
- public function searchIsSelfAttr($query, $value, $data)
- {
- if ($value) {
- $query->where('is_self', '=', $value);
- }
- }
- /**
- * 店铺分类
- * @param $query
- * @param $value
- * @param $data
- */
- public function searchCategoryIdAttr($query, $value, $data)
- {
- if ($value) {
- $query->where('category_id', '=', $value);
- }
- }
- }
|