Skip to content

Request parameters not included in Filter object pulled from DI container in Controller #30

Description

@bluesheep100
  • App Version: 2.1.0
  • PHP Version: 8.4
  • Database Driver & Version: MySQL 8.0

Steps To Reproduce

When trying to use the Filter object like so:

public function index(PostFilter $postFilter)
{
    $posts = Post::with(['media'])->filter($postFilter)->get();
    //
}

The relevant filter methods are not called, presumably because the Request object passed to PostFilter when it is created, is empty.
If I instead do the following:

public function index()
{
    $postFilter = new PostFilter(request());
    $posts = Post::with(['media'])->filter($postFilter)->get();
    //
}

This consistently functions as expected. It seems the problem is the DI container not instantiating the PostFilter object correctly.
It should not be caused by caching, as caching was disabled wherever possible for all of my testing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions