Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’2y agoβ€’
6 replies
SirAlyon

Trouble with Relation Manager for Many-to-Many Relationship

Hello everyone, I'm experiencing issues with managing the Filament relation manager. Currently, I have two Laravel models related with a many-to-many relationship. I've followed the steps in the documentation, but I can't understand why I'm not getting any results. The manager table is not displayed in the create or edit views of the resource, and all this happens without triggering any errors. I'll paste the formatted code that's needed for reference.

I'm pretty confident the issue lies on the Filament side, as I've tested the relationship with Laravel Tinker, and it works correctly. I'm not getting any results in the edit/create views of the resource. Can anyone help me figure out what's going wrong?


KiidPdfPattern Model:
class KiidPdfPattern extends Model
{
    use HasFactory;

    public $timestamps = false;

    protected $table = 'kiid_dati_tipo';
    protected $primaryKey = 'lunivid';
    protected $guarded = [];

    public function kiidMailPdfs(): BelongsToMany
    {
        return $this->belongsToMany(KiidMailPdf::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_dati_tipo_lunivid', 'kiid_mail_pdf_lunivid');
    }
}
class KiidPdfPattern extends Model
{
    use HasFactory;

    public $timestamps = false;

    protected $table = 'kiid_dati_tipo';
    protected $primaryKey = 'lunivid';
    protected $guarded = [];

    public function kiidMailPdfs(): BelongsToMany
    {
        return $this->belongsToMany(KiidMailPdf::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_dati_tipo_lunivid', 'kiid_mail_pdf_lunivid');
    }
}


KiidMailPdf Model:
class KiidMailPdf extends Model
{
    use HasFactory;

    protected $table = 'kiid_mail_pdf';
    //protected $connection = 'palliauto';

    public $timestamps = false;
    
    protected $primaryKey = 'lunivid';
    protected $guarded = [];

    public function kiidPdfPatterns(): BelongsToMany
    {
        return $this->belongsToMany(KiidPdfPattern::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_mail_pdf_lunivid', 'kiid_dati_tipo_lunivid');
    } 
}
class KiidMailPdf extends Model
{
    use HasFactory;

    protected $table = 'kiid_mail_pdf';
    //protected $connection = 'palliauto';

    public $timestamps = false;
    
    protected $primaryKey = 'lunivid';
    protected $guarded = [];

    public function kiidPdfPatterns(): BelongsToMany
    {
        return $this->belongsToMany(KiidPdfPattern::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_mail_pdf_lunivid', 'kiid_dati_tipo_lunivid');
    } 
}


...other code in the comments! Thank you all guys! πŸ™‚
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel β€’ Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Relation manager Many to Many relationship
FilamentFFilament / β“β”Šhelp
3y ago
Many relationship manager?
FilamentFFilament / β“β”Šhelp
2y ago
Relation manager with intermediate relationship
FilamentFFilament / β“β”Šhelp
3y ago
sushi many to many relation manager
FilamentFFilament / β“β”Šhelp
2y ago