Listing records from a custom page:

Hello I want to create a custom page for listing records only. I don't want a full resource but I only want a page to list records which will be linked to a certain resource which has already benn created, so I proceeded to create my bew resource as per docs as:
php artisan make:filament-page ActiveLoans --resource=LoanResource --type=custom
Upon creating my custom page I registered my custom page route in the `LoanResource file class under getPages as shown:
public static function getPages(): array
    {
        return [
            'active' => Pages\ActiveLoans::route('/active'),
            'index' => Pages\ListLoans::route('/'),
            'create' => Pages\CreateLoan::route('/create'),
            'view' => Pages\ViewLoan::route('/{record}'),
            'edit' => Pages\EditLoan::route('/{record}/edit'),
            
        ];
    }

I then went to my newly created custom page class component and added the following files:
<?php

namespace App\Filament\Resources\LoanResource\Pages;
use Illuminate\Support\Collection;
use App\Filament\Resources\LoanResource;
use App\Models\Loan;
use Filament\Resources\Pages\Page;

class ActiveLoans extends Page
{
    protected static string $resource = LoanResource::class;

    protected static string $view = 'filament.resources.loan-resource.pages.active-loans';


    public function getViewData(): array {
        $data = Loan::get();
    
        if ($data instanceof Collection) {
            return $data->toArray();
        }
    
       
    }
}

The corresponding laravel blade for the custom class looks like this:
<x-filament-panels::page>
    {{ $this->data }}
</x-filament-panels::page>

However each time I access my route am getting the following exception :
Property [$data] not found on component: [app.filament.resources.loan-resource.pages.active-loans]
What am I missing?
Was this page helpful?