我有一个下拉列表,使用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