| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class AgentUserReward extends Model
- {
- /**
- * 数据库连接名
- */
- protected $connection = 'mysql';
- /**
- * 与模型关联的表名
- */
- protected $table = 'webgame.agent_user_rewards';
- /**
- * 可批量赋值的属性
- */
- protected $fillable = [
- 'UserID',
- 'reward_type',
- 'source_id',
- 'taskid',
- 'amount',
- 'remark',
- 'status'
- ];
- /**
- * 获取用户
- */
- public function user()
- {
- // return $this->belongsTo(User::class, 'UserID', 'id');
- }
- /**
- * 获取任务(如果是任务奖励)
- */
- public function task()
- {
- if ($this->reward_type == 1 && $this->taskid) {
- return $this->belongsTo(AgentTask::class, 'taskid', 'taskid');
- }
- return null;
- }
- /**
- * 获取佣金记录(如果是佣金奖励)
- */
- public function commission()
- {
- if ($this->reward_type == 2 && $this->source_id) {
- return $this->belongsTo(AgentDepositCommission::class, 'source_id', 'id');
- }
- return null;
- }
- }
|