diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 26cccd04..e38b6dee 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -3,14 +3,15 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
+use App\Http\Views\HomeView;
class HomeController extends Controller
{
- public function __invoke()
+ public function __invoke(Request $request)
{
session()->put('menu', 'dashboard');
session()->put('title', 'Dashboard');
-
- return \Inertia::render('Home', []);
+
+ return \Inertia::render('home/Index', app(HomeView::class)->index($request));
}
}
diff --git a/app/Http/Views/HomeView.php b/app/Http/Views/HomeView.php
new file mode 100644
index 00000000..1c27f607
--- /dev/null
+++ b/app/Http/Views/HomeView.php
@@ -0,0 +1,29 @@
+selectRaw('sum(subscriptions.amount) AS a')->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')->first()->a;
+ $members = Member::whereHasPendingPayment()->count();
+
+ return [
+ 'data' => [
+ 'payments' => [
+ 'users' => $members,
+ 'all_users' => Member::count(),
+ 'amount' => number_format($amount / 100, 2, ',', '.').' €'
+ ]
+ ]
+ ];
+ }
+
+}
diff --git a/app/Member/Member.php b/app/Member/Member.php
index 578eeb36..cb78baf2 100644
--- a/app/Member/Member.php
+++ b/app/Member/Member.php
@@ -154,6 +154,12 @@ class Member extends Model
]);
}
+ public function scopeWhereHasPendingPayment($q) {
+ return $q->whereHas('payments', function($q) {
+ return $q->whereNeedsPayment();
+ });
+ }
+
public function scopePayable($q) {
$q->where('bill_kind_id', '!=', null)->where('subscription_id', '!=', null);
}
@@ -164,4 +170,8 @@ class Member extends Model
});
}
+ public function scopeForDashboard($q) {
+ return $q->selectRaw('SUM(id)');
+ }
+
}
diff --git a/resources/js/views/Home.vue b/resources/js/views/Home.vue
deleted file mode 100644
index b384f399..00000000
--- a/resources/js/views/Home.vue
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/resources/js/views/home/Block.vue b/resources/js/views/home/Block.vue
new file mode 100644
index 00000000..bcacf8ad
--- /dev/null
+++ b/resources/js/views/home/Block.vue
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/resources/js/views/home/Index.vue b/resources/js/views/home/Index.vue
new file mode 100644
index 00000000..f99fc2fb
--- /dev/null
+++ b/resources/js/views/home/Index.vue
@@ -0,0 +1,27 @@
+
+
+
+
+