File tree 5 files changed +58
-3
lines changed
resources/assets/js/prototype/screens
5 files changed +58
-3
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Http \Controllers \Api ;
4
+
5
+ use App \Http \Controllers \Controller ;
6
+ use App \Http \Resources \CurrencyResource ;
7
+ use App \Models \Currency ;
8
+ use Illuminate \Http \Request ;
9
+ use Illuminate \Http \Resources \Json \AnonymousResourceCollection ;
10
+
11
+ class CurrencyController extends Controller
12
+ {
13
+ public function __invoke (): AnonymousResourceCollection
14
+ {
15
+ return CurrencyResource::collection (Currency::all ());
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Http \Resources ;
4
+
5
+ use Illuminate \Http \Request ;
6
+ use Illuminate \Http \Resources \Json \JsonResource ;
7
+
8
+ class CurrencyResource extends JsonResource
9
+ {
10
+ public function toArray (Request $ request ): array
11
+ {
12
+ return [
13
+ 'id ' => $ this ->id ,
14
+ 'name ' => $ this ->name ,
15
+ 'symbol ' => $ this ->symbol ,
16
+ ];
17
+ }
18
+ }
Original file line number Diff line number Diff line change 4
4
5
5
use App \Helper ;
6
6
use App \Models \Space ;
7
+ use Illuminate \Http \Resources \Json \JsonResource ;
7
8
use Illuminate \Support \ServiceProvider ;
8
9
use Auth ;
9
10
@@ -26,6 +27,8 @@ public function boot()
26
27
'versionNumber ' => $ versionNumber
27
28
]);
28
29
});
30
+
31
+ JsonResource::withoutWrapping ();
29
32
}
30
33
31
34
public function register ()
Original file line number Diff line number Diff line change 1
1
<script setup>
2
- //
2
+ import axios from ' axios' ;
3
+ import { onMounted , ref } from ' vue' ;
4
+
5
+ const currencies = ref ([]);
6
+
7
+ const fetchCurrencies = () => {
8
+ axios
9
+ .get (' http://localhost:8000/api/currencies' )
10
+ .then (response => currencies .value = response .data );
11
+ };
12
+
13
+ onMounted (() => {
14
+ fetchCurrencies ();
15
+ });
3
16
</script >
4
17
5
18
<template >
23
36
</div >
24
37
<div >
25
38
<label class =" block mb-1 text-sm text-gray-700" >Currency</label >
26
- <input class =" w-full px-3 py-2 text-sm border rounded-md" type =" text" />
39
+ <select class =" w-full px-3 py-2 text-sm border rounded-md appearance-none" >
40
+ <option v-for =" currency in currencies" >
41
+ <span v-html =" currency.name + ' (' + currency.symbol + ')'" ></span >
42
+ </option >
43
+ </select >
27
44
</div >
28
45
<button class =" w-full py-2.5 hover:bg-blue-600 transition text-sm bg-blue-500 text-white rounded-md" >Register</button >
29
46
</div >
Original file line number Diff line number Diff line change 2
2
3
3
use Illuminate \Http \Request ;
4
4
5
- //
5
+ Route:: get ( ' /currencies ' , \ App \ Http \ Controllers \ Api \CurrencyController::class);
You can’t perform that action at this time.
0 commit comments