| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace App\Module\Game\Models;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use UCore\ModelCore;
- /**
- * 条件组
- *
- * field start
- * @property int $id 主键
- * @property string $name 条件组名称
- * @property string $code 条件组编码(唯一)
- * @property string $description 条件组描述
- * @property int $logic_type 逻辑类型(1:全部满足, 2:任一满足)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class GameConditionGroup extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'game_condition_groups';
- // attrlist start
- protected $fillable = [
- 'id',
- 'name',
- 'code',
- 'description',
- 'logic_type',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'logic_type' => 'integer',
- ];
- /**
- * 逻辑类型:全部满足
- */
- const LOGIC_TYPE_ALL = 1;
- /**
- * 逻辑类型:任一满足
- */
- const LOGIC_TYPE_ANY = 2;
- /**
- * 获取逻辑类型列表
- *
- * @return array
- */
- public static function getLogicTypes(): array
- {
- return [
- self::LOGIC_TYPE_ALL => '全部满足',
- self::LOGIC_TYPE_ANY => '任一满足',
- ];
- }
- /**
- * 获取条件组中的所有条件项
- *
- * @return HasMany
- */
- public function conditionItems(): HasMany
- {
- return $this->hasMany(GameConditionItem::class, 'group_id', 'id');
- }
- }
|