/** * Resolve the parent menu item and return it's ID. * Default to the 'root' menu item if no match can be found. * * @param $parent * @return mixed */ protected static function getParentMenuID($parent) { // Set the parent id to be root by default. $parent_id = Menu::where('name', 'root')->first()->id; // // If a string was provided, find the Menu based on that name. // if (is_string($parent)) { // $parent = Menu::where('name', $parent)->first(); // } $parent = Menu::resolve($parent); // If a Menu object was provided or found in the previous block, // return the ID of that object. if ($parent instanceof Menu) { $parent_id = $parent->id; } return $parent_id; }