Laravel背包过滤器预填充下拉菜单

时间:2019-08-27 08:31:37

标签: php laravel backpack-for-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

0 个答案:

没有答案