Add dashboard
This commit is contained in:
parent
74773c256c
commit
da7fd88b5a
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Views;
|
||||
|
||||
use App\Member\MemberResource;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Payment\Status;
|
||||
use App\Payment\Subscription;
|
||||
use App\Payment\PaymentResource;
|
||||
use App\Payment\Payment;
|
||||
|
||||
class HomeView {
|
||||
public function index(Request $request) {
|
||||
$amount = Payment::whereNeedsPayment()->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, ',', '.').' €'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -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)');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<template>
|
||||
<div class="gap-6 grid-cols-4 grid p-6">
|
||||
|
||||
<!--
|
||||
<inertia-link v-for="block, index in blocks" class="items-center text-gray-800 bg-gray-100 hover:bg-gray-300 p-6 shadow flex flex-col" :href="block.href" :key="index">
|
||||
<span class="flex-grow mb-4">
|
||||
<span :class="block.icon" class="fa fa-lg text-gray-700"></span>
|
||||
</span>
|
||||
<span v-html="block.label"></span>
|
||||
</inertia-link>
|
||||
-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import App from '../layouts/App';
|
||||
|
||||
export default {
|
||||
layout: App,
|
||||
|
||||
props: {
|
||||
blocks: {}
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<template>
|
||||
<div class="rounded-lg bg-gray-700 text-gray-400 p-3">
|
||||
<div class="text-base pb-2 leading-none" v-html="title"></div>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
<template>
|
||||
<div class="gap-6 grid-cols-4 grid p-6">
|
||||
<block title="Ausstehende Mitgliedsbeiträge">
|
||||
<div class="text-gray-100">
|
||||
<span class="text-xl mr-1 font-semibold" v-text="data.payments.amount"></span>
|
||||
<span class="text-sm" v-text="`von ${data.payments.users} / ${data.payments.all_users} Mitgliedern`"></span>
|
||||
</div>
|
||||
</block>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import App from '../../layouts/App';
|
||||
import Block from './Block.vue';
|
||||
|
||||
export default {
|
||||
layout: App,
|
||||
|
||||
components: { Block },
|
||||
|
||||
props: {
|
||||
data: {},
|
||||
blocks: {}
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue