Expand Link app with analytics, settings, and custom domains.
Deploy Ladill Link / deploy (push) Successful in 37s

Add Bitly-style branded domain support via Ladill Domains SSL API,
account analytics dashboard, settings page with default domain picker,
and fix SSO/dashboard issues from QR Plus template leftovers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-27 12:16:34 +00:00
co-authored by Cursor
parent d9c91ad7d8
commit 9516fcb9f3
38 changed files with 1263 additions and 70 deletions
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\Link;
use App\Http\Controllers\Controller;
use App\Services\Link\LinkAnalyticsService;
use Illuminate\Http\Request;
use Illuminate\View\View;
class AnalyticsController extends Controller
{
public function __construct(private LinkAnalyticsService $analytics) {}
public function index(Request $request): View
{
$account = ladill_account();
return view('links.analytics.index', [
'summary' => $this->analytics->summaryForAccount($account),
'dailyClicks' => $this->analytics->dailyClicksForAccount($account, 30),
'topLinks' => $this->analytics->topLinksForAccount($account),
'recentClicks' => $this->analytics->recentClicksForAccount($account),
'referrers' => $this->analytics->referrersForAccount($account),
]);
}
}
@@ -0,0 +1,94 @@
<?php
namespace App\Http\Controllers\Link;
use App\Http\Controllers\Controller;
use App\Models\LinkCustomDomain;
use App\Services\CustomDomain\DomainsSslClient;
use App\Services\CustomDomain\LinkCustomDomainService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class CustomDomainController extends Controller
{
public function __construct(
private readonly LinkCustomDomainService $service,
private readonly DomainsSslClient $domains,
) {}
public function index(Request $request): View
{
$account = ladill_account();
return view('links.domains.index', [
'domains' => $account->linkCustomDomains()->latest()->get(),
'enabled' => $this->service->enabled(),
'serverIp' => (string) config('customdomain.server_ip'),
'publicDomain' => (string) config('link.public_domain', 'ladl.link'),
]);
}
public function store(Request $request): RedirectResponse
{
abort_unless($this->service->enabled(), 404);
$data = $request->validate([
'host' => ['required', 'string', 'max:255', 'regex:/^(?!-)([a-z0-9-]+\.)+[a-z]{2,}$/i'],
'include_www' => ['nullable', 'boolean'],
'make_default' => ['nullable', 'boolean'],
]);
$host = strtolower(preg_replace('/^www\./', '', trim($data['host'])));
if (LinkCustomDomain::where('host', $host)->exists()) {
return back()->withErrors(['host' => 'That domain is already connected.']);
}
$domain = $this->service->attach(
$request->user(),
$host,
(bool) ($data['include_www'] ?? true),
(bool) ($data['make_default'] ?? false),
);
$this->domains->registerConnected(
$host,
(string) $request->user()->public_id,
'Ladill Link',
route('link.domains.index'),
);
return back()->with('success', "Domain added. Point an A record for {$host} to ".config('customdomain.server_ip').', then click Verify.');
}
public function verify(Request $request, LinkCustomDomain $customDomain): RedirectResponse
{
abort_unless($customDomain->user_id === $request->user()->id, 403);
[$ok, $message] = $this->service->verifyAndProvision($customDomain);
return back()->with($ok ? 'success' : 'error', $message);
}
public function makeDefault(Request $request, LinkCustomDomain $customDomain): RedirectResponse
{
abort_unless($customDomain->user_id === $request->user()->id, 403);
abort_unless($customDomain->isLive(), 422);
$this->service->setDefault($customDomain);
return back()->with('success', $customDomain->host.' is now your default short-link domain.');
}
public function destroy(Request $request, LinkCustomDomain $customDomain): RedirectResponse
{
abort_unless($customDomain->user_id === $request->user()->id, 403);
$host = $customDomain->host;
$customDomain->delete();
$this->domains->removeConnected($host);
return back()->with('success', 'Custom domain removed.');
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\Link;
use App\Http\Controllers\Controller;
use App\Models\LinkCustomDomain;
use App\Models\LinkWallet;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class SettingsController extends Controller
{
public function index(Request $request): View
{
$account = ladill_account();
return view('links.settings.index', [
'pricePerLink' => LinkWallet::pricePerLink(),
'defaultDomain' => $account->defaultLinkDomain(),
'publicDomain' => (string) config('link.public_domain', 'ladl.link'),
'customDomains' => $account->linkCustomDomains()->latest()->get(),
]);
}
public function updateDefaultDomain(Request $request): RedirectResponse
{
$account = ladill_account();
$validated = $request->validate([
'domain' => ['required', 'string', 'max:255'],
]);
if ($validated['domain'] === 'platform') {
LinkCustomDomain::where('user_id', $account->id)->update(['is_default' => false]);
return back()->with('success', 'Default short-link domain set to ladl.link.');
}
$domain = LinkCustomDomain::query()
->where('user_id', $account->id)
->where('id', $validated['domain'])
->firstOrFail();
abort_unless($domain->isLive(), 422);
LinkCustomDomain::where('user_id', $account->id)->update(['is_default' => false]);
$domain->forceFill(['is_default' => true])->save();
return back()->with('success', 'Default short-link domain updated.');
}
}