F
Filament4mo ago
topan

Relation Managers

why relation managers not working? I use the command: php artisan make:filament-relation-manager ProductResource categories name Product Model
public function categories(): HasMany
{
return $this->hasMany(Category::class);
}
public function categories(): HasMany
{
return $this->hasMany(Category::class);
}
Category Model
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
ProductResource.php
public static function getRelations(): array
{
return [
ProductCategoriesRelationManager::class,
];
}
public static function getRelations(): array
{
return [
ProductCategoriesRelationManager::class,
];
}
No description
3 Replies
Melomancheto
Melomancheto4mo ago
Because you are creating resource. When you create the resource go into the resource and you will see it. It's not shown on listing and creating. Also make sure you have set the correct relation within ProductCategoriesRelationManager
topan
topanOP4mo ago
@Melomancheto I don't understand about that. If both have the same hasMany relationship, what happens? Tag Model
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
Product Model
public function tags(): HasMany
{
return $this->hasMany(Tags::class);
}
public function tags(): HasMany
{
return $this->hasMany(Tags::class);
}
LeandroFerreira
LeandroFerreira4mo ago
Relation managers are interactive tables that allow administrators to list, create, attach, associate, edit, detach, dissociate and delete related records without leaving the resource's Edit or View page.

Did you find this page helpful?