当前位置: 首页>>代码示例>>PHP>>正文


PHP Department::whereIn方法代码示例

本文整理汇总了PHP中app\Department::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::whereIn方法的具体用法?PHP Department::whereIn怎么用?PHP Department::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Department的用法示例。


在下文中一共展示了Department::whereIn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter

 /**
  * Filters departments by criteria
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function filter(Request $request)
 {
     $departments = null;
     $user = Session::get('user');
     $match_departments = Session::get('match_departments');
     // Get all inputs from request
     $btnFindDepartment = $request->input('btnFindDepartment');
     $btnFindAll = $request->input('btnFindAll');
     $departmentName = $request->input('txtDepartmentSearch');
     $match_departments = Session::get('match_departments');
     $departments = Department::whereIn('id', $match_departments)->get();
     // Check which action to perform
     if (isset($btnFindDepartment)) {
         $filtered = collect([]);
         // Filter by name
         if ($departmentName != null) {
             $filtered = $departments->filter(function ($item) use($departmentName) {
                 if (strpos($item->name, $departmentName) !== false) {
                     // Get rough match
                     return true;
                 }
             });
         }
         $departments = $filtered;
     } else {
         if (isset($btnFindAll)) {
             // Get all departments and clear search string
             $departmentName = null;
             //$departments = Department::all();
         } else {
             abort(401, 'Unauthorized');
         }
     }
     $data = array('departments' => $departments, 'departmentName' => $departmentName, 'user' => $user);
     return view('pages/departments', $data);
 }
开发者ID:AdaptiveAds,项目名称:AdaptiveAds,代码行数:41,代码来源:DepartmentController.php


注:本文中的app\Department::whereIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。