F
Filamentβ€’12mo ago
Chriis

How to transform a classic resource into a simple one ?

Hi, I have a some classic resources that I created at the start of my app, but I now realized they would be better has --simple resources. How can I transform them into exactly what the --simple flag create without having to recreat them ?
2 Replies
Tobias Platen
Tobias Platenβ€’12mo ago
Removing the create/edit pages in the getPages() Methode should do the thing. You need a few changes in your Pages\List-File. A Simple-Resource has an manage-file instead of an list file. Just change:
use Filament\Resources\Pages\ListRecords;

class ListResource extends ListRecords
use Filament\Resources\Pages\ListRecords;

class ListResource extends ListRecords
to
use Filament\Resources\Pages\ManageRecords;

class ListResource extends ManageRecords
use Filament\Resources\Pages\ManageRecords;

class ListResource extends ManageRecords
If you want change your Class- and filename from List to Manage. Then you need to change the Names in the getPages() Method too. One more difference is in the Table Actions. Basically a simple resource has an DeleteAction in it.
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
Last thing is the getRelations()-Methode. A simple-resource hasnt this method. Remove it in your Resourcefile.
Chriis
ChriisOPβ€’12mo ago
Ok thanks a lot πŸ™‚
Want results from more Discord servers?
Add your server