refactor: adopt CorePHP patterns in Pool, Trade, Names Website modules

All three Website modules now use $event->routes() with domain-scoped
routing. On their subdomain (e.g. pool.lthn.io): routes serve at root.
On lthn.io: the Mod modules handle the prefixed paths (/pool, /trade,
/names). Removed loadViewsFrom from boot() where views are already
registered by the corresponding Mod modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-04 09:58:38 +01:00
parent c1402cade5
commit 6ebb8407a2
No known key found for this signature in database
GPG key ID: AF404715446AEB41
3 changed files with 34 additions and 16 deletions

View file

@ -13,12 +13,13 @@ use Illuminate\Support\ServiceProvider;
/**
* .lthn TLD registrar website.
*
* Serves names.lthn.io (prod) or /names path on lthn.io.
* On names.lthn.io: serves at root. On lthn.io: Mod/Names handles /names prefix.
*/
class Boot extends ServiceProvider
{
public static array $domains = [
'/^names\.lthn\.io$/',
'/^names\.(test|localhost)$/',
];
public static array $listens = [
@ -30,8 +31,6 @@ class Boot extends ServiceProvider
public function boot(): void
{
$this->loadViewsFrom(__DIR__ . '/Views', 'names');
foreach (static::$listens as $event => $method) {
Event::listen($event, [$this, $method]);
}
@ -47,8 +46,15 @@ class Boot extends ServiceProvider
}
}
public function onWebRoutes(): void
public function onWebRoutes(WebRoutesRegistering $event): void
{
Route::prefix('names')->group(__DIR__ . '/Routes/web.php');
$host = $_SERVER['HTTP_HOST'] ?? '';
foreach (static::$domains as $pattern) {
if (preg_match($pattern, $host)) {
$event->routes(fn () => Route::group([], __DIR__ . '/Routes/web.php'));
return;
}
}
}
}

View file

@ -11,14 +11,15 @@ use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
/**
* Mining pool dashboard website.
* Mining pool dashboard.
*
* Serves pool.lthn.io (prod) or /pool path on lthn.io.
* On pool.lthn.io: serves at root. On lthn.io: Mod/Pool handles /pool prefix.
*/
class Boot extends ServiceProvider
{
public static array $domains = [
'/^pool\.lthn\.io$/',
'/^pool\.(test|localhost)$/',
];
public static array $listens = [
@ -30,8 +31,6 @@ class Boot extends ServiceProvider
public function boot(): void
{
$this->loadViewsFrom(__DIR__ . '/Views', 'pool');
foreach (static::$listens as $event => $method) {
Event::listen($event, [$this, $method]);
}
@ -47,8 +46,15 @@ class Boot extends ServiceProvider
}
}
public function onWebRoutes(): void
public function onWebRoutes(WebRoutesRegistering $event): void
{
Route::prefix('pool')->group(__DIR__ . '/Routes/web.php');
$host = $_SERVER['HTTP_HOST'] ?? '';
foreach (static::$domains as $pattern) {
if (preg_match($pattern, $host)) {
$event->routes(fn () => Route::group([], __DIR__ . '/Routes/web.php'));
return;
}
}
}
}

View file

@ -13,12 +13,13 @@ use Illuminate\Support\ServiceProvider;
/**
* DEX trade website.
*
* Serves trade.lthn.io (prod) or /trade path on lthn.io.
* On trade.lthn.io: serves at root. On lthn.io: Mod/Trade handles /trade prefix.
*/
class Boot extends ServiceProvider
{
public static array $domains = [
'/^trade\.lthn\.io$/',
'/^trade\.(test|localhost)$/',
];
public static array $listens = [
@ -30,8 +31,6 @@ class Boot extends ServiceProvider
public function boot(): void
{
$this->loadViewsFrom(__DIR__ . '/Views', 'trade');
foreach (static::$listens as $event => $method) {
Event::listen($event, [$this, $method]);
}
@ -47,8 +46,15 @@ class Boot extends ServiceProvider
}
}
public function onWebRoutes(): void
public function onWebRoutes(WebRoutesRegistering $event): void
{
Route::prefix('trade')->group(__DIR__ . '/Routes/web.php');
$host = $_SERVER['HTTP_HOST'] ?? '';
foreach (static::$domains as $pattern) {
if (preg_match($pattern, $host)) {
$event->routes(fn () => Route::group([], __DIR__ . '/Routes/web.php'));
return;
}
}
}
}