初始化
This commit is contained in:
78
addons/webman/model/Activity.php
Normal file
78
addons/webman/model/Activity.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace addons\webman\model;
|
||||
|
||||
use addons\webman\traits\DataPermissions;
|
||||
use addons\webman\traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class activity
|
||||
* @property int id 主键
|
||||
* @property int status 状态
|
||||
* @property int is_show 状态
|
||||
* @property int department_id 渠道id
|
||||
* @property int sort 排序
|
||||
* @property string link 链接
|
||||
* @property int recharge_id 充值配置id
|
||||
* @property string start_time 开始时间
|
||||
* @property string end_time 结束时间
|
||||
* @property int type 类型
|
||||
* @property int cycle_type 周期类型
|
||||
* @property string cycle_data 周期数据
|
||||
* @property string created_at 创建时间
|
||||
* @property string updated_at 最后一次修改时间
|
||||
* @property string deleted_at 删除时间
|
||||
*
|
||||
* @property Channel channel 渠道
|
||||
* @property ActivityContent activity_content 活动内容
|
||||
* @property ChannelRechargeSetting channelRechargeSetting 活动内容
|
||||
* @package addons\webman\model
|
||||
*/
|
||||
class Activity extends Model
|
||||
{
|
||||
use SoftDeletes, HasDateTimeFormatter, DataPermissions;
|
||||
|
||||
//数据权限字段
|
||||
protected $dataAuth = ['department_id' => 'department_id'];
|
||||
|
||||
const TYPE_CYCLE = 1; // 周期模式
|
||||
const TYPE_CUSTOM = 2; // 自定义模式
|
||||
|
||||
//数据权限字段
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
$this->setTable(plugin()->webman->config('database.activity_table'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道信息
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(plugin()->webman->config('database.channel_model'), 'department_id', 'department_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动内容
|
||||
* @return hasMany
|
||||
*/
|
||||
public function activity_content(): hasMany
|
||||
{
|
||||
return $this->hasMany(plugin()->webman->config('database.activity_content_model'), 'activity_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值配置
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function channelRechargeSetting(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(plugin()->webman->config('database.channel_recharge_setting_model'), 'recharge_id')->withTrashed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user