Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

saba_mdn's avatar

Implementation hasMany relation in filament not working

Hello all, I have a filament admin panel and I have a model 'Product' and another mode 'ProductProperties'. Each product could have many product properties. I used filament RelationManager to be able to manage records under product. Did the same thing as before and as mentioned in document:

php artisan make:filament-relation-manager ProductResource product_properties property

Everything is fine, I add

use app\Filament\Resources\ProductResource\RelationManagers\ProductPropertiesRelationManager;

in ProductResource and modify getRelations method as below:

public static function getRelations(): array
    {
        return [
            ProductPropertiesRelationManager::class,
        ];
    }

But I get this error when I go to admin/products/1/edit: Class "app\Filament\Resources\ProductResource\RelationManagers\ProductPropertiesRelationManager" not found

The class exists and I can link to the class in my VS Code, so the spelling and all should be fine. What should I do about it? Without this relation, admin/products/1/edit opens and functions normally. I have even tried this:

public static function getRelations(): array
    {
        return [
            RelationManagers\ProductPropertiesRelationManager::class,
        ];
    }

But when edit page opens, after a few seconds I get this error in a modal:

Unable to find component: [app.filament.resources.product-resource.relation-managers.product-properties-relation-manager]

here are my model and migration:

	Schema::create('product_properties', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('product_id');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
            $table->string('property');
            $table->string('value');
            $table->timestamps();
        });
    }
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Product extends Model
{
    protected $fillable = [
        'name',
    ];

    public function product_properties(): HasMany
    {
        return $this->hasMany(ProductProperty::class);
    }

}

0 likes
1 reply
saba_mdn's avatar
saba_mdn
OP
Best Answer
Level 1

Turns out I had it wrong:

use app\Filament\Resources\ProductResource\RelationManagers\ProductPropertiesRelationManager;

Obviously, it should be "App" and not "app" :)

and in the second case that I used:

public static function getRelations(): array
    {
        return [
            RelationManagers\ProductPropertiesRelationManager::class,
        ];
    }

the "Unable to find component: [app.filament.resources.product-resource.relation-managers.product-properties-relation-manager]" error was due to cache. I solved it by:

php artisan filament:clear-cached-components

Please or to participate in this conversation.