diff --git a/app/Filament/Pages/Analisys.php b/app/Filament/Pages/Analisys.php index 95ff37c..6e15b9f 100644 --- a/app/Filament/Pages/Analisys.php +++ b/app/Filament/Pages/Analisys.php @@ -12,6 +12,7 @@ use App\Models\Order; use App\Models\Payroll; use BackedEnum; +use BezhanSalleh\FilamentShield\Traits\HasPageShield; use Carbon\Carbon; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; @@ -25,7 +26,7 @@ class Analisys extends Page implements HasForms { - use InteractsWithForms; + use HasPageShield, InteractsWithForms; public ?array $data = []; diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 9489283..aa3f384 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -2,6 +2,7 @@ namespace App\Filament\Pages; +use App\Enums\RoleEnum; use App\Models\Customer; use App\Models\DelayedGood; use App\Models\EggCollectionItem; @@ -10,6 +11,7 @@ use App\Models\Order; use App\Models\Payroll; use Filament\Pages\Dashboard as BaseDashboard; +use Filament\Widgets\AccountWidget; class Dashboard extends BaseDashboard { @@ -17,6 +19,13 @@ class Dashboard extends BaseDashboard protected string $view = 'filament.pages.dashboard'; + public function getHeaderWidgets(): array + { + return [ + AccountWidget::class, + ]; + } + public function getViewData(): array { $formatNumber = fn ($val) => number_format((float) $val, $val == floor($val) ? 0 : 2, ',', '.'); @@ -118,6 +127,7 @@ public function getViewData(): array ->get(); return [ + 'isAdministrator' => auth()->user()->hasRole(RoleEnum::ADMINISTRATOR->value), 'mainStats' => $mainStats, 'totalEggsByUnit' => $totalEggsByUnit, 'totalDelayedByUnit' => $delayedStatsByUnit, diff --git a/database/seeders/ShieldSeeder.php b/database/seeders/ShieldSeeder.php index 189e00b..46498b3 100644 --- a/database/seeders/ShieldSeeder.php +++ b/database/seeders/ShieldSeeder.php @@ -22,11 +22,7 @@ public function run(): void "name": "Developer", "guard_name": "web", "permissions" : [ - "View:StatsOverview", - "View:EggProductionChart", - "View:OrderTrendChart", - "View:RevenueExpenseChart", - "View:TopCustomersChart", + "View:Analisys", "ViewAny:Customer", "View:Customer", @@ -189,11 +185,7 @@ public function run(): void "name": "Pemilik", "guard_name": "web", "permissions" : [ - "View:StatsOverview", - "View:EggProductionChart", - "View:OrderTrendChart", - "View:RevenueExpenseChart", - "View:TopCustomersChart", + "View:Analisys", "ViewAny:Customer", "View:Customer", diff --git a/resources/views/filament/pages/dashboard.blade.php b/resources/views/filament/pages/dashboard.blade.php index d02a18b..635576a 100644 --- a/resources/views/filament/pages/dashboard.blade.php +++ b/resources/views/filament/pages/dashboard.blade.php @@ -1,220 +1,242 @@ -
- {{-- Main Stats Grid --}} -
- @foreach ($mainStats as $stat) -
-
- {{ $stat['label'] }} -
- @if ($stat['prefix']) - {{ $stat['prefix'] }} - @endif - {{ $stat['value'] }} + @if (!$isAdministrator) + +
+ {{-- Main Stats Grid --}} +
+ @foreach ($mainStats as $stat) +
+
+ {{ $stat['label'] }} +
+ @if ($stat['prefix']) + {{ $stat['prefix'] }} + @endif + {{ $stat['value'] }} +
+ {{ $stat['desc'] }}
- {{ $stat['desc'] }} +
+ @endforeach +
+ + {{-- Distribution Row --}} +
+
+

+ + Sumber Pemasukan +

+
+
- @endforeach -
- - {{-- Distribution Row --}} -
-
-

- - Sumber Pemasukan -

-
- -
-
-
-

- - Alokasi Pengeluaran -

-
- -
-
-
-

- - Penjualan per Satuan -

-
- -
-
-
- - {{-- Units Breakdown --}} -
- {{-- Production --}} -
-

Produksi (Unit)

- Hari Ini + class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm p-6"> +

+ + Alokasi Pengeluaran +

+
+ +
-
- @forelse($totalEggsByUnit as $item) -
- {{ $item['unit_name'] }} -
+
+

+ + Penjualan per Satuan +

+
+ +
+
+
+ + {{-- Units Breakdown --}} +
+ {{-- Production --}} +
+
+

Produksi (Unit)

+ Hari Ini +
+
+ @forelse($totalEggsByUnit as $item) +
+ {{ $item['unit_name'] }} +
+
+ Bagus + {{ $item['total_good'] }} +
+
+ Pecah + {{ $item['total_broken'] }} +
+
+
+ @empty +
Belum ada data produksi +
+ @endforelse +
+
+ + {{-- Delayed --}} +
+
+

Tertunda (Unit)

+ Hari Ini +
+
+ @forelse($totalDelayedByUnit as $item) +
+ {{ $item['unit_name'] }} + {{ $item['total'] }} +
+ @empty +
Tidak ada barang tertunda + hari + ini
+ @endforelse +
+
+
+ + +
+ + {{-- Top Customers Today --}} +
+
+ +

Top Pelanggan Hari Ini

+
+
+ @forelse ($topCustomers as $customer) +
+
+ {{ $customer->name }} + {{ $customer->phone_number ?? 'Telp tidak ada' }} +
- Bagus {{ $item['total_good'] }} -
-
- Pecah - {{ $item['total_broken'] }} + class="text-[10px] font-semibold text-gray-400 uppercase block leading-none mb-1">Transaksi + Rp + {{ $formatNumber($customer->total_spent) }}
-
- @empty -
Belum ada data produksi
- @endforelse -
-
- - {{-- Delayed --}} -
-
-

Tertunda (Unit)

- Hari Ini -
-
- @forelse($totalDelayedByUnit as $item) -
- {{ $item['unit_name'] }} - {{ $item['total'] }} -
- @empty -
Tidak ada barang tertunda hari - ini
- @endforelse + @empty +
Belum ada transaksi hari + ini +
+ @endforelse +
+ @endif - -
- - {{-- Top Customers Today --}} -
-
- -

Top Pelanggan Hari Ini

-
-
- @forelse ($topCustomers as $customer) -
-
- {{ $customer->name }} - {{ $customer->phone_number ?? 'Telp tidak ada' }} -
-
- Transaksi - Rp - {{ $formatNumber($customer->total_spent) }} -
-
- @empty -
Belum ada transaksi hari ini -
- @endforelse -
-
-
-
- - - + + + @endif