F
Filament2mo ago
Franky

Resource broke after downgrade from v4 to v3

Hello, I just started using filament, I am creating a API, every single page must be translated in multiple languages: english, italian, german, etc. I downloaded v4, I just downgraded to v3 (v4 is just too new and I needed this plugin: https://v2.filamentphp.com/plugins/language-switch) I attached a picture of the "pages" table and a picture of the "pages" admin view, as you can see the titles are missing, this is my PageResource class:
class PageResource extends Resource
{
protected static ?string $model = Page::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
TextInput::make('title')
->required()
->label('Nome della pagina'),
Builder::make('content')
->label('Contenuto')
->blocks([
Block::make('heading')
->label('Intestazione')
->schema([
TextInput::make('title')
->label('Titolo')
->required(),
]),
Block::make('paragraph')
->label('Contenuto')
->schema([
RichEditor::make('content')
->label('Paragraph')
->required(),
]),
Block::make('image')
->label('Immagine')
->schema([
FileUpload::make('url')
->label('Image')
->image()
->required(),
]),
Block::make('repeater')
->label('Ripetore')
->schema([
Repeater::make('members')
->schema([
TextInput::make('name')->required(),
Select::make('role')
->options([
'member' => 'Member',
'administrator' => 'Administrator',
'owner' => 'Owner',
])
->required(),
])
->columns(2)
]),
])
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListPages::route('/'),
'create' => Pages\CreatePage::route('/create'),
'edit' => Pages\EditPage::route('/{record}/edit'),
];
}
}
class PageResource extends Resource
{
protected static ?string $model = Page::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
TextInput::make('title')
->required()
->label('Nome della pagina'),
Builder::make('content')
->label('Contenuto')
->blocks([
Block::make('heading')
->label('Intestazione')
->schema([
TextInput::make('title')
->label('Titolo')
->required(),
]),
Block::make('paragraph')
->label('Contenuto')
->schema([
RichEditor::make('content')
->label('Paragraph')
->required(),
]),
Block::make('image')
->label('Immagine')
->schema([
FileUpload::make('url')
->label('Image')
->image()
->required(),
]),
Block::make('repeater')
->label('Ripetore')
->schema([
Repeater::make('members')
->schema([
TextInput::make('name')->required(),
Select::make('role')
->options([
'member' => 'Member',
'administrator' => 'Administrator',
'owner' => 'Owner',
])
->required(),
])
->columns(2)
]),
])
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListPages::route('/'),
'create' => Pages\CreatePage::route('/create'),
'edit' => Pages\EditPage::route('/{record}/edit'),
];
}
}
Where did I go wrong? 😅
No description
No description
5 Replies
Franky
FrankyOP2mo ago
update: - i dropped the pages table - removed the row relative to the migration - created the migration from scratch - ran the migration - created a new page didn't work😭
awcodes
awcodes2mo ago
Is this the actual code of your resource? You don’t have any columns specified in the table.
Franky
FrankyOP2mo ago
it is when i create a page from the admin panel it creates the record
awcodes
awcodes2mo ago
Right but there’s no ->columns() in the table method. That’s why it’s not showing anything in the list page screen shot you shared.
Franky
FrankyOP2mo ago
that is 1 to 1 what i had with filament v4 and it used to work, i'll try you were right... I made a mistake in the table method from the PageResource object. I called the columns method on the $table object
return $table->columns([
TextColumn::make('title')
->label('Nome della pagina')
->searchable()
])
...
return $table->columns([
TextColumn::make('title')
->label('Nome della pagina')
->searchable()
])
...

Did you find this page helpful?