laravel-admin 中列表筛选方法

时间:2022-07-27
本文章向大家介绍laravel-admin 中列表筛选方法,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1、简单筛选

$filter- is('aid', '报警模块')- select(Alarm::all()- pluck('title', 'id'));

2、筛选联动

$filter- is('pid', '物业公司')- select(Property::all()- pluck('name', 'id'))- load('gid', '/admin/getDepartment');
$filter- is('gid', '部门')- select(PropertyDepartment::all()- pluck('name', 'id'));
/*
 * 根据物业公司的id,获取公司的部门信息
 */
public function getDepartment(Request $request){

  $pid = $request- get('q');

  return PropertyDepartment::where('pid','=', $pid)- get(['id', DB::raw('name as text')]);
}

以上这篇laravel-admin 中列表筛选方法就是小编分享给大家的全部内容了,希望能给大家一个参考。