#https://filamentphp.com/docs/4.x/tables/custom-data on Resource needs $record of type Model

16 messages · Page 1 of 1 (latest)

karmic frost
#

in filament/filament/src/Resources/Pages/ListRecord.php

on line 129:

->recordAction(function (Model $record, Table $table): ?string {

and on line 162:

if (! $table->hasCustomRecordUrl()) {
    $table->recordUrl(function (Model $record, Table $table): ?string {

still only accepts a "Model". but when using "custom data" as per documentation. the return type of a record is an array. so it should be

(Model|array $record, Table $table)

or do i need to do something else so it behaves like a "Model".?

vocal saffronBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

zealous crypt
karmic frost
karmic frost
zealous crypt
karmic frost
#

Anyway, when just adding this Model|array it also works in resources.

zealous crypt
karmic frost
zealous crypt
karmic frost
karmic frost
#

@zealous crypt maybe for the Actions added to the table or headerActions it needs a Model type (not sure)... but i do see that the Trait InteractsWithRecord also accepts an array as record on many functions.. getRecord() , record(), ensureCorrectRecordType(), resolveRecordKey()

#

also i see when adding

public static function getPages(): array
{
        return [
            'index' => Pages\ListAccounts::route('/'),
            'edit' => Pages\EditAccount::route('/{record}'),
            'create' => Pages\CreateAccount::route('/create'),
        ];
    }

then in ListRecords.php line 202
i also get this problem:

  if (! $resource::{'can' . ucfirst($action)}($record)) {
                        continue;
                    }

so better convert my resource to a simple Page. anyway thanks for clarification. i just thought creating a resource which can CRUD in sync with an API instead of a Model would this (using a Resource) be the better way.

zealous crypt