refactor: Use class imports and scope methods for improved readability in chart widgets.
This commit is contained in:
parent
7d970587fa
commit
9fdba64499
@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Location;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -17,7 +18,7 @@ class IssueLocationChart extends ChartWidget
|
||||
protected function getData(): array
|
||||
{
|
||||
$issueTable = (new IssueManagement)->getTable();
|
||||
$locationTable = (new \App\Models\Location)->getTable();
|
||||
$locationTable = (new Location)->getTable();
|
||||
|
||||
$data = IssueManagement::query()
|
||||
->join($locationTable, "{$issueTable}.location_id", '=', "{$locationTable}.id")
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Journalist;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -36,7 +37,7 @@ protected function getData(): array
|
||||
'backgroundColor' => 'rgba(99, 102, 241, 0.1)',
|
||||
],
|
||||
],
|
||||
'labels' => $data->pluck('month')->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
'labels' => $data->pluck('month')->map(fn ($m) => Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\PartnerMedia;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -36,7 +37,7 @@ protected function getData(): array
|
||||
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
|
||||
],
|
||||
],
|
||||
'labels' => $data->pluck('month')->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
'labels' => $data->pluck('month')->map(fn ($m) => Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\Report;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -35,9 +35,9 @@ protected function getData(): array
|
||||
$rejectedData = [];
|
||||
|
||||
foreach ($months as $month) {
|
||||
$acceptedData[] = $data->where('month', $month)->where('status', ApprovalStatus::ACCEPTED)->first()?->count ?? 0;
|
||||
$pendingData[] = $data->where('month', $month)->where('status', ApprovalStatus::PENDING)->first()?->count ?? 0;
|
||||
$rejectedData[] = $data->where('month', $month)->where('status', ApprovalStatus::REJECTED)->first()?->count ?? 0;
|
||||
$acceptedData[] = $data->where('month', $month)->accepted()->first()?->count ?? 0;
|
||||
$pendingData[] = $data->where('month', $month)->pending()->first()?->count ?? 0;
|
||||
$rejectedData[] = $data->where('month', $month)->rejected()->first()?->count ?? 0;
|
||||
}
|
||||
|
||||
return [
|
||||
@ -58,7 +58,7 @@ protected function getData(): array
|
||||
'backgroundColor' => '#EF4444',
|
||||
],
|
||||
],
|
||||
'labels' => $months->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
'labels' => $months->map(fn ($m) => Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\VerificationStatus;
|
||||
use App\Models\VerificationRequest;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -52,7 +53,7 @@ protected function getData(): array
|
||||
'backgroundColor' => '#EF4444',
|
||||
],
|
||||
],
|
||||
'labels' => $months->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
'labels' => $months->map(fn ($m) => Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Visitor;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -36,7 +37,7 @@ protected function getData(): array
|
||||
'backgroundColor' => 'rgba(59, 130, 246, 0.1)',
|
||||
],
|
||||
],
|
||||
'labels' => $data->pluck('day')->map(fn ($d) => \Carbon\Carbon::parse($d)->translatedFormat('d M'))->toArray(),
|
||||
'labels' => $data->pluck('day')->map(fn ($d) => Carbon::parse($d)->translatedFormat('d M'))->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user