123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\common\model\user;
- use think\Model;
- use app\common\Enum\ShareEnum;
- use app\common\model\User as UserModel;
- use app\common\model\Goods as GoodsModel;
- class Share extends Model
- {
- // 表名
- protected $name = 'shop_user_share';
-
- protected $type = [
- 'ext' => 'json'
- ];
-
- protected $append = [
- 'platform_text',
- 'from_text'
- ];
- public function getPlatformTextAttr($value, $data)
- {
- $value = $value ?: ($data['platform'] ?? null);
- return ShareEnum::getPlatformText($value);
- }
- public function getFromTextAttr($value, $data)
- {
- $value = $value ?: ($data['from'] ?? null);
- return ShareEnum::getFromText($value);
- }
-
- // -- commission code start --
- public function agent()
- {
- return $this->belongsTo(\app\common\model\commission\Agent::class, 'share_id', 'user_id');
- }
- // -- commission code end --
- public function user()
- {
- return $this->belongsTo(UserModel::class, 'user_id', 'id');
- }
-
-
- }
|