edster - 11 months ago

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());
    }

Answer

edster - 11 months ago

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());
    }

edster - 11 months ago

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());
    }