修改导航
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Article;
|
||||
use App\Models\Patent;
|
||||
use App\Models\Talent;
|
||||
use Encore\Admin\Auth\Database\Menu;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
function getOneCategory($categoryId, $return = '')
|
||||
{
|
||||
@@ -134,3 +135,25 @@ function getCate($id, $value = '')
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取所有上级
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/2/3 13:22
|
||||
* @param $categoryId
|
||||
* @return mixed
|
||||
*/
|
||||
function getAllParentCate($categoryId): array
|
||||
{
|
||||
$res = collect();
|
||||
$parent = Category::find($categoryId);
|
||||
$res->prepend($parent);
|
||||
|
||||
while ($parent->parent_id != 0) {
|
||||
$parent = $parent->parent;
|
||||
$res->prepend($parent);
|
||||
}
|
||||
|
||||
return $res->all();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user