mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
Full rewrite of the installer (incl. the finish step), self-update pipeline, settings store, cron webhook, dashboard/bootstrap surface, environment manager, wizard login, config endpoint and shared helpers. Byte-compatible public interfaces and observable behavior, including documented legacy quirks; verified by the pilot behavioral suite and the full test suite.
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Platform\Operations\Http\Company;
|
|
|
|
use App\Platform\Http\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use InvoiceShelf\Modules\Registry;
|
|
|
|
class ConfigController extends Controller
|
|
{
|
|
/**
|
|
* Hand the SPA one value out of the application configuration.
|
|
*
|
|
* Exchange-rate drivers are assembled at runtime rather than read from a
|
|
* config file, so that key takes its own path.
|
|
*/
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$key = $request->key;
|
|
|
|
if ($key === 'exchange_rate_drivers') {
|
|
return response()->json(['exchange_rate_drivers' => $this->exchangeRateDrivers()]);
|
|
}
|
|
|
|
return response()->json([$key => config('invoiceshelf.'.$key)]);
|
|
}
|
|
|
|
/**
|
|
* Build the exchange rate driver list from the module Registry.
|
|
*
|
|
* Returns enriched objects (with label, website, and config_fields) so the
|
|
* frontend can render driver-specific configuration forms without hardcoding
|
|
* any per-driver UI.
|
|
*
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
protected function exchangeRateDrivers(): array
|
|
{
|
|
return collect(Registry::allDrivers('exchange_rate'))
|
|
->map(fn (array $meta, string $name) => [
|
|
'value' => $name,
|
|
'label' => $meta['label'] ?? $name,
|
|
'website' => $meta['website'] ?? '',
|
|
'config_fields' => $meta['config_fields'] ?? [],
|
|
])
|
|
->values()
|
|
->all();
|
|
}
|
|
}
|