1010use Filament \Forms \Set ;
1111use Filament \Resources \Resource ;
1212use Filament \Tables \Actions \DeleteBulkAction ;
13- use Filament \Tables \Actions \EditAction ;
13+ use Filament \Tables \Actions \ViewAction ;
14+ use Filament \Tables \Columns \IconColumn ;
1415use Filament \Tables \Columns \TextColumn ;
1516use Filament \Tables \Table ;
1617use Illuminate \Support \Facades \Config ;
1718use Moox \UserDevice \Models \UserDevice ;
1819use Moox \UserDevice \Resources \UserDeviceResource \Pages \ListPage ;
20+ use Moox \UserDevice \Resources \UserDeviceResource \Pages \ViewPage ;
1921use Moox \UserDevice \Resources \UserDeviceResource \Widgets \UserDeviceWidgets ;
2022
2123class UserDeviceResource extends Resource
@@ -29,7 +31,12 @@ public static function form(Form $form): Form
2931 return $ form
3032 ->schema ([
3133 TextInput::make ('title ' )
34+ ->label (__ ('user-device::translations.title ' ))
35+ ->maxLength (255 ),
36+ TextInput::make ('slug ' )
37+ ->label (__ ('user-device::translations.slug ' ))
3238 ->maxLength (255 ),
39+ DateTimePicker::make ('updated_at ' ),
3340 DateTimePicker::make ('created_at ' ),
3441
3542 Select::make ('user_type ' )
@@ -64,29 +71,43 @@ public static function table(Table $table): Table
6471 {
6572 return $ table
6673 ->columns ([
74+ IconColumn::make ('platform ' )
75+ ->label ('' )
76+ ->icon (function ($ record ) {
77+ switch ($ record ->platform ) {
78+ case 'Mobile ' :
79+ return 'heroicon-o-device-mobile ' ;
80+ case 'Desktop ' :
81+ return 'heroicon-o-computer-desktop ' ;
82+ default :
83+ return 'heroicon-o-computer-desktop ' ;
84+ }
85+ }),
6786 TextColumn::make ('title ' )
6887 ->label (__ ('user-device::translations.title ' ))
6988 ->sortable (),
70- TextColumn::make ('created_at ' )
71- ->label (__ ('user-device::translations.created_at ' ))
72- ->since ()
73- ->sortable (),
74- TextColumn::make ('active ' )
75- ->label (__ ('user-device::translations.active ' ))
76- ->sortable (),
77- TextColumn::make ('user_type ' )
78- ->label (__ ('user-device::translations.user_type ' ))
79- ->sortable (),
8089 TextColumn::make ('user_id ' )
8190 ->label (__ ('user-device::translations.username ' ))
8291 ->getStateUsing (function ($ record ) {
8392 return optional ($ record ->user )->name ?? 'unknown ' ;
8493 })
8594 ->sortable (),
95+ IconColumn::make ('active ' )
96+ ->label (__ ('user-device::translations.active ' ))
97+ ->toggleable ()
98+ ->boolean (),
99+ TextColumn::make ('updated_at ' )
100+ ->label (__ ('user-device::translations.updated_at ' ))
101+ ->since ()
102+ ->sortable (),
103+ TextColumn::make ('created_at ' )
104+ ->label (__ ('user-device::translations.created_at ' ))
105+ ->since ()
106+ ->sortable (),
86107 ])
87108 ->defaultSort ('title ' , 'desc ' )
88109 ->actions ([
89- EditAction ::make (),
110+ ViewAction ::make (),
90111 ])
91112 ->bulkActions ([
92113 DeleteBulkAction::make (),
@@ -104,6 +125,7 @@ public static function getPages(): array
104125 {
105126 return [
106127 'index ' => ListPage::route ('/ ' ),
128+ //'view' => ViewPage::route('/{record}'),
107129 ];
108130 }
109131
0 commit comments