Many relationship manager?
In my database I have brands and products
I have a resource called Brand, and have tried making a relationship manager for Products. However, on my Brands table I don't have any product ids, because it can have hundreds.
my products table has a brand_id column
How do i properly set up this relationship in filament? Do I need to create an in between table?
Solution:Jump to solution
php artisan make:filament-relation-manager BrandResource products name
Brand Model
```php
public function products(): HasMany...8 Replies
you can use: belongsTo -> brand in product model and set in ProductResource under $form->schema something like this and on productResource -> table->columns
now if do you want see al products that has one brand, Leandro Ferreira message can solve
this works if brand has a product id column, however if it doesnt it just says brand::product() doesn't exist or something like that.
Do you mean, product has a
brand_id
?yeah brands table doesn't have anything, relating it to products but product has brand_id.
I have a Brand resource, am trying to make it so I can click on a Brand and still list its product where brand_id = selected_id or something like that
Solution
php artisan make:filament-relation-manager BrandResource products name
Brand Model
Product Model
This worked, thank you so much, I really appreciate it!!