aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/api.php25
-rw-r--r--routes/web.php5
2 files changed, 26 insertions, 4 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();
});
diff --git a/routes/web.php b/routes/web.php
index 9396c11..c7be55c 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -30,7 +30,10 @@ Route::get('/', function () {
$rates = new Collection();
foreach($ratesRaw as $r) {
- $rates->push(Rates::find($r->id));
+ $rate = Rates::find($r->id);
+ if($rate->currency->name != "Bitcoin") {
+ $rates->push($rate);
+ }
}
return view('welcome', ['currencies' => Currency::all(), 'rates' => $rates]);
});