本文整理汇总了PHP中app\Location::buildTree方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::buildTree方法的具体用法?PHP Location::buildTree怎么用?PHP Location::buildTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Location
的用法示例。
在下文中一共展示了Location::buildTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('locations')->truncate();
$location = [['name' => 'Myanmar', 'pcode' => 'MMR', 'type' => 'country', 'lat' => 16.799999, 'long' => 96.150002, 'mya_name' => 'မြန်မာ', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]];
Location::buildTree($location);
//$files = [
// 'locations/Myanmar/Ayeyarwady.csv'
// ];
/**
$files = 'locations/Myanmar';
$excel = Excel::batch($files, function($rows, $file) {
$this->rows[$rows->title] = $rows->each(function($row) {});
});
$nested_set = $this->locations->merge_excel_import($this->rows);
$parent = Location::where('pcode', '=', 'MMR')->first();
//dd($parent->location);
$imported = $parent->makeTree($nested_set); // => true
*
*/
$files = 'locations/Myanmar';
$excel = Excel::batch($files, function ($rows, $file) {
$i = 5000;
Excel::filter('chunk')->load($file)->chunk(5000, function ($results) use($file, &$i) {
$row = $this->locations->arrayToNestedSet('MMR', $results);
echo "{$i} rows completed\n";
return $i += 5000;
});
echo $file . "completed\n";
//$parent = Location::where('pcode', '=', 'MMR')->first();
//$imported = $parent->makeTree($nested_set_children);
});
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例2: buildTree
public function buildTree($array)
{
return Location::buildTree($array);
}