| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?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 $from_type_id 起始土地类型ID
- * @property int $to_type_id 目标土地类型ID
- * @property object|array $materials 升级所需材料
- * @property object|array $conditions 其他升级条件
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- 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');
- }
- }
|