aboutsummaryrefslogtreecommitdiff
path: root/routes/api.php
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@fastmailteam.com>2022-08-02 18:38:01 -0400
committerCalvin Morrison <calvin@fastmailteam.com>2022-08-02 18:38:01 -0400
commit0d2180d9b488219e570d354d11ec3782f1b46024 (patch)
tree53aae2ff3b7b2d90878748d1887c87d67d26ad85 /routes/api.php
parentf2aff7518be55da0fd250e04a4bfc1bbbd5a3d0a (diff)
add a chart
Diffstat (limited to 'routes/api.php')
-rw-r--r--routes/api.php25
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();
});