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);
}
}