11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Moox \Builder \Resources ;
46
5- use Camya \ Filament \Forms \Components \ TitleWithSlugInput ;
6- use Filament \Forms \ Components \ Actions ;
7- use Filament \ Forms \ Components \ DateTimePicker ;
8- use Filament \Forms \ Components \ FileUpload ;
7+ use Filament \Forms \Form ;
8+ use Filament \Tables \ Table ;
9+ use Moox \ Builder \ Models \ Item ;
10+ use Filament \Resources \ Resource ;
911use Filament \Forms \Components \Grid ;
10- use Filament \Forms \Components \MarkdownEditor ;
11- use Filament \Forms \Components \Section ;
1212use Filament \Forms \Components \Select ;
13+ use Filament \Forms \Components \Actions ;
14+ use Filament \Forms \Components \Section ;
1315use Filament \Forms \Components \Textarea ;
14- use Filament \Forms \Form ;
15- use Filament \Resources \Resource ;
16- use Filament \Tables \Actions \DeleteBulkAction ;
1716use Filament \Tables \Actions \EditAction ;
18- use Filament \Tables \Actions \RestoreBulkAction ;
1917use Filament \Tables \Actions \ViewAction ;
20- use Filament \Tables \Columns \ImageColumn ;
2118use Filament \Tables \Columns \TextColumn ;
19+ use Filament \Tables \Columns \ImageColumn ;
20+ use Filament \Forms \Components \FileUpload ;
2221use Filament \Tables \Filters \SelectFilter ;
23- use Filament \Tables \Table ;
2422use Illuminate \Database \Eloquent \Builder ;
23+ use Filament \Forms \Components \DateTimePicker ;
24+ use Filament \Forms \Components \MarkdownEditor ;
25+ use Filament \Tables \Actions \DeleteBulkAction ;
2526use Illuminate \Database \Eloquent \SoftDeletes ;
26- use Moox \ Builder \ Models \ Item ;
27- use Moox \ Builder \ Resources \ ItemResource \ Pages \ CreateItem ;
27+ use Filament \ Tables \ Actions \ RestoreBulkAction ;
28+ use Camya \ Filament \ Forms \ Components \ TitleWithSlugInput ;
2829use Moox \Builder \Resources \ItemResource \Pages \EditItem ;
29- use Moox \Builder \Resources \ItemResource \Pages \ListItem ;
3030use Moox \Builder \Resources \ItemResource \Pages \ViewItem ;
31+ use Moox \Builder \Resources \ItemResource \Pages \ListItems ;
32+ use Moox \Builder \Resources \ItemResource \Pages \CreateItem ;
3133use Moox \Builder \Resources \ItemResource \Widgets \ItemWidgets ;
3234
3335//use Moox\Core\Forms\Components\TitleWithSlugInput;
@@ -64,17 +66,18 @@ public static function form(Form $form): Form
6466 fieldSlug: 'slug ' , // The name of the field in your model that will store the slug.
6567 ),
6668
67- /*
68- ... TitleWithSlugInput::make('title')
69+
70+ /* TitleWithSlugInput::make('title')
6971 ->titleLabel(__('core::core.title'))
7072 ->slugLabel(__('core::core.slug'))
71- ->showSlugInput(fn ($record) => ! $record ||
72- (config('builder.allow_slug_change_after_saved') || ! $record->exists) &&
73- (config('builder.allow_slug_change_after_publish') || ! $record->published_at)
73+ ->showSlugInput(
74+ fn($record) => ! $record ||
75+ (config('builder.allow_slug_change_after_saved') || ! $record->exists) &&
76+ (config('builder.allow_slug_change_after_publish') || ! $record->published_at)
7477 )
75- ->slugPrefix(url('/'). '/'. config('builder.url_slug', 'items/'))
76- ->components(),
77- */
78+ ->slugPrefix(url('/') . '/' . config('builder.url_slug', 'items/'))
79+ ->components(),*/
80+
7881 FileUpload::make ('featured_image_url ' )
7982 ->label (__ ('core::core.featured_image_url ' )),
8083 MarkdownEditor::make ('content ' )
@@ -99,8 +102,8 @@ public static function form(Form $form): Form
99102 ->color ('success ' )
100103 ->button ()
101104 ->extraAttributes (['class ' => 'w-full ' ])
102- ->action (fn ($ record ) => $ record ->restore ())
103- ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof ViewItem),
105+ ->action (fn ($ record ) => $ record ->restore ())
106+ ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof ViewItem),
104107 Actions \Action::make ('save ' )
105108 ->label (__ ('core::core.save ' ))
106109 ->color ('primary ' )
@@ -109,7 +112,7 @@ public static function form(Form $form): Form
109112 ->action (function ($ livewire ) {
110113 $ livewire instanceof CreateItem ? $ livewire ->create () : $ livewire ->save ();
111114 })
112- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem || $ livewire instanceof EditItem),
115+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem || $ livewire instanceof EditItem),
113116 Actions \Action::make ('publish ' )
114117 ->label (__ ('core::core.publish ' ))
115118 ->color ('success ' )
@@ -123,7 +126,7 @@ public static function form(Form $form): Form
123126 $ livewire ->form ->fill ($ data );
124127 $ livewire instanceof CreateItem ? $ livewire ->create () : $ livewire ->save ();
125128 })
126- ->hidden (fn ($ livewire , $ record ) => $ record && $ record ->trashed ()),
129+ ->hidden (fn ($ livewire , $ record ) => $ record && $ record ->trashed ()),
127130 Actions \Action::make ('saveAndCreateAnother ' )
128131 ->label (__ ('core::core.save_and_create_another ' ))
129132 ->color ('secondary ' )
@@ -132,35 +135,35 @@ public static function form(Form $form): Form
132135 ->action (function ($ livewire ) {
133136 $ livewire ->saveAndCreateAnother ();
134137 })
135- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
138+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
136139 Actions \Action::make ('cancel ' )
137140 ->label (__ ('core::core.cancel ' ))
138141 ->color ('secondary ' )
139142 ->outlined ()
140143 ->extraAttributes (['class ' => 'w-full ' ])
141- ->url (fn () => static ::getUrl ('index ' ))
142- ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
144+ ->url (fn () => static ::getUrl ('index ' ))
145+ ->visible (fn ($ livewire ) => $ livewire instanceof CreateItem),
143146 Actions \Action::make ('edit ' )
144147 ->label (__ ('core::core.edit ' ))
145148 ->color ('primary ' )
146149 ->button ()
147150 ->extraAttributes (['class ' => 'w-full ' ])
148- ->url (fn ($ record ) => static ::getUrl ('edit ' , ['record ' => $ record ]))
149- ->visible (fn ($ livewire , $ record ) => $ livewire instanceof ViewItem && ! $ record ->trashed ()),
151+ ->url (fn ($ record ) => static ::getUrl ('edit ' , ['record ' => $ record ]))
152+ ->visible (fn ($ livewire , $ record ) => $ livewire instanceof ViewItem && ! $ record ->trashed ()),
150153 Actions \Action::make ('restore ' )
151154 ->label (__ ('core::core.restore ' ))
152155 ->color ('success ' )
153156 ->button ()
154157 ->extraAttributes (['class ' => 'w-full ' ])
155- ->action (fn ($ record ) => $ record ->restore ())
156- ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof EditItem),
158+ ->action (fn ($ record ) => $ record ->restore ())
159+ ->visible (fn ($ livewire , $ record ) => $ record && $ record ->trashed () && $ livewire instanceof EditItem),
157160 Actions \Action::make ('delete ' )
158161 ->label (__ ('core::core.delete ' ))
159162 ->color ('danger ' )
160163 ->link ()
161164 ->extraAttributes (['class ' => 'w-full ' ])
162- ->action (fn ($ record ) => $ record ->delete ())
163- ->visible (fn ($ livewire , $ record ) => $ record && ! $ record ->trashed () && $ livewire instanceof EditItem),
165+ ->action (fn ($ record ) => $ record ->delete ())
166+ ->visible (fn ($ livewire , $ record ) => $ record && ! $ record ->trashed () && $ livewire instanceof EditItem),
164167 ]),
165168 Select::make ('type ' )
166169 ->options (static ::getModel ()::getTypeOptions ())
@@ -172,11 +175,11 @@ public static function form(Form $form): Form
172175
173176 Select::make ('author_id ' )
174177 ->label (__ ('core::core.author ' ))
175- ->options (fn () => static ::getAuthorOptions ())
176- ->default (fn () => auth ()->id ())
178+ ->options (fn () => static ::getAuthorOptions ())
179+ ->default (fn () => auth ()->id ())
177180 ->required ()
178181 ->searchable ()
179- ->visible (fn () => static ::shouldShowAuthorField ()),
182+ ->visible (fn () => static ::shouldShowAuthorField ()),
180183 ]),
181184 // TODO: Taxonomy Plugin
182185 ])
@@ -219,22 +222,22 @@ public static function table(Table $table): Table
219222 ->toggleable (),
220223 ImageColumn::make ('author.avatar_url ' )
221224 ->label (__ ('core::core.author ' ))
222- ->tooltip (fn ($ record ) => $ record ->author ?->name)
225+ ->tooltip (fn ($ record ) => $ record ->author ?->name)
223226 ->alignment ('center ' )
224227 ->circular ()
225- ->visible (fn () => static ::shouldShowAuthorField ())
228+ ->visible (fn () => static ::shouldShowAuthorField ())
226229 ->toggleable (),
227230 TextColumn::make ('type ' )
228231 ->label (__ ('core::core.type ' ))
229232 ->visible (! empty (config ('builder.types ' )))
230- ->formatStateUsing (fn ($ record ): string => config ('builder.types ' )[$ record ->type ] ?? ucfirst ($ record ->type ))
233+ ->formatStateUsing (fn ($ record ): string => config ('builder.types ' )[$ record ->type ] ?? ucfirst ($ record ->type ))
231234 ->sortable (),
232235 TextColumn::make ('status ' )
233236 ->label (__ ('core::core.status ' ))
234237 ->alignment ('center ' )
235238 ->badge ()
236- ->formatStateUsing (fn (string $ state ): string => strtoupper ($ state ))
237- ->color (fn (string $ state ): string => match ($ state ) {
239+ ->formatStateUsing (fn (string $ state ): string => strtoupper ($ state ))
240+ ->color (fn (string $ state ): string => match ($ state ) {
238241 'draft ' => 'primary ' ,
239242 'published ' => 'success ' ,
240243 'scheduled ' => 'info ' ,
@@ -253,7 +256,7 @@ public static function table(Table $table): Table
253256 ->defaultSort ('slug ' , 'desc ' )
254257 ->actions ([
255258 ViewAction::make (),
256- EditAction::make ()->hidden (fn () => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
259+ EditAction::make ()->hidden (fn () => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
257260 ])
258261 ->bulkActions ([
259262 DeleteBulkAction::make ()->hidden (function () use ($ currentTab ) {
@@ -284,7 +287,7 @@ public static function getRelations(): array
284287 public static function getPages (): array
285288 {
286289 return [
287- 'index ' => ListItem ::route ('/ ' ),
290+ 'index ' => ListItems ::route ('/ ' ),
288291 'edit ' => EditItem::route ('/{record}/edit ' ),
289292 'create ' => CreateItem::route ('/create ' ),
290293 'view ' => ViewItem::route ('/{record} ' ),
0 commit comments