本文整理匯總了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);
}