| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Module\Farm\Repositories;
- use App\Module\Farm\Models\FarmSeed;
- use Dcat\Admin\Repositories\EloquentRepository;
- use Illuminate\Database\Eloquent\Collection;
- /**
- * 种子配置仓库
- *
- * 提供种子配置数据的访问和操作功能。
- * 该类是种子配置模块与后台管理系统的桥梁,用于处理种子配置数据的CRUD操作。
- */
- class FarmSeedRepository extends EloquentRepository
- {
- /**
- * 模型类名
- *
- * @var string
- */
- protected $eloquentClass = FarmSeed::class;
- /**
- * 获取指定类型的种子
- *
- * @param int $type
- * @return Collection
- */
- public function findByType(int $type): Collection
- {
- return FarmSeed::where('type', $type)->get();
- }
- /**
- * 根据物品ID查找种子
- *
- * @param int $itemId
- * @return FarmSeed|null
- */
- public function findByItemId(int $itemId): ?FarmSeed
- {
- return FarmSeed::where('item_id', $itemId)->first();
- }
- /**
- * 获取所有普通种子
- *
- * @return Collection
- */
- public function findNormalSeeds(): Collection
- {
- return FarmSeed::where('type', 1)->get();
- }
- /**
- * 获取所有神秘种子
- *
- * @return Collection
- */
- public function findMysteriousSeeds(): Collection
- {
- return FarmSeed::where('type', 2)->get();
- }
- /**
- * 获取所有巨化种子
- *
- * @return Collection
- */
- public function findGiantSeeds(): Collection
- {
- return FarmSeed::where('type', 3)->get();
- }
- }
|