| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Module\Farm\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 团队收益记录模型
- * field start
- * @property int $id 主键ID
- * @property int $user_id 获得收益的用户ID
- * @property int $team_member_id 团队成员ID
- * @property int $harvest_id 收获记录ID
- * @property int $profit_amount 分成收益数量
- * @property float $profit_rate 分成比例
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class FarmTeamProfit extends Model
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_team_profits';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'user_id',
- 'team_member_id',
- 'harvest_id',
- 'profit_amount',
- 'profit_rate',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'profit_rate' => 'float',
- ];
- /**
- * 表明模型是否应该被打上时间戳
- *
- * @var bool
- */
- public $timestamps = false;
- /**
- * 获取关联的收获记录
- *
- * @return BelongsTo
- */
- public function harvestLog(): BelongsTo
- {
- return $this->belongsTo(FarmHarvestLog::class, 'harvest_id', 'id');
- }
- }
|