php - 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
解决方案
推荐阅读
- c++ - 它说我需要的分号应该去哪里?
- nginx - NGINX反向代理未加载所有图像主页
- protocol-buffers - 您如何看待可选作为 protobuf 字段名称的前缀?
- python - 如何使用 `requests.Session` 对给定 URL 的请求进行速率限制
- .htaccess - 使用 HTACCESS 重写 URL 以获得多语言支持
- reactjs - React axios 获取返回空数组
- python-3.x - 使用 python 3.6 的图像到 osd tesseract 错误
- java - Alam Manager 并非一直在工作
- python - ubuntu中的Harvester安装错误
- python - 如何将数组放入消息中?