diff options
Diffstat (limited to 'routes/api.php')
-rw-r--r-- | routes/api.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/routes/api.php b/routes/api.php index eb6fa48..4cbbd6d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,7 +2,8 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; - +use App\Models\Currency; +use App\Models\Rates; /* |-------------------------------------------------------------------------- | API Routes @@ -14,6 +15,24 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware('auth:sanctum')->get('/user', function (Request $request) { - return $request->user(); +Route::get('rateseries/{name}', function(Request $request, $name) { + // If the Content-Type and Accept headers are set to 'application/json', + // this will return a JSON structure. This will be cleaned up later. + + $ret = array(); + + $currency = Currency::Where('name', $name)->first(); + + $rates = Rates::where('currency_id', $currency->id)->get(); + foreach($rates as $rate) { + $ret[] = ['x' => strtotime($rate->updated_at), 'y' => $rate->value]; + } + + return $ret; +}); + +Route::get('currency', function() { + // If the Content-Type and Accept headers are set to 'application/json', + // this will return a JSON structure. This will be cleaned up later. + return Currency::all(); }); |