本文整理匯總了PHP中Region::makeFirstChildOf方法的典型用法代碼示例。如果您正苦於以下問題:PHP Region::makeFirstChildOf方法的具體用法?PHP Region::makeFirstChildOf怎麽用?PHP Region::makeFirstChildOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Region
的用法示例。
在下文中一共展示了Region::makeFirstChildOf方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
//.........這裏部分代碼省略.........
$regions['Victoria'] = [];
$regions['Victoria']['Central Victoria']['Bendigo'] = [];
$regions['Victoria']['Central Victoria']['Goulburn Valley']['Nagambie Lakes'] = [];
$regions['Victoria']['Central Victoria']['Heathcote'] = [];
$regions['Victoria']['Central Victoria']['Strathbogie Ranges'] = [];
$regions['Victoria']['Central Victoria']['Upper Goulburn'] = [];
$regions['Victoria']['Gippsland'] = [];
$regions['Victoria']['North East Victoria']['Alpine Valleys'] = [];
$regions['Victoria']['North East Victoria']['Beechworth'] = [];
$regions['Victoria']['North East Victoria']['Glenrowan'] = [];
$regions['Victoria']['North East Victoria']['King Valley'] = [];
$regions['Victoria']['North East Victoria']['Rutherglen'] = [];
$regions['Victoria']['North West Victoria']['Murray Darling'] = [];
$regions['Victoria']['North West Victoria']['Swan Hill'] = [];
$regions['Victoria']['Port Phillip']['Geelong'] = [];
$regions['Victoria']['Port Phillip']['Macedon Ranges'] = [];
$regions['Victoria']['Port Phillip']['Mornington Peninsula'] = [];
$regions['Victoria']['Port Phillip']['Sunbury'] = [];
$regions['Victoria']['Port Phillip']['Yarra Valley'] = [];
$regions['Victoria']['Western Victoria']['Grampians']['Great Western'] = [];
$regions['Victoria']['Western Victoria']['Henty'] = [];
$regions['Victoria']['Western Victoria']['Pyrenees'] = [];
$regions['Tasmania'] = [];
$regions['Northern Territory'] = [];
$regions['Australian Capital Territory'] = [];
foreach ($regions as $region => $children) {
$this->makeChild($country, $region, $children, $depths);
}
// ---------------------------
$new = new Region(['name' => 'South Eastern Australia', 'region_type_id' => 5]);
$new->makeLastChildOf($country);
$subzones = Region::whereIn('name', ['New South Wales', 'South Australia', 'Queensland', 'Victoria'])->get();
foreach ($subzones as $subzone) {
$subzone = new Region(['name' => $subzone->name, 'region_type_id' => 2, 'shortcut_id' => $subzone->id]);
$subzone->makeLastChildOf($new);
}
// ---------------------------
$existing = Region::whereName('South Australia')->first();
$new = new Region(['name' => 'Adelaide', 'region_type_id' => 5]);
$new->makeFirstChildOf($existing);
$subzones = Region::whereIn('name', ['Mount Lofty Ranges', 'Fleurieu', 'Barossa'])->get();
foreach ($subzones as $subzone) {
$subzone = new Region(['name' => $subzone->name, 'region_type_id' => 6, 'shortcut_id' => $subzone->id]);
$subzone->makeLastChildOf($new);
}
// ---------------------------
$existing = Region::whereName('Murray Darling')->get();
$first = $existing->first();
$last = $existing->last();
$last->shortcut_id = $first->id;
$last->save();
// ---------------------------
$existing = Region::whereName('Swan Hill')->get();
$first = $existing->first();
$last = $existing->last();
$last->shortcut_id = $first->id;
$last->save();
// ---------------------------
$depths = [1, 7, 8];
$country = new Region(['name' => 'New Zealand', 'region_type_id' => array_shift($depths)]);
$country->makeRoot();
$regions = [];
$regions["Northland"] = [];
$regions["Auckland"] = [];
$regions["Auckland"]["Waiheke Island"] = [];
$regions["Auckland"]["Henderson"] = [];
$regions["Auckland"]["Clevedon"] = [];
$regions["Auckland"]["Matakana"] = [];
$regions["Auckland"]["Kumeu"] = [];
$regions["Waikato"] = [];
$regions["Bay of Plenty"] = [];
$regions["Gisborne"] = [];
$regions["Hawke's Bay"] = [];
$regions["Hawke's Bay"]["Gimblett Gravels"] = [];
$regions["Wairarapa"] = [];
$regions["Wairarapa"]["Carterton"] = [];
$regions["Wairarapa"]["Masterton"] = [];
$regions["Wairarapa"]["South Wairarapa"] = [];
$regions["Wairarapa"]["Martinborough"] = [];
$regions["Marlborough"] = [];
$regions["Marlborough"]["Southern Valleys"] = [];
$regions["Marlborough"]["Wairau Valley"] = [];
$regions["Marlborough"]["Awatere Valley"] = [];
$regions["Nelson"] = [];
$regions["Nelson"]["Moutere"] = [];
$regions["Nelson"]["Brightwater"] = [];
$regions["Canterbury/ Waipara Valley"] = [];
$regions["Central Otago"] = [];
$regions["Central Otago"]["Wanaka"] = [];
$regions["Central Otago"]["Gibbston"] = [];
$regions["Central Otago"]["Bannockburn"] = [];
$regions["Central Otago"]["Alexandra"] = [];
$regions["Central Otago"]["Roxburgh"] = [];
$regions["Central Otago"]["Bendigo"] = [];
$regions["Central Otago"]["Lowburn/ Pisa"] = [];
$regions["Central Otago"]["Cromwell"] = [];
foreach ($regions as $region => $children) {
$this->makeChild($country, $region, $children, $depths);
}
}