|
|
@@ -2,13 +2,17 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
+use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Models\Sport as SportModel;
|
|
|
use App\Services\FixtureService;
|
|
|
+use Illuminate\Http\JsonResponse;
|
|
|
+use Exception;
|
|
|
+use Illuminate\Validation\ValidationException;
|
|
|
|
|
|
class Sport extends Controller
|
|
|
{
|
|
|
- public function index()
|
|
|
+ public function index(): JsonResponse
|
|
|
{
|
|
|
$date = request()->input('date', date('Y-m-d'));
|
|
|
$start = strtotime($date);
|
|
|
@@ -19,4 +23,22 @@ public function index()
|
|
|
->where("game_time", "<", $end)->count();
|
|
|
return $this->success(['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
+
|
|
|
+ public function odds(): JsonResponse
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ request()->validate([
|
|
|
+ 'data_id' => ['required', 'string', 'min:1'],
|
|
|
+ ]);
|
|
|
+ $dataId = request()->input('data_id');
|
|
|
+ $res = FixtureService::odds($dataId);
|
|
|
+ }catch (ValidationException $e) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error($e->getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return $this->success($res);
|
|
|
+ }
|
|
|
}
|