@@ -58,6 +58,8 @@ public static function form(Schema $schema): Schema
5858 TitleWithSlugInput::make (
5959 fieldTitle: 'title ' ,
6060 fieldSlug: 'slug ' ,
61+ fieldPermalink: 'permalink ' ,
62+ urlPathEntityType: 'categories ' ,
6163 slugRuleUniqueParameters: [
6264 'modifyRuleUsing ' => function (Unique $ rule , $ record , $ livewire ) {
6365 $ locale = $ livewire ->lang ;
@@ -86,13 +88,13 @@ public static function form(Schema $schema): Schema
8688 relationship: 'parent ' ,
8789 titleAttribute: 'title ' ,
8890 parentAttribute: 'parent_id ' ,
89- modifyQueryUsing: fn (Builder $ query , $ get ) => $ query ->where ('id ' , '!= ' , $ get ('id ' ))
91+ modifyQueryUsing: fn (Builder $ query , $ get ) => $ query ->where ('id ' , '!= ' , $ get ('id ' ))
9092 )
9193 ->label ('Parent Category ' )
9294 ->searchable ()
93- ->disabledOptions (fn ($ get ): array => [$ get ('id ' )])
95+ ->disabledOptions (fn ($ get ): array => [$ get ('id ' )])
9496 ->enableBranchNode ()
95- ->visible (fn () => Category::count () > 0 ),
97+ ->visible (fn () => Category::count () > 0 ),
9698 ])
9799 ->columnSpan (2 ),
98100 Grid::make ()
@@ -107,16 +109,16 @@ public static function form(Schema $schema): Schema
107109 TextInput::make ('weight ' )->numeric (),
108110 TextInput::make ('count ' )
109111 ->disabled ()
110- ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
112+ ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
111113 DateTimePicker::make ('created_at ' )
112114 ->disabled ()
113- ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
115+ ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
114116 DateTimePicker::make ('updated_at ' )
115117 ->disabled ()
116- ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
118+ ->visible (fn ($ livewire , $ record ): bool => ($ record && $ livewire instanceof EditCategory) || ($ record && $ livewire instanceof ViewCategory)),
117119 DateTimePicker::make ('deleted_at ' )
118120 ->disabled ()
119- ->visible (fn ($ livewire , $ record ): bool => $ record && $ record ->trashed () && $ livewire instanceof ViewCategory),
121+ ->visible (fn ($ livewire , $ record ): bool => $ record && $ record ->trashed () && $ livewire instanceof ViewCategory),
120122 ]),
121123 ])
122124 ->columnSpan (1 )
@@ -133,7 +135,7 @@ public static function table(Table $table): Table
133135 $ currentTab = static ::getCurrentTab ();
134136
135137 return $ table
136- ->query (fn (): Builder => static ::getEloquentQuery ())
138+ ->query (fn (): Builder => static ::getEloquentQuery ())
137139 ->defaultSort ('_lft ' , 'asc ' )
138140 ->columns ([
139141 TextColumn::make ('id ' )->sortable (),
@@ -170,7 +172,7 @@ public static function table(Table $table): Table
170172 }),
171173 TextColumn::make ('level ' )
172174 ->label (__ ('category::fields.level ' ))
173- ->getStateUsing (fn (Category $ record ): int => $ record ->ancestors ->count () + 1 )
175+ ->getStateUsing (fn (Category $ record ): int => $ record ->ancestors ->count () + 1 )
174176 ->sortable ()
175177 ->toggleable (isToggledHiddenByDefault: true ),
176178 TextColumn::make ('children_count ' )
@@ -212,16 +214,16 @@ public static function table(Table $table): Table
212214 ->defaultSort ('updated_at ' , 'desc ' )
213215 ->recordActions ([
214216 ViewAction::make (),
215- EditAction::make ()->hidden (fn (): bool => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
217+ EditAction::make ()->hidden (fn (): bool => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
216218 ])
217219 ->toolbarActions ([
218- DeleteBulkAction::make ()->hidden (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
219- RestoreBulkAction::make ()->visible (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
220+ DeleteBulkAction::make ()->hidden (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
221+ RestoreBulkAction::make ()->visible (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
220222 ])
221223 ->filters ([
222224 SelectFilter::make ('parent_id ' )
223225 ->label (__ ('category::fields.parent ' ))
224- ->relationship ('parent ' , 'title ' , fn ($ query ) => $ query ->has ('children ' ))
226+ ->relationship ('parent ' , 'title ' , fn ($ query ) => $ query ->has ('children ' ))
225227 ->searchable (),
226228 SelectFilter::make ('children_count ' )
227229 ->label (__ ('category::fields.children_count ' ))
@@ -231,7 +233,7 @@ public static function table(Table $table): Table
231233 '6-10 ' => '6-10 ' ,
232234 '10+ ' => '10+ ' ,
233235 ])
234- ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ option ) {
236+ ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ option ) {
235237 switch ($ option ) {
236238 case '0 ' :
237239 return $ query ->doesntHave ('children ' );
@@ -245,8 +247,8 @@ public static function table(Table $table): Table
245247 })),
246248 SelectFilter::make ('depth ' )
247249 ->label (__ ('category::fields.level ' ))
248- ->options (fn (): array => array_combine (range (1 , 5 ), range (1 , 5 )))
249- ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ depth ): void {
250+ ->options (fn (): array => array_combine (range (1 , 5 ), range (1 , 5 )))
251+ ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ depth ): void {
250252 $ query ->whereIn ('id ' , function ($ subquery ) use ($ depth ): void {
251253 $ subquery ->select ('id ' )
252254 ->from ('categories as c ' )
@@ -257,16 +259,16 @@ public static function table(Table $table): Table
257259 ->defaultSort ('id ' , 'asc ' )
258260 ->recordActions ([
259261 ViewAction::make (),
260- EditAction::make ()->hidden (fn (): bool => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
262+ EditAction::make ()->hidden (fn (): bool => in_array (static ::getCurrentTab (), ['trash ' , 'deleted ' ])),
261263 ])
262264 ->toolbarActions ([
263- DeleteBulkAction::make ()->hidden (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
264- RestoreBulkAction::make ()->visible (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
265+ DeleteBulkAction::make ()->hidden (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
266+ RestoreBulkAction::make ()->visible (fn (): bool => in_array ($ currentTab , ['trash ' , 'deleted ' ])),
265267 ])
266268 ->filters ([
267269 SelectFilter::make ('parent_id ' )
268270 ->label (__ ('category::fields.parent ' ))
269- ->relationship ('parent ' , 'title ' , fn ($ query ) => $ query ->has ('children ' ))
271+ ->relationship ('parent ' , 'title ' , fn ($ query ) => $ query ->has ('children ' ))
270272 ->searchable (),
271273 SelectFilter::make ('children_count ' )
272274 ->label (__ ('category::fields.children_count ' ))
@@ -276,7 +278,7 @@ public static function table(Table $table): Table
276278 '6-10 ' => '6-10 ' ,
277279 '10+ ' => '10+ ' ,
278280 ])
279- ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ option ) {
281+ ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ option ) {
280282 switch ($ option ) {
281283 case '0 ' :
282284 return $ query ->doesntHave ('children ' );
@@ -290,8 +292,8 @@ public static function table(Table $table): Table
290292 })),
291293 SelectFilter::make ('depth ' )
292294 ->label (__ ('category::fields.level ' ))
293- ->options (fn (): array => array_combine (range (1 , 5 ), range (1 , 5 )))
294- ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ depth ): void {
295+ ->options (fn (): array => array_combine (range (1 , 5 ), range (1 , 5 )))
296+ ->query (fn (Builder $ query , array $ data ) => $ query ->when ($ data ['value ' ], function ($ query , $ depth ): void {
295297 $ query ->whereIn ('id ' , function ($ subquery ) use ($ depth ): void {
296298 $ subquery ->select ('id ' )
297299 ->from ('categories as c ' )
0 commit comments