2
2
3
3
namespace LaraZeus \Sky \Filament \Resources ;
4
4
5
- use Filament \Forms \Components \Radio ;
6
5
use Filament \Forms \Components \Section ;
7
6
use Filament \Forms \Components \Select ;
8
7
use Filament \Forms \Components \SpatieMediaLibraryFileUpload ;
24
23
use LaraZeus \Sky \Filament \Resources \LibraryResource \Pages ;
25
24
use LaraZeus \Sky \Models \Library ;
26
25
use LaraZeus \Sky \SkyPlugin ;
26
+ use Wallo \FilamentSelectify \Components \ButtonGroup ;
27
27
28
28
class LibraryResource extends SkyResource
29
29
{
@@ -42,56 +42,59 @@ public static function form(Form $form): Form
42
42
{
43
43
return $ form
44
44
->schema ([
45
- TextInput::make ('title ' )
46
- ->label (__ ('Library Title ' ))
47
- ->required ()
48
- ->maxLength (255 )
49
- ->live (onBlur: true )
50
- ->afterStateUpdated (function (Set $ set , $ state , $ context ) {
51
- if ($ context === 'edit ' ) {
52
- return ;
53
- }
54
-
55
- $ set ('slug ' , Str::slug ($ state ));
56
- }),
57
-
58
- TextInput::make ('slug ' )
59
- ->unique (ignorable: fn (?Library $ record ): ?Library => $ record )
60
- ->required ()
61
- ->maxLength (255 )
62
- ->label (__ ('Library Slug ' )),
63
-
64
- Textarea::make ('description ' )
65
- ->maxLength (255 )
66
- ->label (__ ('Library Description ' ))
67
- ->columnSpan (2 ),
68
-
69
- SpatieTagsInput::make ('category ' )
70
- ->type ('library ' )
71
- ->label (__ ('Library Categories ' )),
72
-
73
- Select::make ('type ' )
74
- ->label (__ ('Library Type ' ))
75
- ->visible (SkyPlugin::get ()->getLibraryTypes () !== null )
76
- ->options (SkyPlugin::get ()->getLibraryTypes ()),
45
+ Section::make (__ ('Library File ' ))
46
+ ->columns (2 )
47
+ ->schema ([
48
+ TextInput::make ('title ' )
49
+ ->label (__ ('Library Title ' ))
50
+ ->required ()
51
+ ->maxLength (255 )
52
+ ->live (onBlur: true )
53
+ ->afterStateUpdated (function (Set $ set , $ state , $ context ) {
54
+ if ($ context === 'edit ' ) {
55
+ return ;
56
+ }
57
+
58
+ $ set ('slug ' , Str::slug ($ state ));
59
+ }),
60
+
61
+ TextInput::make ('slug ' )
62
+ ->unique (ignorable: fn (?Library $ record ): ?Library => $ record )
63
+ ->required ()
64
+ ->maxLength (255 )
65
+ ->label (__ ('Library Slug ' )),
66
+
67
+ Textarea::make ('description ' )
68
+ ->maxLength (255 )
69
+ ->label (__ ('Library Description ' ))
70
+ ->columnSpan (2 ),
71
+
72
+ SpatieTagsInput::make ('category ' )
73
+ ->type ('library ' )
74
+ ->label (__ ('Library Categories ' )),
75
+
76
+ Select::make ('type ' )
77
+ ->label (__ ('Library Type ' ))
78
+ ->visible (SkyPlugin::get ()->getLibraryTypes () !== null )
79
+ ->options (SkyPlugin::get ()->getLibraryTypes ()),
80
+ ]),
77
81
78
82
Section::make (__ ('Library File ' ))
83
+ ->collapsible ()
84
+ ->compact ()
79
85
->schema ([
80
- Radio::make ('upload_or_url ' )
81
- ->label ('' )
86
+ ButtonGroup::make ('upload_or_url ' )
82
87
->live ()
83
88
->dehydrated (false )
84
89
->afterStateHydrated (function (Set $ set , Get $ get ) {
85
90
$ setVal = ($ get ('file_path ' ) === null ) ? 'upload ' : 'url ' ;
86
91
$ set ('upload_or_url ' , $ setVal );
87
92
})
88
- ->default ('upload ' )
89
93
->options ([
90
94
'upload ' => __ ('upload ' ),
91
95
'url ' => __ ('url ' ),
92
96
])
93
- ->inline (),
94
-
97
+ ->default ('upload ' ),
95
98
SpatieMediaLibraryFileUpload::make ('file_path_upload ' )
96
99
->collection ('library ' )
97
100
->multiple ()
@@ -103,8 +106,7 @@ public static function form(Form $form): Form
103
106
->label (__ ('file url ' ))
104
107
->visible (fn (Get $ get ) => $ get ('upload_or_url ' ) === 'url ' )
105
108
->url (),
106
- ])
107
- ->collapsible (),
109
+ ]),
108
110
]);
109
111
}
110
112
0 commit comments