|
|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
+use App\Models\Sport;
|
|
|
use App\Services\ApiFootball\Client;
|
|
|
use App\Services\FixtureService;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
@@ -12,30 +13,12 @@ class Test extends Controller
|
|
|
{
|
|
|
public function index()
|
|
|
{
|
|
|
-// $data = $this->football('/countries',[]);
|
|
|
-// $data = $this->football('/leagues',['code'=>'DZ']);
|
|
|
-// $data = $this->football('/fixtures', ['date' => '2026-03-05']);
|
|
|
-
|
|
|
-// $data[] = Client::timezone();
|
|
|
-// $data[] = $this->football('/fixtures', ['date' => '2026-03-05']);
|
|
|
-
|
|
|
-// $data[] = $this->football('/odds',['fixture'=>'1491915']);
|
|
|
-
|
|
|
-// $data = FixtureService::index();
|
|
|
- $id = request()->input('id', '1492541');
|
|
|
-//
|
|
|
-// $sport = DB::select("SELECT * FROM sports WHERE data_id = {$id}");
|
|
|
-// $sport = $sport[0];
|
|
|
- $list = $this->football('/odds/live',['fixture'=>$id]);
|
|
|
-// $data[] = $sport;
|
|
|
-// foreach ($list['response'] as $item) {
|
|
|
-// if ($item['fixture']['id'] == $sport->data_id) {
|
|
|
-// $data[] = $item;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
- $data[] = $list;
|
|
|
- return $this->success($data);
|
|
|
+ $list = $this->football('/odds/live');
|
|
|
+ foreach ($list['response'] as $item) {
|
|
|
+ $sport = Sport::where('data_id', $item['fixture']['id'])->first();
|
|
|
+ $sport->odds = json_encode($item['odds']);
|
|
|
+ $sport->save();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function football($api, $params = [])
|