當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。