EasyAdmin 4-用过滤器生成URL

发布于 2025-01-23 22:07:54 字数 367 浏览 3 评论 0原文

我需要将用户重定向到CRUD索引,其中应用“ status = Active”的过滤器索引。

我已经这样做了:

$url = $this->adminUrlGenerator
            ->setController(Customer::class)

            ->generateUrl();

return $this->redirect($url);

但是我找不到向其添加过滤器的方法。我尝试搜索类似的东西:

->setFilter('Status', 'ACTIVE')

但是没有运气。文档中没有什么。怎么做?

I need to redirect my user to CRUD index where filter "STATUS = ACTIVE" is applied.

I've this:

$url = $this->adminUrlGenerator
            ->setController(Customer::class)

            ->generateUrl();

return $this->redirect($url);

But I can't find a way to add a filter to it. I've tried searching for something like:

->setFilter('Status', 'ACTIVE')

but without any luck. There is nothing in the docs. How to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屌丝范 2025-01-30 22:07:54

easyAdmin通过添加多个选项来处理每个过滤器案例,将easyAdmin处理过滤器。

  1. 进行比较
  2. (示例:value and value2之间
  3. valuevalue2 等...

通过状态过滤 活动会用

&filters[Status][comparison]=%3D&filters[Status][value]=ACTIVE

请注意,此处%3D为=为URL编码,但使用=也可以工作。

因此,使用EA Adminurlgenerator时,您可以使用- > set修改选项。

您会得到:

$url = $this->adminUrlGenerator
            ->setController(Customer::class)
            ->set('filters[Status][value]', 'ACTIVE')
            ->set('filters[Status][comparison]', '=')
            ->generateUrl();
            

我将案例保留在 s tatus上,但是如果您的财产处于小写状态,请在此处进行。

EasyAdmin handle filters in your url by adding multiple options to handle each filters case.

  1. value to be compared with
  2. value2 (Example: between value and value2)
  3. comparison for "equal", "less than", "greater than" etc...

Filtering by Status ACTIVE would modify your url with

&filters[Status][comparison]=%3D&filters[Status][value]=ACTIVE

Note that here %3D is = encoded for the url, but using = would work as well.

So when using EA AdminUrlGenerator, you can use ->set to modify options.

You would get:

$url = $this->adminUrlGenerator
            ->setController(Customer::class)
            ->set('filters[Status][value]', 'ACTIVE')
            ->set('filters[Status][comparison]', '=')
            ->generateUrl();
            

I kept the case on Status, but if your property is in lowercase, do it here as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文