chore: code refactor via rector
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use BackedEnum;
|
||||
use UnitEnum;
|
||||
use App\Filament\Resources\CategoryResource\Pages\CreateCategory;
|
||||
use App\Filament\Resources\CategoryResource\Pages\EditCategory;
|
||||
use App\Filament\Resources\CategoryResource\Pages\ListCategories;
|
||||
@@ -26,9 +28,9 @@ class CategoryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Category::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-ticket';
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-ticket';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Content';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Content';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -37,7 +39,7 @@ class CategoryResource extends Resource
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->live(1)
|
||||
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state))),
|
||||
->afterStateUpdated(fn (Set $set, ?string $state): mixed => $set('slug', Str::slug($state))),
|
||||
TextInput::make('slug')->required(),
|
||||
Select::make('is_active')
|
||||
->options([
|
||||
@@ -58,9 +60,7 @@ class CategoryResource extends Resource
|
||||
TextColumn::make('slug'),
|
||||
TextColumn::make('blogs_count')
|
||||
->label('Blogs')
|
||||
->getStateUsing(function (Category $record): int {
|
||||
return $record->blogs()->count();
|
||||
}),
|
||||
->getStateUsing(fn(Category $record): int => $record->blogs()->count()),
|
||||
IconColumn::make('is_active')->label('Active')->boolean(),
|
||||
])
|
||||
->filters([
|
||||
@@ -73,7 +73,7 @@ class CategoryResource extends Resource
|
||||
Action::make('toggleStatus')
|
||||
->label('Toggle Status')
|
||||
->icon('heroicon-o-power')
|
||||
->action(function (Category $record) {
|
||||
->action(function (Category $record): void {
|
||||
$record->update(['is_active' => ! $record->is_active]);
|
||||
}),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user