Polymorphic Relationships https://laravel.com/docs/11.x/eloquent-relationships#polymorphic-relationships
Or try union, should be very ease while the tables' structure is the same https://laravel.com/docs/11.x/queries#unions
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello friends
I am developing a project with filament. There is an issue I am stuck.
I have relationships named cashMovements, bankMovements and bondMovements in my Customer model;
public function cashMovements()
{
return $this->hasMany(CustomerCashMovement::class, 'customer_account_id');
}
public function bankMovements()
{
return $this->hasMany(CustomerBankMovement::class, 'customer_account_id');
}
public function bondMovements()
{
return $this->hasMany(CustomerBondMovement::class, 'customer_account_id');
}
The database of these relationships is exactly the same. For 3 relationships I need to set up a separate relationship manager but this is not enough. The 3 relationships need to be listed by date in a single table. My purpose here is to show the customer's cash, bank and bond movements financially.
But somehow I could not combine these two in a single table.
Is there a way to do this? In addition, I think this merge need will be 5 pieces in the future.
Polymorphic Relationships https://laravel.com/docs/11.x/eloquent-relationships#polymorphic-relationships
Or try union, should be very ease while the tables' structure is the same https://laravel.com/docs/11.x/queries#unions
Please or to participate in this conversation.