| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * 商家店铺管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
- class StoreModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'user';
- // 封面图
- public function getAvatarAttribute($value)
- {
- $value = $value ? get_image_url($value) : '';
- return $value;
- }
- public function setAvatarAttribute($value)
- {
- return $value ? get_image_path($value) : '';
- }
- // 营业执照
- public function getBusinessLicenseAttribute($value)
- {
- $value = $value ? get_image_url($value) : '';
- return $value;
- }
- public function member()
- {
- return $this->hasOne(MemberModel::class, 'id', 'user_id')
- ->select(['id', 'realname', 'nickname', 'mobile','parents', 'status']);
- }
- /**
- * 商家商品
- */
- public function goods()
- {
- return $this->hasMany(GoodsModel::class, 'store_id', 'id')
- ->with(['category'])
- ->where(['status'=>1,'mark'=>1])
- ->select(['id','goods_name','category_id','store_id','price','thumb','sales','sku_type','unit','status'])
- ->orderBy('sort','desc')
- ->orderBy('id','desc');
- }
- public function getInfoByUserId($userId)
- {
- return $this->where(['user_id' => $userId, 'mark' => 1])->first();
- }
- }
|