调整活动
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToUser;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Activity extends Model
|
||||
@@ -36,6 +39,13 @@ class Activity extends Model
|
||||
self::CHANNEL_UNION => '银联',
|
||||
];
|
||||
|
||||
const VERIFY_SHOP_YES = 1;
|
||||
const VERIFY_SHOP_NO = 0;
|
||||
const VERIFY_SHOPS = [
|
||||
self::VERIFY_SHOP_YES => '是',
|
||||
self::VERIFY_SHOP_NO => '否',
|
||||
];
|
||||
|
||||
/**
|
||||
* 默认加载的关联
|
||||
* @var array
|
||||
@@ -52,7 +62,7 @@ class Activity extends Model
|
||||
}
|
||||
|
||||
//活动类型 固定期限 延期
|
||||
public function getTypeTextAttribute()
|
||||
public function getTypeTextAttribute(): string
|
||||
{
|
||||
return self::TYPES[$this->type] ?? '未知';
|
||||
}
|
||||
@@ -64,26 +74,46 @@ class Activity extends Model
|
||||
}
|
||||
|
||||
//关联卡券规则 ysd-full100-10
|
||||
public function rule()
|
||||
public function rule(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ActivityRule::class, 'activity_rule_id');
|
||||
}
|
||||
|
||||
//关联券表
|
||||
public function coupons()
|
||||
public function coupons(): HasMany
|
||||
{
|
||||
return $this->hasMany(ActivityCoupon::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 关联可发券渠道
|
||||
* Notes: 关联可发券渠道中间表
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
public function grants()
|
||||
public function grants(): HasMany
|
||||
{
|
||||
return $this->hasMany(ActivityGrant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 可发券的渠道
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:36
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function grant_users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'activity_grants')->using(ActivityGrant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 关联可核券网点中间表
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
public function shops(): HasMany
|
||||
{
|
||||
return $this->hasMany(ActivityShop::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,10 +121,19 @@ class Activity extends Model
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
public function verifications()
|
||||
public function verifications(): HasMany
|
||||
{
|
||||
return $this->hasMany(ActivityVerification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 可核销的渠道
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:37
|
||||
*/
|
||||
public function verify_users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'activity_verifications')->using(ActivityVerification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user