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


PHP Location::whereIn方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $match_departments = Session::get('match_departments');
     $allowed_departments = Session::get('allowed_departments');
     $user = Session::get('user');
     // Return locations and playlits the user can access
     $locations = Location::whereIn('department_id', $match_departments)->get();
     //$playlists = Playlist::whereIn('department_id', $match_departments)->get();
     // Get screens that the user has access to
     $screens = $this->getAllowedScreens($user, $allowed_departments);
     $data = array('screens' => $screens, 'locations' => $locations, 'user' => $user);
     return view('pages/screens', $data);
 }
开发者ID:AdaptiveAds,项目名称:AdaptiveAds,代码行数:18,代码来源:ScreenController.php

示例2: filter

 /**
  * Filter locations by criteria
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function filter(Request $request)
 {
     $locations = null;
     // Get all input vars
     $btnFindLocation = $request->input('btnFindLocation');
     $btnFindAll = $request->input('btnFindAll');
     $locationName = $request->input('txtLocationName');
     $departmentID = $request->input('drpDepartments');
     $match_departments = Session::get('match_departments');
     $locations = Location::whereIn('department_id', $match_departments)->get();
     // Check which action to perform
     if (isset($btnFindLocation)) {
         $filtered = collect([]);
         // Filter by name
         if ($locationName != null) {
             $filtered = $locations->filter(function ($item) use($locationName) {
                 if (strpos($item->name, $locationName) !== false) {
                     // Get rough match
                     return true;
                 }
             });
         }
         // Filter by department id
         if ($filtered->count() == 0) {
             $filtered = $locations->filter(function ($item) use($departmentID) {
                 if ($item->department_id == $departmentID) {
                     return true;
                 }
             });
         }
         $locations = $filtered;
     } else {
         if (isset($btnFindAll)) {
             $locationName = null;
         } else {
             abort(401, 'Unauthorized');
         }
     }
     $user = Session::get('user');
     $allowed_departments = Session::get('allowed_departments');
     $data = array('locations' => $locations, 'searchItem' => $locationName, 'user' => $user, 'allowed_departments' => $allowed_departments);
     return view('pages/locations', $data);
 }
开发者ID:AdaptiveAds,项目名称:AdaptiveAds,代码行数:48,代码来源:LocationController.php


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