ajsmith_codes
1 month ago
199
4
Laravel

Help with filter using pipelines. Laravel 7

Posted 1 month ago by ajsmith_codes

I set up filters using the Laravel pipeline and it works great with sorting string data, but it doesn't work with dates. Any ideas as to why?

Here is a tutorial that is similar to what I did:

https://www.codechief.org/article/laravel-pipeline-interpretation-with-example

Model:

    return $orders = app(Pipeline::class)
        ->send(Order::query())
        ->through([
            \App\QueryFilters\Active::class,
            \App\QueryFilters\SortOrders::class,
            \App\QueryFilters\MaxCount::class
        ])
        ->thenReturn()->paginate(5);

Main Filter class:

    if (! request()->has($this->filterName())) {

        return $next($request);

    }

    $builder = $next($request);


    return $this->applyFilter($builder);


    return $builder->where('active', request('active'));

SortOrders class that extends Filter:

return $builder->orderBy('requested_ship_date', request($this->filterName()));

Please sign in or create an account to participate in this conversation.