Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I use Easyadmin bundle for the administrative part of the web-application and I use configuration like this:

easy_admin:
  entities:
    Payment:
      class: AppEntityPayment
      controller: AppControllerCompanyController
      label: 'payments'
      list:
        item_permission: ['ROLE_ADMIN','ROLE_COMPANY_OWNER','ROLE_COMPANY_ACCOUNTANT']
        actions: ['show', '-delete', '-edit', '-new']
        collapse_actions: true
        title: 'Payments'
        filters:
          - { property: 'id', label: 'id' }
          - { property: 'type', label: 'type' }
          - { property: 'user', label: 'user' }
          ...

The problem is about I can't set filter via entity relation, like { property: 'user.company', label: 'company' }, it throws exception that property does not exist or misconfigurated. Does anybody have any idea how to solve this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

you can use Static Filters (dql_filter Option) The dql_filter option lets you define the conditions passed to the WHERE clause of the Doctrine query used to get the entities displayed in the list and search views.

for exemple

easy_admin:
    entities:
        VipCustomers:
            class: AppEntityUser
            list:
                dql_filter: 'entity.budget > 100000'
        RegularCustomers:
            class: AppEntityUser
            list:
                dql_filter: 'entity.budget <= 100000'

and in your case i think you can do something like this.

easy_admin:
  entities:
    Payment:
      class: AppEntityPayment
      controller: AppControllerCompanyController
      label: 'payments'
      list:
        item_permission: ['ROLE_ADMIN','ROLE_COMPANY_OWNER','ROLE_COMPANY_ACCOUNTANT']
        actions: ['show', '-delete', '-edit', '-new']
        collapse_actions: true
        title: 'Payments'
        dql_filter: "user.company"
           

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...