disableCreateButton(); $tree->disableEditButton(); if (Admin::user()->cannot('dcat.admin.permissions.create')) { $tree->disableQuickCreateButton(); } $tree->actions(function (Tree\Actions $actions) { $actions->disableEdit(Admin::user()->cannot('dcat.admin.permissions.edit')); $actions->disableDelete(Admin::user()->cannot('dcat.admin.permissions.destroy')); }); $tree->branch(function ($branch) { $branchName = htmlspecialchars($branch['name']); $branchSlug = htmlspecialchars($branch['slug']); $payload = "
{$branchName}  [{$branchSlug}]"; $path = array_filter($branch['http_path']); if (! $path) { return $payload.'
 '; } $max = 3; if (count($path) > $max) { $path = array_slice($path, 0, $max); array_push($path, '...'); } $method = $branch['http_method'] ?: []; $path = collect($path)->map(function ($path) use (&$method) { if (Str::contains($path, ':')) { [$me, $path] = explode(':', $path); $method = array_merge($method, explode(',', $me)); } if ($path !== '...' && ! empty(config('admin.route.prefix')) && ! Str::contains($path, '.')) { $path = trim(admin_base_path($path), '/'); } $color = Admin::color()->primaryDarker(); return "$path"; })->implode('  '); $method = collect($method ?: ['ANY'])->unique()->map(function ($name) { return strtoupper($name); })->map(function ($name) { return "{$name}"; })->implode(' ').' '; $payload .= "  $method$path"; return $payload; }); }); } }