
PK 
https://laracasts.com/discuss/channels/eloquent/hierarchical-database-table
https://laracasts.com/discuss/channels/general-discussion/best-way-to-implement-nestedhierarchical-categories
https://itsolutionstuff.com/post/laravel-5-category-treeview-hierarchical-structure-example-with-demoexample.html
http://demo.itsolutionstuff.com/category-tree-view
https://stackoverflow.com/questions/29517615/retrieve-all-parent-child-records-from-database-on-laravel-hierarchical-data
https://github.com/etrepat/baumlaravel hierarchical data
http://www.expertphp.in/article/how-to-get-location-from-its-ip-address-using-laravel-5-4-with-example
function getIp(){
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key){
if (array_key_exists($key, $_SERVER) === true){
foreach (explode(',', $_SERVER[$key]) as $ip){
$ip = trim($ip); // just to be safe
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false){
return $ip;
}
}
}
}
}
function buildTree(array $elements, $parentId = 0) {
$branch = array();
foreach ($elements as $element) {
if ($element['parent_id'] == $parentId) {
$children = buildTree($elements, $element['id']);
if ($children) {
$element['children'] = $children;
}
$branch[] = $element;
}
}
return $branch;
}
$tree = buildTree(Model::all()->toArray());


PK 99