feat: tambah role editor, workflow post, leaderboard, rekap kehadiran, kategori kas dengan type, seeder lengkap
This commit is contained in:
@@ -21,7 +21,7 @@ class CashStatsWidget extends StatsOverviewWidget
|
||||
$saldo = fn ($query) => $query
|
||||
->whereNotNull('verified_at')
|
||||
->join('cash_categories', 'cash_records.category_id', '=', 'cash_categories.id')
|
||||
->selectRaw("SUM(CASE WHEN cash_categories.name = 'pemasukan' THEN amount ELSE -amount END) as saldo")
|
||||
->selectRaw("SUM(CASE WHEN cash_categories.type = 'pemasukan' THEN amount ELSE -amount END) as saldo")
|
||||
->value('saldo') ?? 0;
|
||||
|
||||
$bulanIni = now()->startOfMonth();
|
||||
@@ -30,12 +30,12 @@ class CashStatsWidget extends StatsOverviewWidget
|
||||
$totalSaldo = $saldo(CashRecord::query());
|
||||
$pemasukanBulanIni = CashRecord::whereNotNull('verified_at')
|
||||
->join('cash_categories', 'cash_records.category_id', '=', 'cash_categories.id')
|
||||
->where('cash_categories.name', 'pemasukan')
|
||||
->where('cash_categories.type', 'pemasukan')
|
||||
->whereMonth('date', $bulanIni->month)->whereYear('date', $bulanIni->year)
|
||||
->sum('amount');
|
||||
$pengeluaranBulanIni = CashRecord::whereNotNull('verified_at')
|
||||
->join('cash_categories', 'cash_records.category_id', '=', 'cash_categories.id')
|
||||
->where('cash_categories.name', 'pengeluaran')
|
||||
->where('cash_categories.type', 'pengeluaran')
|
||||
->whereMonth('date', $bulanIni->month)->whereYear('date', $bulanIni->year)
|
||||
->sum('amount');
|
||||
$saldoBulanLalu = $saldo(CashRecord::query()->where('date', '<', $bulanIni));
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\MemberPoint;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class LeaderboardWidget extends TableWidget
|
||||
{
|
||||
protected static ?string $heading = 'Leaderboard Poin Anggota';
|
||||
protected int | string | array $columnSpan = 'full';
|
||||
protected static ?int $sort = 3;
|
||||
|
||||
public function getTableRecordKey(\Illuminate\Database\Eloquent\Model|array $record): string
|
||||
{
|
||||
return (string) (is_array($record) ? $record['user_id'] : $record->user_id);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(
|
||||
MemberPoint::query()
|
||||
->selectRaw('user_id, SUM(points) as total_points')
|
||||
->groupBy('user_id')
|
||||
->orderByDesc('total_points')
|
||||
->limit(10)
|
||||
->with('user')
|
||||
)
|
||||
->columns([
|
||||
TextColumn::make('user.name')->label('Anggota'),
|
||||
TextColumn::make('total_points')->label('Total Poin')
|
||||
->badge()->color('success'),
|
||||
])
|
||||
->paginated(false);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class StatsOverview extends StatsOverviewWidget
|
||||
{
|
||||
$totalKas = CashRecord::whereNotNull('verified_at')
|
||||
->join('cash_categories', 'cash_records.category_id', '=', 'cash_categories.id')
|
||||
->selectRaw("SUM(CASE WHEN cash_categories.name = 'pemasukan' THEN amount ELSE -amount END) as saldo")
|
||||
->selectRaw("SUM(CASE WHEN cash_categories.type = 'pemasukan' THEN amount ELSE -amount END) as saldo")
|
||||
->value('saldo') ?? 0;
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user