1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\api\model;
- use think\Model;
- class ProductShangpin extends Model
- {
-
-
- // 表名
- protected $name = 'product_shangpin';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- ];
- public function shopuser()
- {
- return $this->belongsTo('app\admin\model\ShopUser','suser_id','id')->field('id,shopname,phone,phone_axn,axn_id');
- }
- public function storeseckill()
- {
- return $this->hasOne('StoreSeckill','store_id','id');
- }
- public function attribute()
- {
- return $this->hasMany('app\admin\model\store\StoreProductAttribute','pro_id','id')->order('id asc');
- }
- public function getImageAttr($value)
- {
- if (empty($value)){
- return '';
- }
- // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
- return config('site.siteUrl').$value;
- }
- public function getMp4Attr($value)
- {
- if (empty($value)){
- return '';
- }
- // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
- return config('site.siteUrl').$value;
- }
- public function getSliderImageAttr($value)
- {
- $images=explode(',',$value);
- foreach ($images as $k=>$v){
- if (!empty($v)){
- $images[$k]=config('site.siteUrl').$v;
- }else{
- $images[$k]='';
- }
- }
- // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
- return $images;
- }
- }
|