Limit the entries on a table builder
Created 6 years ago by edster

I was trying to figure this out and got some help in slack.

You do this by adding the below to your table builder.

/**
     * Fired just before starting the query.
     *
     * @param Builder $query

     */
use Illuminate\Database\Eloquent\Builder;
    public function onQuerying(Builder $query)
    {
        $menu = $this->getMenu();
        $query->where('menu_id', $menu->getId());
    }
edster  —  6 years ago Best Answer

See exampe: https://github.com/anomalylabs/navigation-module/blob/2.3/src/Link/Tree/LinkTreeBuilder.php#L62

/**
     * Fired just before starting the query.
     *
     * @param Builder $query

     */
use Illuminate\Database\Eloquent\Builder;
    public function onQuerying(Builder $query)
    {
        $menu = $this->getMenu();
        $query->where('menu_id', $menu->getId());
    }