當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Location::getLocationHierarchy方法代碼示例

本文整理匯總了PHP中app\models\Location::getLocationHierarchy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Location::getLocationHierarchy方法的具體用法?PHP Location::getLocationHierarchy怎麽用?PHP Location::getLocationHierarchy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Location的用法示例。


在下文中一共展示了Location::getLocationHierarchy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLocationHierarchy

 public static function getLocationHierarchy($locations, $parent_id = null)
 {
     $op = array();
     foreach ($locations as $location) {
         if ($location['parent_id'] == $parent_id) {
             $op[$location['id']] = array('name' => $location['name'], 'parent_id' => $location['parent_id']);
             // Using recursion
             $children = Location::getLocationHierarchy($locations, $location['id']);
             if ($children) {
                 $op[$location['id']]['children'] = $children;
             }
         }
     }
     return $op;
 }
開發者ID:dmeltzer,項目名稱:snipe-it,代碼行數:15,代碼來源:Location.php

示例2: getEdit

 /**
  * Makes a form view to edit location information.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see LocationsController::postCreate() method that validates and stores
  * @param int $locationId
  * @since [v1.0]
  * @return View
  */
 public function getEdit($locationId = null)
 {
     // Check if the location exists
     if (is_null($location = Location::find($locationId))) {
         return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.does_not_exist'));
     }
     // Show the page
     $locations = Location::orderBy('name', 'ASC')->get();
     $location_options_array = Location::getLocationHierarchy($locations);
     $location_options = Location::flattenLocationsArray($location_options_array);
     $location_options = array('' => 'Top Level') + $location_options;
     return View::make('locations/edit', compact('location'))->with('location_options', $location_options);
 }
開發者ID:dmeltzer,項目名稱:snipe-it,代碼行數:22,代碼來源:LocationsController.php


注:本文中的app\models\Location::getLocationHierarchy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。