laravelfilamentphp

Error with Filament Fabricator Page Block Rendering


Problem I'm trying to build a CMS using Laravel and Filament, following the structure from Wire-Content-v2. However, I'm encountering an error when trying to render page blocks:

Z3d0X\FilamentFabricator\PageBlocks\PageBlock::preloadRelatedData(): Argument #1 ($page) must be of type Z3d0X\FilamentFabricator\Models\Contracts\Page, null given, called in /Users/admin/Herd/alayen_site/storage/framework/views/6874f6ca5f37860ea4db0a70882621cd.php on line 45

Steps to Reproduce

composer install
composer update
npm install & npm run dev

Removed the following configurations from composer.json:

"repositories": [
     {
         "type": "path",
         "url": "packages/wire-content",
         "options": {
             "symlink": true
         }
     }
 ],

And removed:

"matildevoldsen/wire-content": "@dev",

What I've Tried

php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear

What could be causing this error, and how can I solve it?


Solution

  • The issue occurs because the variable $page is undefined in the code. To fix it, update the file:

    Path: /vendor/z3d0x/filament-fabricator/resources/views/components/page-blocks.blade.php

    Original Code:

    if (!empty($blockClass)) {
        $blockClass::preloadRelatedData($page, $group);
    }
    

    Just add $this-> to the page variable so the code will be as follow:

    if (!empty($blockClass) && $page !== null) {
        $blockClass::preloadRelatedData($page, $group);
    }else if (!empty($blockClass)&& $this->page !== null) {
        $blockClass::preloadRelatedData($this->page, $group);
    }
    

    $page is undefined which causing an error. $this->page accesses the page property in the class, ensuring the data is correctly passed.