Where-in-the-World-is-Ben/routes/web.php

56 lines
1.6 KiB
PHP
Raw Normal View History

2022-08-23 19:11:43 +00:00
<?php
use Illuminate\Support\Facades\Route;
use GuzzleHttp\Client;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
2022-09-21 19:40:14 +00:00
if (config('app.current_trip_id')) {
$client = new Client([
'base_uri' => 'https://app.wayward.travel/',
'timeout' => 3.0
]);
$response = $client->get('trip/'.config('app.current_trip_id').'/user/zmld8ko6qy7d9j3xvq10/json');
if ($response->getStatusCode() == 200) {
$data = json_decode($response->getBody());
return view('tracker', ['trip' => $data->trip]);
} else {
return 'Something went wrong';
}
} else {
return view('no-trip');
}
});
Route::get('/past-trips', function () {
return view('past-trips');
});
Route::get('/past-trip/{tripId}', function ($tripId) {
2022-08-23 19:11:43 +00:00
$client = new Client([
'base_uri' => 'https://app.wayward.travel/',
'timeout' => 3.0
]);
2022-09-21 19:40:14 +00:00
$response = $client->get('trip/'.$tripId.'/user/zmld8ko6qy7d9j3xvq10/json');
2022-08-23 19:11:43 +00:00
if ($response->getStatusCode() == 200) {
$data = json_decode($response->getBody());
2022-09-21 19:40:14 +00:00
return view('past-trip', ['trip' => $data->trip]);
2022-08-23 19:11:43 +00:00
} else {
return 'Something went wrong';
}
});