| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Http\Controllers\api;
- use App\Models\GameplayRule;
- use Illuminate\Validation\ValidationException;
- use Exception;
- class Game extends BaseController
- {
- /**
- * @api {get} /game/rule 玩法规则
- */
- function rule()
- {
- try {
- request()->validate([
- 'page' => ['nullable', 'integer', 'min:1'],
- 'limit' => ['nullable', 'integer', 'min:1']
- ]);
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 10);
- $list = GameplayRule::forPage($page, $limit)
- ->orderBy('groups')
- ->orderByDesc('created_at')
- ->get();
-
- } catch (ValidationException $e) {
- return $this->error($e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getMessage());
- }
- return $this->success($list);
- }
- }
|