| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Module\Game\Repositories;
- use App\Module\Game\Models\GameConsumeGroup;
- use Dcat\Admin\Repositories\EloquentRepository;
- /**
- * 消耗组仓库
- *
- * 提供消耗组数据的访问和操作功能。
- * 该类是消耗组模块与后台管理系统的桥梁,用于处理消耗组数据的CRUD操作。
- */
- class GameConsumeGroupRepository extends EloquentRepository
- {
- /**
- * 模型类名
- *
- * @var string
- */
- protected $eloquentClass = GameConsumeGroup::class;
- /**
- * 根据编码获取消耗组
- *
- * @param string $code
- * @return GameConsumeGroup|null
- */
- public function findByCode(string $code): ?GameConsumeGroup
- {
- return GameConsumeGroup::where('code', $code)->first();
- }
- /**
- * 获取所有消耗组的编码和名称
- *
- * @return array
- */
- public function getCodesAndNames(): array
- {
- return GameConsumeGroup::pluck('name', 'code')->toArray();
- }
- }
|