function pids($sql, $sid)
{
$sql = json_decode(json_encode($sql), true);
$index = $sid;
$arr = [];
foreach ($sql as $n)
foreach ($sql as $item)
{
list($id, $pid) = array_values($item);
if ($id == $index)
{
$index = $pid;
$arr[] = $item;
}
}
return $arr;
}
$breadcrumb[] = ['name' => 'Главная', 'href' => '/'];
$breadcrumb[] = ['name' => 'Категории', 'href' => route('admin.categories')];
$categories = DB::table('categories') -> select('id') -> addSelect('categories_id') -> addSelect('categories_name') -> get();
$tmp = array_reverse(pids($categories, intval($product -> categories_id)));
foreach ($tmp as $item)
$breadcrumb[] = ['name' => $item['categories_name'], 'href' => route('admin.categories.list', ['id' => $item['id']])];