Use select element in favor of Searchable component for currency input on registration page and also show currency's name alongside symbol for clarification
MODIFY
app/Http/Controllers/RegisterController.php
app/Http/Controllers/RegisterController.php
@@ -4,11 +4,11 @@ namespace App\Http\Controllers;
use App\Actions\StoreSpaceInSessionAction;
use App\Actions\SendVerificationMailAction;
+use App\Models\Currency;
use App\Models\LoginAttempt;
use Illuminate\Http\Request;
// use App\Http\Controllers\Controller;
-use App\Repositories\CurrencyRepository;
use App\Repositories\LoginAttemptRepository;
use App\Repositories\SpaceRepository;
use App\Repositories\UserRepository;
@@ -16,18 +16,15 @@ use Illuminate\Support\Facades\Auth;
class RegisterController extends Controller
{
- private $currencyRepository;
private $userRepository;
private $spaceRepository;
private $loginAttemptRepository;
public function __construct(
- CurrencyRepository $currencyRepository,
UserRepository $userRepository,
SpaceRepository $spaceRepository,
LoginAttemptRepository $loginAttemptRepository
) {
- $this->currencyRepository = $currencyRepository;
$this->userRepository = $userRepository;
$this->spaceRepository = $spaceRepository;
$this->loginAttemptRepository = $loginAttemptRepository;
@@ -36,7 +33,7 @@ class RegisterController extends Controller
public function index()
{
return view('register', [
- 'currencies' => $this->currencyRepository->getKeyValueArray()
+ 'currencies' => Currency::orderBy('name')->get()
]);
}

MODIFY
app/Repositories/CurrencyRepository.php
app/Repositories/CurrencyRepository.php
@@ -29,18 +29,4 @@ class CurrencyRepository
->groupBy('currencies.id')
->get();
}
-
- public function getKeyValueArray(): array
- {
- $response = [];
-
- foreach ($this->getAll() as $currency) {
- $response[] = [
- 'key' => $currency->id,
- 'label' => $currency->symbol
- ];
- }
-
- return $response;
- }
}

MODIFY
resources/views/register.blade.php
resources/views/register.blade.php
</div>
<div class="input">
<label>Currency</label>
- <searchable
- class="shadow"
- name="currency"
- size="2"
- :items='@json($currencies)'
- initial="{{ old('currency') }}"></searchable>
+ <select name="currency" class="shadow">
+ @foreach ($currencies as $currency)
+ <option value="{{ $currency->id }}">{{ $currency->name }} ({!! $currency->symbol !!})</option>
+ @endforeach
+ </select>
@include('partials.validation_error', ['payload' => 'currency'])
</div>
<button class="button button--wide">Register</button>

Use select element in favor of Searchable component for currency input on registration page and also show currency's name alongside symbol for clarification