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


PHP Location::flattenLocationsArray方法代码示例

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


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

示例1: flattenLocationsArray

 public static function flattenLocationsArray($location_options_array = null)
 {
     $location_options = array();
     foreach ($location_options_array as $id => $value) {
         // get the top level key value
         $location_options[$id] = $value['name'];
         // If there is a key named children, it has child locations and we have to walk it
         if (array_key_exists('children', $value)) {
             foreach ($value['children'] as $child_id => $child_location_array) {
                 $child_location_options = Location::flattenLocationsArray($value['children']);
                 foreach ($child_location_options as $child_id => $child_name) {
                     $location_options[$child_id] = '--' . $child_name;
                 }
             }
         }
     }
     return $location_options;
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:18,代码来源: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::flattenLocationsArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。