44
55namespace Moox \Builder \Resources ;
66
7- use Filament \Forms \Form ;
8- use Filament \Tables \Table ;
9- use Moox \Builder \Models \Item ;
10- use Filament \Resources \Resource ;
11- use Filament \Forms \Components \Grid ;
12- use Filament \Forms \Components \Select ;
7+ use Camya \Filament \Forms \Components \TitleWithSlugInput ;
138use Filament \Forms \Components \Actions ;
9+ use Filament \Forms \Components \DateTimePicker ;
10+ use Filament \Forms \Components \FileUpload ;
11+ use Filament \Forms \Components \Grid ;
12+ use Filament \Forms \Components \MarkdownEditor ;
1413use Filament \Forms \Components \Section ;
14+ use Filament \Forms \Components \Select ;
1515use Filament \Forms \Components \Textarea ;
16+ use Filament \Forms \Form ;
17+ use Filament \Resources \Resource ;
18+ use Filament \Tables \Actions \DeleteBulkAction ;
1619use Filament \Tables \Actions \EditAction ;
20+ use Filament \Tables \Actions \RestoreBulkAction ;
1721use Filament \Tables \Actions \ViewAction ;
18- use Filament \Tables \Columns \TextColumn ;
1922use Filament \Tables \Columns \ImageColumn ;
20- use Filament \Forms \ Components \ FileUpload ;
23+ use Filament \Tables \ Columns \ TextColumn ;
2124use Filament \Tables \Filters \SelectFilter ;
25+ use Filament \Tables \Table ;
2226use Illuminate \Database \Eloquent \Builder ;
23- use Filament \Forms \Components \DateTimePicker ;
24- use Filament \Forms \Components \MarkdownEditor ;
25- use Filament \Tables \Actions \DeleteBulkAction ;
2627use Illuminate \Database \Eloquent \SoftDeletes ;
27- use Filament \ Tables \ Actions \ RestoreBulkAction ;
28- use Camya \ Filament \ Forms \ Components \ TitleWithSlugInput ;
28+ use Moox \ Builder \ Models \ Item ;
29+ use Moox \ Builder \ Resources \ ItemResource \ Pages \ CreateItem ;
2930use Moox \Builder \Resources \ItemResource \Pages \EditItem ;
30- use Moox \Builder \Resources \ItemResource \Pages \ViewItem ;
3131use Moox \Builder \Resources \ItemResource \Pages \ListItems ;
32- use Moox \Builder \Resources \ItemResource \Pages \CreateItem ;
32+ use Moox \Builder \Resources \ItemResource \Pages \ViewItem ;
3333use Moox \Builder \Resources \ItemResource \Widgets \ItemWidgets ;
3434
3535//use Moox\Core\Forms\Components\TitleWithSlugInput;
@@ -66,7 +66,6 @@ public static function form(Form $form): Form
6666 fieldSlug: 'slug ' , // The name of the field in your model that will store the slug.
6767 ),
6868
69-
7069 /*TitleWithSlugInput::make('title')
7170 ->titleLabel(__('core::core.title'))
7271 ->slugLabel(__('core::core.slug'))
@@ -102,8 +101,8 @@ public static function form(Form $form): Form
102101 ->color ('success ' )
103102 ->button ()
104103 ->extraAttributes (['class ' => 'w-full ' ])
105- ->action (fn ($ record ) => $ record ->restore ())
106- ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof ViewItem),
104+ ->action (fn ($ record ) => $ record ->restore ())
105+ ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof ViewItem),
107106 Actions \Action::make ('save ' )
108107 ->label (__ ('core::core.save ' ))
109108 ->color ('primary ' )
@@ -112,7 +111,7 @@ public static function form(Form $form): Form
112111 ->action (function ($ livewire ) {
113112 $ livewire instanceof CreateItem ? $ livewire ->create () : $ livewire ->save ();
114113 })
115- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem || $ livewire instanceof EditItem),
114+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem || $ livewire instanceof EditItem),
116115 Actions \Action::make ('publish ' )
117116 ->label (__ ('core::core.publish ' ))
118117 ->color ('success ' )
@@ -126,7 +125,7 @@ public static function form(Form $form): Form
126125 $ livewire ->form ->fill ($ data );
127126 $ livewire instanceof CreateItem ? $ livewire ->create () : $ livewire ->save ();
128127 })
129- ->hidden (fn ($ livewire , $ record ) => $ record && $ record ->trashed ()),
128+ ->hidden (fn ($ livewire , $ record ) => $ record && $ record ->trashed ()),
130129 Actions \Action::make ('saveAndCreateAnother ' )
131130 ->label (__ ('core::core.save_and_create_another ' ))
132131 ->color ('secondary ' )
@@ -135,35 +134,35 @@ public static function form(Form $form): Form
135134 ->action (function ($ livewire ) {
136135 $ livewire ->saveAndCreateAnother ();
137136 })
138- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
137+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
139138 Actions \Action::make ('cancel ' )
140139 ->label (__ ('core::core.cancel ' ))
141140 ->color ('secondary ' )
142141 ->outlined ()
143142 ->extraAttributes (['class ' => 'w-full ' ])
144- ->url (fn () => static ::getUrl ('index ' ))
145- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
143+ ->url (fn () => static ::getUrl ('index ' ))
144+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
146145 Actions \Action::make ('edit ' )
147146 ->label (__ ('core::core.edit ' ))
148147 ->color ('primary ' )
149148 ->button ()
150149 ->extraAttributes (['class ' => 'w-full ' ])
151- ->url (fn ($ record ) => static ::getUrl ('edit ' , ['record ' => $ record ]))
152- ->visible (fn ($ livewire , $ record ) => $ livewire instanceof ViewItem && ! $ record ->trashed ()),
150+ ->url (fn ($ record ) => static ::getUrl ('edit ' , ['record ' => $ record ]))
151+ ->visible (fn ($ livewire , $ record ) => $ livewire instanceof ViewItem && ! $ record ->trashed ()),
153152 Actions \Action::make ('restore ' )
154153 ->label (__ ('core::core.restore ' ))
155154 ->color ('success ' )
156155 ->button ()
157156 ->extraAttributes (['class ' => 'w-full ' ])
158- ->action (fn ($ record ) => $ record ->restore ())
159- ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof EditItem),
157+ ->action (fn ($ record ) => $ record ->restore ())
158+ ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof EditItem),
160159 Actions \Action::make ('delete ' )
161160 ->label (__ ('core::core.delete ' ))
162161 ->color ('danger ' )
163162 ->link ()
164163 ->extraAttributes (['class ' => 'w-full ' ])
165- ->action (fn ($ record ) => $ record ->delete ())
166- ->visible (fn ($ livewire , $ record ) => $ record && ! $ record ->trashed () && $ livewire instanceof EditItem),
164+ ->action (fn ($ record ) => $ record ->delete ())
165+ ->visible (fn ($ livewire , $ record ) => $ record && ! $ record ->trashed () && $ livewire instanceof EditItem),
167166 ]),
168167 Select::make ('type ' )
169168 ->options (static ::getModel ()::getTypeOptions ())
@@ -175,11 +174,11 @@ public static function form(Form $form): Form
175174
176175 Select::make ('author_id ' )
177176 ->label (__ ('core::core.author ' ))
178- ->options (fn () => static ::getAuthorOptions ())
179- ->default (fn () => auth ()->id ())
177+ ->options (fn () => static ::getAuthorOptions ())
178+ ->default (fn () => auth ()->id ())
180179 ->required ()
181180 ->searchable ()
182- ->visible (fn () => static ::shouldShowAuthorField ()),
181+ ->visible (fn () => static ::shouldShowAuthorField ()),
183182 ]),
184183 // TODO: Taxonomy Plugin
185184 ])
@@ -222,22 +221,22 @@ public static function table(Table $table): Table
222221 ->toggleable (),
223222 ImageColumn::make ('author.avatar_url ' )
224223 ->label (__ ('core::core.author ' ))
225- ->tooltip (fn ($ record ) => $ record ->author ?->name)
224+ ->tooltip (fn ($ record ) => $ record ->author ?->name)
226225 ->alignment ('center ' )
227226 ->circular ()
228- ->visible (fn () => static ::shouldShowAuthorField ())
227+ ->visible (fn () => static ::shouldShowAuthorField ())
229228 ->toggleable (),
230229 TextColumn::make ('type ' )
231230 ->label (__ ('core::core.type ' ))
232231 ->visible (! empty (config ('builder.types ' )))
233- ->formatStateUsing (fn ($ record ): string => config ('builder.types ' )[$ record ->type ] ?? ucfirst ($ record ->type ))
232+ ->formatStateUsing (fn ($ record ): string => config ('builder.types ' )[$ record ->type ] ?? ucfirst ($ record ->type ))
234233 ->sortable (),
235234 TextColumn::make ('status ' )
236235 ->label (__ ('core::core.status ' ))
237236 ->alignment ('center ' )
238237 ->badge ()
239- ->formatStateUsing (fn (string $ state ): string => strtoupper ($ state ))
240- ->color (fn (string $ state ): string => match ($ state ) {
238+ ->formatStateUsing (fn (string $ state ): string => strtoupper ($ state ))
239+ ->color (fn (string $ state ): string => match ($ state ) {
241240 'draft ' => 'primary ' ,
242241 'published ' => 'success ' ,
243242 'scheduled ' => 'info ' ,
@@ -256,7 +255,7 @@ public static function table(Table $table): Table
256255 ->defaultSort ('slug ' , 'desc ' )
257256 ->actions ([
258257 ViewAction::make (),
259- EditAction::make ()->hidden (fn () => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
258+ EditAction::make ()->hidden (fn () => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
260259 ])
261260 ->bulkActions ([
262261 DeleteBulkAction::make ()->hidden (function () use ($ currentTab ) {
0 commit comments