From bc46fef19a34afff16485e39b7b5b2e05d87f21f Mon Sep 17 00:00:00 2001 From: Bohdan Shulha Date: Thu, 8 Aug 2024 23:56:18 +0200 Subject: [PATCH] feat: #68 replace jetstream dashboard with saas-related microdashboard --- app/Http/Controllers/DashboardController.php | 18 +++ .../Middleware/EnsureTeamSubscription.php | 2 +- app/Models/Team.php | 7 +- resources/js/Components/Welcome.vue | 104 ------------------ resources/js/Pages/Dashboard.vue | 23 +++- resources/js/Pages/Nodes/Index.vue | 2 +- routes/web.php | 6 +- 7 files changed, 46 insertions(+), 116 deletions(-) create mode 100644 app/Http/Controllers/DashboardController.php delete mode 100644 resources/js/Components/Welcome.vue diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php new file mode 100644 index 0000000..694624b --- /dev/null +++ b/app/Http/Controllers/DashboardController.php @@ -0,0 +1,18 @@ +user()->currentTeam; + + return Inertia::render('Dashboard', [ + 'nodesCount' => $team->nodes()->count(), + 'servicesCount' => $team->services()->count(), + ]); + } +} diff --git a/app/Http/Middleware/EnsureTeamSubscription.php b/app/Http/Middleware/EnsureTeamSubscription.php index d28f7c1..3bd3f22 100644 --- a/app/Http/Middleware/EnsureTeamSubscription.php +++ b/app/Http/Middleware/EnsureTeamSubscription.php @@ -18,7 +18,7 @@ public function handle(Request $request, Closure $next): Response $team = auth()->user()->currentTeam; $subscription = $team->subscription(); - $doesntHaveSubscription = $subscription === null || ! $subscription->onTrial() && ! $subscription->active(); + $doesntHaveSubscription = $subscription === null || ! $subscription->valid(); if ($doesntHaveSubscription) { return redirect()->route('teams.billing.show', $team); } diff --git a/app/Models/Team.php b/app/Models/Team.php index e30e477..a2a3ee7 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -71,11 +71,16 @@ protected static function booted() }); } - protected function nodes(): HasMany + public function nodes(): HasMany { return $this->hasMany(Node::class); } + public function services(): HasMany + { + return $this->hasMany(Service::class); + } + /** * Get the name of the team. */ diff --git a/resources/js/Components/Welcome.vue b/resources/js/Components/Welcome.vue deleted file mode 100644 index 1ebcfc9..0000000 --- a/resources/js/Components/Welcome.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index d2c067f..002e559 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -1,20 +1,33 @@