What is the best way to limit the returned entries for a tableBuilder
Created 7 years ago by edster

I have a table builder for a stream called access. This stream has a user relation to it.

When you load up the table builder, I only want to return those access entries for that user to show up.

What is the best way to do that? Keep in mind I have other table builders that will need different type of content limitations done, so looking at the best overall implementation strategy for things like this.

Thanks!

edster  —  7 years ago Best Answer

Suggestion from failcookie

/**
     * Fired just before querying
     * for table entries.
     */
    public function onQuerying(Builder $query, Request $request)
    {
        $query->where('user_id', $request->route()->parameter('userid'));
    }
ryanthompson  —  7 years ago

Yep the onQuerying is the best spot to do that - then set data on your table you'll need in there accordingly.

ryanthompson  —  7 years ago

I add setters/getters and an attribute sometimes for stuff like this just for an API doc'd paper trail.

edster  —  7 years ago

Awesome thanks guys!