diff --git a/app/Livewire/Modals/UtmBuilder.php b/app/Livewire/Modals/UtmBuilder.php index 140f34f..0380404 100644 --- a/app/Livewire/Modals/UtmBuilder.php +++ b/app/Livewire/Modals/UtmBuilder.php @@ -3,9 +3,9 @@ namespace App\Livewire\Modals; use Illuminate\View\View; +use Livewire\Attributes\Computed; use LivewireUI\Modal\ModalComponent; -/** @property-read string $fullUrl */ class UtmBuilder extends ModalComponent { public string $baseUrl = ''; @@ -22,7 +22,8 @@ class UtmBuilder extends ModalComponent public bool $copied = false; - public function getFullUrlProperty(): string + #[Computed] + public function fullUrl(): string { if (! $this->baseUrl) { return ''; diff --git a/app/Livewire/Pages/Dashboard/Overview.php b/app/Livewire/Pages/Dashboard/Overview.php index d28340b..11a83c3 100644 --- a/app/Livewire/Pages/Dashboard/Overview.php +++ b/app/Livewire/Pages/Dashboard/Overview.php @@ -9,27 +9,38 @@ use Livewire\Component; class Overview extends Component { - public function render(): View + public int $workspaceId = 0; + + public string $workspaceUlid = ''; + + public function mount(): void { $workspace = require_workspace(); + $this->workspaceId = $workspace->id; + $this->workspaceUlid = $workspace->ulid; + } + + public function render(): View + { + $wsId = $this->workspaceId; // Hero metrics - $today = Click::where('workspace_id', $workspace->id) + $today = Click::where('workspace_id', $wsId) ->whereDate('clicked_at', today()) ->count(); - $last7 = Click::where('workspace_id', $workspace->id) + $last7 = Click::where('workspace_id', $wsId) ->where('clicked_at', '>=', now()->subDays(7)) ->count(); - $last30 = Click::where('workspace_id', $workspace->id) + $last30 = Click::where('workspace_id', $wsId) ->where('clicked_at', '>=', now()->subDays(30)) ->count(); - $totalLinks = Link::where('workspace_id', $workspace->id)->count(); + $totalLinks = Link::where('workspace_id', $wsId)->count(); // Chart data: daily clicks for last 30 days - $chartData = Click::where('workspace_id', $workspace->id) + $chartData = Click::where('workspace_id', $wsId) ->where('clicked_at', '>=', now()->subDays(29)->startOfDay()) ->selectRaw('DATE(clicked_at) as date, COUNT(*) as total') ->groupBy('date') @@ -45,7 +56,7 @@ class Overview extends Component } // Top links by clicks - $topLinks = Link::where('workspace_id', $workspace->id) + $topLinks = Link::where('workspace_id', $wsId) ->withCount(['clicks as total_clicks']) ->orderByDesc('total_clicks') ->limit(5) diff --git a/app/Livewire/Pages/Links/Index.php b/app/Livewire/Pages/Links/Index.php index f7812cc..17b51d2 100644 --- a/app/Livewire/Pages/Links/Index.php +++ b/app/Livewire/Pages/Links/Index.php @@ -16,6 +16,13 @@ class Index extends Component public string $statusFilter = ''; + public int $workspaceId = 0; + + public function mount(): void + { + $this->workspaceId = require_workspace()->id; + } + public function updatingSearch(): void { $this->resetPage(); @@ -36,9 +43,7 @@ class Index extends Component public function render(): View { - $workspace = require_workspace(); - - $links = Link::where('workspace_id', $workspace->id) + $links = Link::where('workspace_id', $this->workspaceId) ->when($this->search, fn ($q) => $q->where(function ($q) { $q->where('title', 'like', "%{$this->search}%") ->orWhere('slug', 'like', "%{$this->search}%") diff --git a/app/Livewire/Pages/Profile/Preferences.php b/app/Livewire/Pages/Profile/Preferences.php index 23058aa..411f675 100644 --- a/app/Livewire/Pages/Profile/Preferences.php +++ b/app/Livewire/Pages/Profile/Preferences.php @@ -29,6 +29,7 @@ class Preferences extends Component 'theme' => $this->theme, ]); + $this->dispatch('theme-changed-server', theme: $this->theme); session()->flash('status', 'Preferences saved.'); } diff --git a/app/Livewire/Pages/Settings/Index.php b/app/Livewire/Pages/Settings/Index.php index 2bbfca8..4f6fe87 100644 --- a/app/Livewire/Pages/Settings/Index.php +++ b/app/Livewire/Pages/Settings/Index.php @@ -11,9 +11,12 @@ class Index extends Component public string $workspaceSlug = ''; + public int $workspaceId = 0; + public function mount(): void { - $ws = current_workspace(); + $ws = require_workspace(); + $this->workspaceId = $ws->id; $this->workspaceName = $ws->name; $this->workspaceSlug = $ws->slug; } @@ -25,9 +28,10 @@ class Index extends Component 'workspaceSlug' => 'nullable|string|max:50|alpha_dash', ]); - require_workspace()->update([ + $ws = \App\Domains\Workspace\Models\Workspace::findOrFail($this->workspaceId); + $ws->update([ 'name' => $this->workspaceName, - 'slug' => $this->workspaceSlug ?: require_workspace()->slug, + 'slug' => $this->workspaceSlug ?: $ws->slug, ]); session()->flash('status', 'Workspace settings saved.'); diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index 2918e7b..09554c9 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -46,9 +46,12 @@ document.addEventListener('alpine:init', () => { init() { this.apply(this.current); }, apply(theme) { this.current = theme; - document.documentElement.dataset.theme = theme; + const actual = theme === 'system' + ? (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') + : theme; + document.documentElement.dataset.theme = actual; localStorage.setItem('nimuli_theme', theme); - document.cookie = 'nimuli_theme=' + theme + '; path=/; max-age=31536000; SameSite=Lax'; + document.cookie = 'nimuli_theme=' + actual + '; path=/; max-age=31536000; SameSite=Lax'; }, cycle() { const order = ['dark', 'light', 'system']; diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index 1f189c4..30acf33 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -244,10 +244,13 @@ :title="$store.sidebar.collapsed ? 'Expand sidebar' : 'Collapse sidebar'" class="flex items-center gap-3 w-full px-3 py-2 rounded-lg text-t3 hover:text-t1 hover:bg-s2 transition-colors" > - -
{{ now()->format('l, F j') }}
|
+
+ @php $qrUrl = $qr->payload['data'] ?? ($qr->payload['url'] ?? null); @endphp
+ @if($qrUrl)
+
Token created — copy it now, it won't be shown again {{ $newToken }}
+
+
|