PcIssue.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Http\Controllers\admin;
  3. use App\Constants\HttpStatus;
  4. use App\Http\Controllers\Controller;
  5. use App\Services\PcIssueService;
  6. use Illuminate\Validation\ValidationException;
  7. use Exception;
  8. use App\Models\PcIssue as PcIssueModel;
  9. class PcIssue extends Controller
  10. {
  11. /**
  12. * @api {get} /admin/pcIssue 极速28
  13. * @apiGroup 极速28
  14. *
  15. * @apiUse result
  16. * @apiUse header
  17. * @apiVersion 1.0.0
  18. *
  19. * @apiParam {int} [page=1]
  20. * @apiParam {int} [limit=10]
  21. * @apiParam {string} [issue_no] 期号
  22. */
  23. public function index()
  24. {
  25. try {
  26. $search = request()->validate([
  27. 'page' => ['nullable', 'integer', 'min:1'],
  28. 'limit' => ['nullable', 'integer', 'min:1'],
  29. 'issue_no' => ['nullable', 'string'],
  30. ]);
  31. $page = request()->input('page', 1);
  32. $limit = request()->input('limit', 15);
  33. $result['keno'] = PcIssueService::getMatchingNumbers($search['issue_no']);
  34. $result['winning_numbers'] = PcIssueService:: getWinningNumbers($result['keno']);
  35. $result['winning_numbers'][] = $search['issue_no'];
  36. // $result['total'] = PcIssueModel::where(PcIssueModel::getWhere($search))->count();
  37. // $result['data'] = PcIssueModel::where(PcIssueModel::getWhere($search))
  38. // ->orderByDesc('id')->forPage($page, $limit)->get();
  39. } catch (ValidationException $e) {
  40. return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
  41. } catch (Exception $e) {
  42. return $this->error(intval($e->getCode()));
  43. }
  44. return $this->success($result);
  45. }
  46. }