File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Enums \CommunityActivity ;
6+
7+ use CommitGlobal \Enums \Concerns \Arrayable ;
8+ use CommitGlobal \Enums \Concerns \Comparable ;
9+ use Filament \Support \Contracts \HasLabel ;
10+
11+ enum OutsideWorkingHours: int implements HasLabel
12+ {
13+ use Arrayable;
14+ use Comparable;
15+
16+ case YES = 1 ;
17+ case NO = 0 ;
18+
19+ public function getLabel (): ?string
20+ {
21+ return match ($ this ) {
22+ self ::YES => __ ('community_activity.hour.outside_working_hours ' ),
23+ self ::NO => __ ('community_activity.hour.within_working_hours ' ),
24+ };
25+ }
26+ }
Original file line number Diff line number Diff line change 1313use Filament \Schemas \Components \Concerns \EntanglesStateWithSingularRelationship ;
1414use Filament \Schemas \Components \Utilities \Get ;
1515use Filament \Schemas \Components \Utilities \Set ;
16- use Illuminate \Support \Facades \Cache ;
1716
1817class Location extends Component
1918{
@@ -57,13 +56,7 @@ protected function setUp(): void
5756 Select::make ($ this ->getCountyField ())
5857 ->label ($ this ->getCountyLabel ())
5958 ->placeholder (__ ('placeholder.county ' ))
60- ->options (
61- fn () => Cache::driver ('array ' )
62- ->rememberForever (
63- 'counties ' ,
64- fn () => County::pluck ('name ' , 'id ' )
65- )
66- )
59+ ->options (County::cachedList ())
6760 ->searchable ()
6861 ->preload ()
6962 ->live ()
Original file line number Diff line number Diff line change 44
55namespace App \Filament \Pages ;
66
7+ use BackedEnum ;
78use Filament \Pages \Dashboard as BaseDashboard ;
9+ use Illuminate \Contracts \Support \Htmlable ;
810
911class Dashboard extends BaseDashboard
1012{
@@ -20,6 +22,11 @@ public static function getNavigationLabel(): string
2022 return __ ('dashboard.home ' );
2123 }
2224
25+ public static function getNavigationIcon (): string | BackedEnum | Htmlable | null
26+ {
27+ return null ;
28+ }
29+
2330 public function getColumns (): int |array
2431 {
2532 return 3 ;
Original file line number Diff line number Diff line change 1414use App \Filament \Resources \Appointments \Schemas \AppointmentInfolist ;
1515use App \Filament \Resources \Appointments \Tables \AppointmentsTable ;
1616use App \Models \Appointment ;
17- use BackedEnum ;
1817use Filament \Resources \Resource ;
1918use Filament \Schemas \Schema ;
20- use Filament \Support \Icons \Heroicon ;
2119use Filament \Tables \Table ;
2220
2321class AppointmentResource extends Resource
@@ -26,8 +24,6 @@ class AppointmentResource extends Resource
2624
2725 protected static ?int $ navigationSort = 3 ;
2826
29- protected static string | BackedEnum | null $ navigationIcon = Heroicon::CalendarDateRange;
30-
3127 public static function getModelLabel (): string
3228 {
3329 return __ ('appointment.label.singular ' );
Original file line number Diff line number Diff line change 1717use App \Filament \Resources \Beneficiaries \Resources \Catagraphies \Pages \SummaryCatagraphy ;
1818use App \Filament \Resources \Beneficiaries \Tables \BeneficiariesTable ;
1919use App \Models \Beneficiary ;
20- use BackedEnum ;
2120use Filament \Resources \Pages \Page ;
2221use Filament \Resources \Resource ;
23- use Filament \Support \Icons \Heroicon ;
2422use Filament \Tables \Table ;
2523use Illuminate \Database \Eloquent \Model ;
2624
@@ -30,8 +28,6 @@ class BeneficiaryResource extends Resource
3028
3129 protected static ?int $ navigationSort = 1 ;
3230
33- protected static string | BackedEnum | null $ navigationIcon = Heroicon::UserGroup;
34-
3531 protected static ?string $ recordTitleAttribute = 'full_name ' ;
3632
3733 public static function getModelLabel (): string
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Filament \Resources \CommunityActivities \Actions ;
6+
7+ use App \Enums \CommunityActivity \Type ;
8+ use App \Filament \Resources \CommunityActivities \Schemas \AdministrativeActivityForm ;
9+ use App \Models \CommunityActivity ;
10+ use Filament \Actions \CreateAction ;
11+ use Filament \Schemas \Schema ;
12+
13+ class CreateAdministrativeActivityAction extends CreateAction
14+ {
15+ public static function getDefaultName (): ?string
16+ {
17+ return 'create_administrative_activity ' ;
18+ }
19+
20+ protected function setUp (): void
21+ {
22+ parent ::setUp ();
23+
24+ $ this ->label (__ ('community_activity.action.create_administrative ' ));
25+ $ this ->modalHeading (__ ('community_activity.action.create_administrative ' ));
26+
27+ $ this ->groupedIcon (null );
28+ $ this ->createAnother (false );
29+
30+ $ this ->using (function (array $ data ) {
31+ $ data ['type ' ] = Type::ADMINISTRATIVE ;
32+
33+ return CommunityActivity::create ($ data );
34+ });
35+
36+ $ this ->schema (fn (Schema $ schema ) => AdministrativeActivityForm::configure ($ schema ));
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Filament \Resources \CommunityActivities \Actions ;
6+
7+ use App \Enums \CommunityActivity \Type ;
8+ use App \Filament \Resources \CommunityActivities \Schemas \CampaignForm ;
9+ use App \Models \CommunityActivity ;
10+ use Filament \Actions \CreateAction ;
11+ use Filament \Schemas \Schema ;
12+
13+ class CreateCampaignAction extends CreateAction
14+ {
15+ public static function getDefaultName (): ?string
16+ {
17+ return 'create_campaign ' ;
18+ }
19+
20+ protected function setUp (): void
21+ {
22+ parent ::setUp ();
23+
24+ $ this ->label (__ ('community_activity.action.create_campaign ' ));
25+ $ this ->modalHeading (__ ('community_activity.action.create_campaign ' ));
26+
27+ $ this ->groupedIcon (null );
28+ $ this ->createAnother (false );
29+
30+ $ this ->using (function (array $ data ) {
31+ $ data ['type ' ] = Type::CAMPAIGN ;
32+
33+ return CommunityActivity::create ($ data );
34+ });
35+
36+ $ this ->schema (fn (Schema $ schema ) => CampaignForm::configure ($ schema ));
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Filament \Resources \CommunityActivities ;
6+
7+ use App \Filament \Resources \CommunityActivities \Pages \ManageAdministrativeActivities ;
8+ use App \Filament \Resources \CommunityActivities \Pages \ManageCampaigns ;
9+ use App \Models \CommunityActivity ;
10+ use Filament \Resources \Resource ;
11+
12+ class CommunityActivityResource extends Resource
13+ {
14+ protected static ?string $ model = CommunityActivity::class;
15+
16+ protected static ?int $ navigationSort = 2 ;
17+
18+ protected static ?string $ slug = 'community ' ;
19+
20+ public static function getModelLabel (): string
21+ {
22+ return __ ('community_activity.label.singular ' );
23+ }
24+
25+ public static function getPluralModelLabel (): string
26+ {
27+ return __ ('community_activity.label.plural ' );
28+ }
29+
30+ public static function getPages (): array
31+ {
32+ return [
33+ 'index ' => ManageCampaigns::route ('/ ' ),
34+ 'administrative ' => ManageAdministrativeActivities::route ('/administrative ' ),
35+ ];
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Filament \Resources \CommunityActivities \Concerns ;
6+
7+ use App \Filament \Resources \CommunityActivities \Actions \CreateAdministrativeActivityAction ;
8+ use App \Filament \Resources \CommunityActivities \Actions \CreateCampaignAction ;
9+ use Filament \Actions \ActionGroup ;
10+ use Filament \Support \Enums \IconPosition ;
11+ use Filament \Support \Icons \Heroicon ;
12+
13+ trait HasActions
14+ {
15+ protected function getHeaderActions (): array
16+ {
17+ return [
18+ ActionGroup::make ([])
19+ ->label (__ ('app.action.group ' ))
20+ ->color ('warning ' )
21+ ->button ()
22+ ->icon (Heroicon::OutlinedChevronDown)
23+ ->iconPosition (IconPosition::After)
24+ ->actions ([
25+ CreateCampaignAction::make (),
26+
27+ CreateAdministrativeActivityAction::make (),
28+ ]),
29+ ];
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Filament \Resources \CommunityActivities \Concerns ;
6+
7+ use App \Concerns \TabbedLayout ;
8+ use App \Filament \Resources \CommunityActivities \CommunityActivityResource ;
9+ use App \Filament \Resources \CommunityActivities \Pages \ManageAdministrativeActivities ;
10+ use App \Filament \Resources \CommunityActivities \Pages \ManageCampaigns ;
11+ use Filament \Navigation \NavigationItem ;
12+
13+ trait HasTabs
14+ {
15+ use TabbedLayout;
16+
17+ public function getTabsNavigation (): array
18+ {
19+ return [
20+
21+ NavigationItem::make ()
22+ ->label (__ ('community_activity.section.campaign ' ))
23+ ->icon ('icon-none ' )
24+ ->url (CommunityActivityResource::getUrl ('index ' ))
25+ ->isActiveWhen (fn () => static ::class === ManageCampaigns::class),
26+
27+ NavigationItem::make ()
28+ ->label (__ ('community_activity.section.administrative ' ))
29+ ->icon ('icon-none ' )
30+ ->url (CommunityActivityResource::getUrl ('administrative ' ))
31+ ->isActiveWhen (fn (): bool => static ::class === ManageAdministrativeActivities::class),
32+
33+ ];
34+ }
35+
36+ public function getHeading (): string
37+ {
38+ return __ ('community_activity.header.list ' );
39+ }
40+
41+ public function getBreadcrumbs (): array
42+ {
43+ return [];
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments