DEV Community

Süleyman Özgür Özarpacı
Süleyman Özgür Özarpacı

Posted on • Edited on

7 1 1 1

How to edit FilamentPHP Relation Manager Table Query

You have to use getTableQuery method for that. This method returns Eloquent Builder or Relation class but for our situation it's going to return Builder class. So we can use that builder to add our queries.

For example i have a relation manager that must be ordered by order_column.

  • Open your relation manager file.
  • Then add this code:
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;

protected function getTableQuery(): Builder|Relation
{
    return parent::getTableQuery()->orderBy('order_column');
}
Enter fullscreen mode Exit fullscreen mode
  • Save and check.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay