So, I just want to make a simple query for my voting extension that gives me all the votes with a certain discussion_id. Nothing complicated, but I'm struggling with it.

I've created a filter:

class VotesByDiscussionIdFilter implements FilterInterface
{

    public function getFilterKey(): string
    {
        return 'discussionId';
    }

    public function filter(FilterState $filterState, string $filterValue, bool $negate): void
    {
        $filterState
            ->getQuery()
            ->where('discussion_id', '=', $filterValue);
    }
}

in the extend.php file I've added:

    (new Extend\Filter(HereShouldBeAFilterer?::class))
        ->addFilter(VotesByDiscussionIdFilter::class, 'mbl-featured-projects-votes')

Then this should also be implemented in the controller. I'm taking a look at the code mentioned in the documentation
here

And then there's also something called "Filterers" that I'm trying to find information on. This is probably where I'm stuck at the moment.

For something very simple, there's a lot to take in. It's probably just me not fully used to the platform yet.

    MikeLundahl can you describe the syntax for the REST endpoint you are trying to create ? Will it return models for a class you created or from another extension ?

    The filterer system is meant for extensions to make their endpoints extendable by other extensions. If you are writing a self-contained extension, you can write the entire query (using the Laravel database query builder) inside the controller and directly read parameters from the URL or payload.

      clarkwinkelmann Thanks for the reply Clark!

      Yes, for now, it's to be self-contained. My needs right now are super simple. A component on the frontend just want to get all the votes with a certain discussion_id stored in the votes table I created.

      Is there any good and simple example? I'll read more about the Laravel database query builder you mentioned.

      btw, I love your videos, Clark! They are very helpful.

        luceos Fantastic! Thanks!

        The simplicity of that was more what I was looking for.

        Strangely though, this is how I get the data from the frontend
        app.store.find('featured-projects-vote', {filter: {discussionId: discussionId}})

        But that returned 0 records.

        However if I remove the "filter" then it works.
        app.store.find('featured-projects-vote', {discussionId: discussionId})

        Looking at the moderator notes example, the frontend component. It seems the "filter" property is not needed.
        However my IDE (PHPStorm) complains with the following Argument type  { discussionId }  is not assignable to parameter type  ApiQueryParamsSingle | undefined