lthn.io/app/Mod/Names/Controllers/NamesWebController.php
Claude 756be80d04
feat: complete module scaffolding — all 6 modules with controllers, routes, services
Modules built:
- Home: landing page with live chain stats and service directory
- Chain: DaemonRpc singleton, config, events
- Explorer: web + API controllers (block, tx, alias, search, stats)
- Names: TLD registrar (availability, lookup, directory, registration)
- Trade: DEX controllers + API (config, pairs, orders)
- Pool: dashboard + PoolClient service (stats, blocks, payments, miner)

Infrastructure:
- composer.json: lthn/lthn.io deps (core/php + laravel 12)
- Dockerfile: FrankenPHP with Caddy
- Caddyfile: PHP server config

Co-Authored-By: Charon <charon@lethean.io>
2026-04-03 16:26:17 +01:00

60 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Mod\Names\Controllers;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Mod\Chain\Services\DaemonRpc;
/**
* .lthn name registrar web views.
*
* GET /names — search + directory
* GET /names/register — registration form
* GET /names/{name} — name detail page
*/
class NamesWebController extends Controller
{
public function __construct(
private readonly DaemonRpc $rpc,
) {}
public function index(Request $request): \Illuminate\View\View
{
$result = $this->rpc->getAllAliases();
$aliases = $result['aliases'] ?? [];
$search = $request->get('search', '');
if ($search) {
$aliases = array_filter($aliases, fn ($a) => str_contains($a['alias'] ?? '', strtolower($search))
|| str_contains($a['comment'] ?? '', strtolower($search)));
}
return view('names::index', [
'aliases' => array_values($aliases),
'total' => count($result['aliases'] ?? []),
'search' => $search,
]);
}
public function register(): \Illuminate\View\View
{
return view('names::register');
}
public function show(string $name): \Illuminate\View\View
{
$alias = $this->rpc->getAliasByName($name);
if (! $alias) {
return view('names::available', ['name' => $name]);
}
return view('names::show', [
'name' => $name,
'alias' => $alias,
]);
}
}