'department_id']; /** * 时间转换 * @param DateTimeInterface $date * @return string */ protected function serializeDate(DateTimeInterface $date): string { return $date->format('Y-m-d H:i:s'); } public function __construct(array $attributes = []) { parent::__construct($attributes); $this->setTable(plugin()->webman->config('database.player_promoter_table')); } /** * 渠道信息 * @return BelongsTo */ public function channel(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.channel_model'), 'department_id', 'department_id')->withTrashed(); } /** * 玩家信息 * @return BelongsTo */ public function player(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.player_model'), 'player_id')->withTrashed(); } /** * 上级推广员 * @return hasOne */ public function parent_promoter(): hasOne { return $this->hasOne(plugin()->webman->config('database.player_promoter_model'), 'player_id', 'recommend_id'); } /** * 下级推广员 ** @return hasMany */ public function sub_promoter() { return $this->hasMany(plugin()->webman->config('database.player_promoter_model'), 'recommend_id', 'player_id'); } /** * 下级推广员 ** @return hasMany */ public function max_sub_promoter() { return $this->hasOne(plugin()->webman->config('database.player_promoter_model'), 'recommend_id', 'player_id') ->orderBy('ratio','desc'); } }