| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Module\Farm\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 土地升级配置模型
- *
- * @property int $id 主键ID
- * @property int $from_type_id 起始土地类型ID
- * @property int $to_type_id 目标土地类型ID
- * @property array $materials 升级所需材料
- * @property array|null $conditions 其他升级条件
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- */
- class FarmLandUpgradeConfig extends Model
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_land_upgrade_configs';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'from_type_id',
- 'to_type_id',
- 'materials',
- 'conditions',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'materials' => 'json',
- 'conditions' => 'json',
- ];
- /**
- * 获取起始土地类型
- *
- * @return BelongsTo
- */
- public function fromType(): BelongsTo
- {
- return $this->belongsTo(FarmLandType::class, 'from_type_id', 'id');
- }
- /**
- * 获取目标土地类型
- *
- * @return BelongsTo
- */
- public function toType(): BelongsTo
- {
- return $this->belongsTo(FarmLandType::class, 'to_type_id', 'id');
- }
- }
|