F
Filament3mo ago
Wim

Filament resource for Markable

I'm using this package. It works well however I would like to show the favorites in Filament backend. I have a model Product. A user can mark a Product as favorite, which results in entries in the table favorites as follows:
id | user_id | markable_type | markable_id
1 | 1 | App\Models\Product | 5
2 | 1 | App\Models\Product | 6
id | user_id | markable_type | markable_id
1 | 1 | App\Models\Product | 5
2 | 1 | App\Models\Product | 6
I have the following model:
class Product extends Model
{
use HasFactory, Multitenantable, Markable;

public function favorites(): belongsToMany
{
return $this->belongsToMany(Markable::class);
}
}
class Product extends Model
{
use HasFactory, Multitenantable, Markable;

public function favorites(): belongsToMany
{
return $this->belongsToMany(Markable::class);
}
}
Ideally I have a resource called FavoriteResource which allows me to show all favorite products for that user. Any idea how this can be done, given I did not create the model Favorites (but rather using the markable package).
0 Replies
No replies yetBe the first to reply to this messageJoin