首页 > 解决方案 > Laravel 背包过滤器预填充下拉列表

问题描述

我有一个下拉列表,通过使用 Laravel Backpack 填充值,但我还有一些其他要求,即基于父下拉列表填充另一个下拉值。

例如,如果我选择州,城市下拉菜单应具有基于州下拉菜单(Select * from Cities where state_id = "selected_value")的预填充值

$this->crud->addFilter([
        'type' => 'select2',
        'name' => 'code',
        'label' => 'Filter',
    ],
    function() {
        return Employee::select('code')->distinct()->get()->pluck('code', 'code')->toArray();
    },
    function($value) {
        $this->crud->addClause('where', 'code', $value);
    });

我添加了过滤器,但在选择查询中,我想获取下拉列表的父值,以便我可以通过WHERE Clause

标签: phplaravellaravel-backpack

解决方案


推荐阅读