$trail->push(''.trans('general.dashboard').'', route('home')) ); /** * Asset Breadcrumbs */ if ((request()->is('hardware*')) && (request()->status_type != '')) { Breadcrumbs::for('hardware.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.assets'), route('hardware.index')) ->push(trans('general.'.strtolower(e(request()->status_type))), route('hardware.index', ['status_type' => request()->status_type])) ); } else { Breadcrumbs::for('hardware.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.assets'), route('hardware.index')) ); } Breadcrumbs::for('hardware.create', fn (Trail $trail) => $trail->parent('hardware.index', route('hardware.index')) ->push(trans('general.create'), route('hardware.create')) ); Breadcrumbs::for('clone/hardware', fn (Trail $trail) => $trail->parent('hardware.index', route('hardware.index')) ->push(trans('admin/hardware/general.clone'), route('hardware.create')) ); Breadcrumbs::for('hardware.show', fn (Trail $trail, Asset $asset) => $trail->parent('hardware.index', route('hardware.index')) ->push($asset->display_name, route('hardware.show', $asset)) ); Breadcrumbs::for('hardware.edit', fn (Trail $trail, Asset $asset) => $trail->parent('hardware.index', route('hardware.index')) ->push($asset->display_name, route('hardware.show', $asset)) ->push(trans('general.update')) ); /** * Asset Model Breadcrumbs */ if ((request()->is('models*')) && (request()->status == 'deleted')) { Breadcrumbs::for('models.index', fn (Trail $trail) => $trail->parent('hardware.index', route('hardware.index')) ->push(trans('general.asset_models'), route('models.index')) ->push(trans('general.deleted_models'), route('models.index', ['status' => request()->status])) ); } else { Breadcrumbs::for('models.index', fn (Trail $trail) => $trail->parent('hardware.index', route('hardware.index')) ->push(trans('general.asset_models'), route('models.index')) ); } Breadcrumbs::for('models.create', fn (Trail $trail) => $trail->parent('models.index', route('models.index')) ->push(trans('general.create'), route('models.create')) ); Breadcrumbs::for('models.show', fn (Trail $trail, AssetModel $model) => $trail->parent('models.index', route('models.index')) ->push($model->name, route('models.show', $model)) ); Breadcrumbs::for('models.edit', fn (Trail $trail, AssetModel $model) => $trail->parent('models.index', route('models.index')) ->push($model->display_name, route('models.show', $model)) ->push(trans('general.update')) ); /** * Accessories Breadcrumbs */ Breadcrumbs::for('accessories.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.accessories'), route('accessories.index')) ); Breadcrumbs::for('accessories.create', fn (Trail $trail) => $trail->parent('accessories.index', route('accessories.index')) ->push(trans('general.create'), route('accessories.create')) ); Breadcrumbs::for('accessories.show', fn (Trail $trail, Accessory $accessory) => $trail->parent('accessories.index', route('accessories.index')) ->push($accessory->name, route('accessories.show', $accessory)) ); Breadcrumbs::for('accessories.edit', fn (Trail $trail, Accessory $accessory) => $trail->parent('accessories.index', route('accessories.index')) ->push($accessory->display_name, route('accessories.show', $accessory)) ->push(trans('general.update')) ); Breadcrumbs::for('accessories.checkout.show', fn (Trail $trail, Accessory $accessory) => $trail->parent('accessories.show', $accessory) ->push(trans('general.checkout')) ); Breadcrumbs::for('accessories.checkin.show', function (Trail $trail, int $accessoryID) { $checkout = AccessoryCheckout::find($accessoryID); $accessory = $checkout ? Accessory::find($checkout->accessory_id) : null; $trail->parent('accessories.index'); if ($accessory) { $trail->push($accessory->name, route('accessories.show', $accessory)); } $trail->push(trans('general.checkin')); }); Breadcrumbs::for('clone/accessories', fn (Trail $trail, Accessory $accessory) => $trail->parent('accessories.show', $accessory) ->push(trans('general.clone')) ); /** * Categories Breadcrumbs */ Breadcrumbs::for('categories.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.categories'), route('categories.index')) ); Breadcrumbs::for('categories.create', fn (Trail $trail) => $trail->parent('categories.index', route('categories.index')) ->push(trans('general.create'), route('categories.create')) ); Breadcrumbs::for('categories.show', fn (Trail $trail, Category $category) => $trail->parent('categories.index', route('categories.index')) ->push($category->name, route('categories.show', $category)) ); Breadcrumbs::for('categories.edit', fn (Trail $trail, Category $category) => $trail->parent('categories.index', route('categories.index')) ->push($category->display_name, route('categories.show', $category)) ->push(trans('general.update')) ); /** * Company Breadcrumbs */ Breadcrumbs::for('companies.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.companies'), route('companies.index')) ); Breadcrumbs::for('companies.create', fn (Trail $trail) => $trail->parent('companies.index', route('companies.index')) ->push(trans('general.create'), route('companies.create')) ); Breadcrumbs::for('companies.show', fn (Trail $trail, Company $company) => $trail->parent('companies.index', route('companies.index')) ->push($company->name, route('companies.show', $company)) ); Breadcrumbs::for('companies.edit', fn (Trail $trail, Company $company) => $trail->parent('companies.index', route('companies.index')) ->push($company->display_name, route('companies.show', $company)) ->push(trans('general.update')) ); /** * Components Breadcrumbs */ Breadcrumbs::for('components.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.components'), route('components.index')) ); Breadcrumbs::for('components.create', fn (Trail $trail) => $trail->parent('components.index', route('components.index')) ->push(trans('general.create'), route('components.create')) ); Breadcrumbs::for('components.show', fn (Trail $trail, Component $component) => $trail->parent('components.index', route('components.index')) ->push($component->name, route('components.show', $component)) ); Breadcrumbs::for('components.edit', fn (Trail $trail, Component $component) => $trail->parent('components.index', route('components.index')) ->push($component->display_name, route('components.show', $component)) ->push(trans('general.update')) ); Breadcrumbs::for('components.clone.create', fn (Trail $trail, Component $component) => $trail->parent('components.index', route('components.index')) ->push($component->display_name, route('components.show', $component)) ->push(trans('general.clone'), route('components.create')) ); Breadcrumbs::for('components.checkout.show', function (Trail $trail, int $componentID) { $component = Component::find($componentID); $trail->parent('components.index'); if ($component) { $trail->push($component->name, route('components.show', $component)); } $trail->push(trans('general.checkout')); }); Breadcrumbs::for('components.checkin.show', function (Trail $trail, int $componentAssetId) { $componentAsset = DB::table('components_assets')->find($componentAssetId); $component = $componentAsset ? Component::find($componentAsset->component_id) : null; $trail->parent('components.index'); if ($component) { $trail->push($component->name, route('components.show', $component)); } $trail->push(trans('general.checkin')); }); /** * Consumables Breadcrumbs */ Breadcrumbs::for('consumables.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.consumables'), route('consumables.index')) ); Breadcrumbs::for('consumables.create', fn (Trail $trail) => $trail->parent('consumables.index', route('consumables.index')) ->push(trans('general.create'), route('consumables.create')) ); Breadcrumbs::for('consumables.show', fn (Trail $trail, Consumable $consumable) => $trail->parent('consumables.index', route('consumables.index')) ->push($consumable->name, route('consumables.show', $consumable)) ); Breadcrumbs::for('consumables.edit', fn (Trail $trail, Consumable $consumable) => $trail->parent('consumables.index', route('consumables.index')) ->push($consumable->display_name, route('consumables.show', $consumable)) ->push(trans('general.update')) ); Breadcrumbs::for('consumables.checkout.show', function (Trail $trail, $consumablesID) { $consumable = Consumable::find($consumablesID); $trail->parent('consumables.index'); if ($consumable) { $trail->push($consumable->name, route('consumables.show', $consumable)); } $trail->push(trans('general.checkout')); }); Breadcrumbs::for('consumables.clone.create', fn (Trail $trail, Consumable $consumable) => $trail->parent('consumables.show', $consumable) ->push(trans('general.clone')) ); /** * Custom fields Breadcrumbs */ Breadcrumbs::for('fields.index', fn (Trail $trail) => $trail->parent('models.index', route('models.index')) ->push(trans('admin/custom_fields/general.custom_fields'), route('fields.index')) ); Breadcrumbs::for('fields.create', fn (Trail $trail) => $trail->parent('fields.index', route('fields.index')) ->push(trans('general.create'), route('fields.create')) ); Breadcrumbs::for('fields.edit', fn (Trail $trail, CustomField $field) => $trail->parent('fields.index', route('fields.index')) ->push(trans('general.update')) // We skip the show section here since there isn't really a concept of fields.show ); /** * Custom fieldsets Breadcrumbs */ Breadcrumbs::for('fieldsets.create', fn (Trail $trail) => $trail->parent('fields.index', route('fields.index')) ->push(trans('admin/custom_fields/general.create_fieldset'), route('fieldsets.create')) ); Breadcrumbs::for('fieldsets.show', fn (Trail $trail, CustomFieldset $fieldset) => $trail->parent('fields.index', route('fields.index')) ->push($fieldset->name, route('fields.index')) ); Breadcrumbs::for('fieldsets.edit', fn (Trail $trail, CustomFieldset $fieldset) => $trail->parent('fields.index', route('fields.index')) ->push($fieldset->display_name, route('fieldsets.show', $fieldset)) ->push(trans('general.update')) ); /** * Department Breadcrumbs */ Breadcrumbs::for('departments.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.departments'), route('departments.index')) ); Breadcrumbs::for('departments.create', fn (Trail $trail) => $trail->parent('departments.index', route('departments.index')) ->push(trans('general.create'), route('departments.create')) ); Breadcrumbs::for('departments.show', fn (Trail $trail, Department $department) => $trail->parent('departments.index', route('departments.index')) ->push($department->name, route('home')) ); Breadcrumbs::for('departments.edit', fn (Trail $trail, Department $department) => $trail->parent('departments.index', route('departments.index')) ->push($department->display_name, route('departments.show', $department)) ->push(trans('general.update')) ); /** * Department Breadcrumbs */ Breadcrumbs::for('depreciations.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.depreciations'), route('depreciations.index')) ); Breadcrumbs::for('depreciations.create', fn (Trail $trail) => $trail->parent('depreciations.index', route('depreciations.index')) ->push(trans('general.create'), route('depreciations.create')) ); Breadcrumbs::for('depreciations.show', fn (Trail $trail, Depreciation $depreciation) => $trail->parent('depreciations.index', route('depreciations.index')) ->push($depreciation->name, route('depreciations.show', $depreciation)) ); Breadcrumbs::for('depreciations.edit', fn (Trail $trail, Depreciation $depreciation) => $trail->parent('depreciations.index', route('depreciations.index')) ->push($depreciation->display_name, route('depreciations.show', $depreciation)) ->push(trans('general.update')) ); /** * Groups Breadcrumbs */ Breadcrumbs::for('groups.index', fn (Trail $trail) => $trail->parent('settings.index', route('settings.index')) ->push(trans('general.groups'), route('groups.index')) ); Breadcrumbs::for('groups.create', fn (Trail $trail) => $trail->parent('groups.index', route('groups.index')) ->push(trans('general.create'), route('groups.create')) ); Breadcrumbs::for('groups.show', fn (Trail $trail, Group $group) => $trail->parent('groups.index', route('groups.index')) ->push($group->name, route('groups.show', $group)) ); Breadcrumbs::for('groups.edit', fn (Trail $trail, Group $group) => $trail->parent('groups.index', route('groups.index')) ->push($group->display_name, route('groups.show', $group)) ->push(trans('general.update')) ); /** * Licenses Breadcrumbs */ if ((request()->is('licenses*')) && (request()->status == 'inactive')) { Breadcrumbs::for('licenses.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.licenses'), route('licenses.index')) ->push(trans('general.show_inactive'), route('licenses.index')) ); } elseif ((request()->is('licenses*')) && (request()->status == 'expiring')) { Breadcrumbs::for('licenses.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.licenses'), route('licenses.index')) ->push(trans('general.show_expiring'), route('licenses.index')) ); } else { Breadcrumbs::for('licenses.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.licenses'), route('licenses.index')) ); } Breadcrumbs::for('licenses.create', fn (Trail $trail) => $trail->parent('licenses.index', route('licenses.index')) ->push(trans('general.create'), route('licenses.create')) ); Breadcrumbs::for('licenses.show', fn (Trail $trail, License $license) => $trail->parent('licenses.index', route('licenses.index')) ->push($license->name, route('licenses.show', $license)) ); Breadcrumbs::for('licenses.edit', fn (Trail $trail, License $license) => $trail->parent('licenses.index', route('licenses.index')) ->push($license->display_name, route('licenses.show', $license)) ->push(trans('general.update')) ); /** * Locations Breadcrumbs */ Breadcrumbs::for('locations.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.locations'), route('locations.index')) ); Breadcrumbs::for('locations.create', fn (Trail $trail) => $trail->parent('locations.index', route('locations.index')) ->push(trans('general.create'), route('locations.create')) ); Breadcrumbs::for('clone/location', fn (Trail $trail) => $trail->parent('locations.index', route('locations.index')) ->push(trans('admin/locations/table.clone'), route('locations.create')) ); Breadcrumbs::for('locations.show', function (Trail $trail, Location $location) { $trail->parent('locations.index', route('locations.index')); $this->pushLocationHierarchy($trail, $location); }); Breadcrumbs::for('locations.edit', function (Trail $trail, Location $location) { $trail->parent('locations.index', route('locations.index')); $this->pushLocationHierarchy($trail, $location); $trail->push(trans('general.update')); }); /** * Maintenances Breadcrumbs */ Breadcrumbs::for('maintenances.index', function (Trail $trail) { $trail->parent('hardware.index', route('hardware.index')) ->push(trans('general.maintenances'), route('maintenances.index')); if (request()->input('upcoming_status') === 'due') { $trail->push(trans('admin/maintenances/general.due')); } elseif (request()->input('upcoming_status') === 'overdue') { $trail->push(trans('admin/maintenances/general.overdue')); } elseif (request()->input('completed') === 'true') { $trail->push(trans('admin/maintenances/general.completed')); } }); Breadcrumbs::for('maintenances.create', fn (Trail $trail) => $trail->parent('maintenances.index', route('maintenances.index')) ->push(trans('general.create'), route('maintenances.create')) ); Breadcrumbs::for('maintenances.show', fn (Trail $trail, Maintenance $maintenance) => $trail->parent('maintenances.index', route('maintenances.index')) ->push($maintenance->name, route('maintenances.show', $maintenance)) ); Breadcrumbs::for('maintenances.edit', fn (Trail $trail, Maintenance $maintenance) => $trail->parent('maintenances.index', route('maintenances.index')) ->push($maintenance->display_name, route('maintenances.show', $maintenance)) ->push(trans('general.update')) ); /** * Manufacturers Breadcrumbs */ Breadcrumbs::for('manufacturers.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.manufacturers'), route('manufacturers.index')) ); Breadcrumbs::for('manufacturers.create', fn (Trail $trail) => $trail->parent('manufacturers.index', route('manufacturers.index')) ->push(trans('general.create'), route('manufacturers.create')) ); Breadcrumbs::for('manufacturers.show', fn (Trail $trail, Manufacturer $manufacturer) => $trail->parent('manufacturers.index', route('manufacturers.index')) ->push($manufacturer->name, route('home')) ); Breadcrumbs::for('manufacturers.edit', fn (Trail $trail, Manufacturer $manufacturer) => $trail->parent('manufacturers.index', route('manufacturers.index')) ->push($manufacturer->name, route('manufacturers.show', $manufacturer)) ->push(trans('general.update')) ); /** * Predefined Kits Breadcrumbs */ Breadcrumbs::for('kits.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.kits'), route('kits.index')) ); Breadcrumbs::for('kits.create', fn (Trail $trail) => $trail->parent('kits.index', route('kits.index')) ->push(trans('general.create'), route('kits.create')) ); Breadcrumbs::for('kits.show', fn (Trail $trail, PredefinedKit $kit) => $trail->parent('kits.index', route('kits.index')) ->push($kit->name, route('kits.show', $kit)) ); Breadcrumbs::for('kits.edit', fn (Trail $trail, PredefinedKit $kit) => $trail->parent('kits.index', route('kits.index')) ->push($kit->display_name, route('kits.show', $kit)) ->push(trans('general.update')) ); /** * Status Labels Breadcrumbs */ Breadcrumbs::for('statuslabels.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.status_labels'), route('statuslabels.index')) ); Breadcrumbs::for('statuslabels.create', fn (Trail $trail) => $trail->parent('statuslabels.index', route('statuslabels.index')) ->push(trans('general.create'), route('statuslabels.create')) ); Breadcrumbs::for('statuslabels.show', fn (Trail $trail, Statuslabel $statuslabel) => $trail->parent('statuslabels.index', route('statuslabels.index')) ->push($statuslabel->name, route('statuslabels.show', $statuslabel)) ); Breadcrumbs::for('statuslabels.edit', fn (Trail $trail, Statuslabel $statuslabel) => $trail->parent('statuslabels.index', route('statuslabels.index')) ->push($statuslabel->display_name, route('statuslabels.show', $statuslabel)) ->push(trans('general.update')) ); /** * Settings Breadcrumbs */ Breadcrumbs::for('settings.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.admin'), route('settings.index')) ); /** * Suppliers Breadcrumbs */ Breadcrumbs::for('suppliers.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.suppliers'), route('suppliers.index')) ); Breadcrumbs::for('suppliers.create', fn (Trail $trail) => $trail->parent('suppliers.index', route('suppliers.index')) ->push(trans('general.create'), route('suppliers.create')) ); Breadcrumbs::for('suppliers.show', fn (Trail $trail, Supplier $supplier) => $trail->parent('suppliers.index', route('suppliers.index')) ->push($supplier->name, route('home')) ); Breadcrumbs::for('suppliers.edit', fn (Trail $trail, Supplier $supplier) => $trail->parent('suppliers.index', route('suppliers.index')) ->push($supplier->display_name, route('suppliers.show', $supplier)) ->push(trans('general.update')) ); /** * Users Breadcrumbs */ if ((request()->is('users*')) && (request()->status == 'deleted')) { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ->push(trans('general.deleted_users'), route('users.index')) ); } elseif ((request()->is('users*')) && (request()->admins == 'true')) { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ->push(trans('general.show_admins'), route('users.index')) ); } elseif ((request()->is('users*')) && (request()->superadmins == 'true')) { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ->push(trans('general.show_superadmins'), route('users.index')) ); } elseif ((request()->is('users*')) && (request()->activated == '0')) { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ->push(trans('general.login_disabled'), route('users.index')) ); } elseif ((request()->is('users*')) && (request()->activated == '1')) { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ->push(trans('general.login_enabled'), route('users.index')) ); } else { Breadcrumbs::for('users.index', fn (Trail $trail) => $trail->parent('home', route('home')) ->push(trans('general.users'), route('users.index')) ); } Breadcrumbs::for('users.create', fn (Trail $trail) => $trail->parent('users.index', route('users.index')) ->push(trans('general.create'), route('users.create')) ); Breadcrumbs::for('users.clone.show', fn (Trail $trail) => $trail->parent('users.index', route('users.index')) ->push(trans('admin/users/general.clone'), route('users.create')) ); Breadcrumbs::for('users.show', fn (Trail $trail, User $user) => $trail->parent('users.index', route('users.index')) ->push($user->display_name ?? 'Missing Username!', route('users.show', $user)) ); Breadcrumbs::for('users.edit', fn (Trail $trail, User $user) => $trail->parent('users.index', route('users.index')) ->push($user->display_name, route('users.show', $user)) ->push(trans('general.update')) ); } /** * Append parent -> child location breadcrumbs recursively for a location. */ private function pushLocationHierarchy(Trail $trail, Location $location): void { $ancestorChain = []; $cursor = $location; while ($cursor !== null) { array_unshift($ancestorChain, $cursor); $cursor = $cursor->parent; } foreach ($ancestorChain as $node) { $trail->push($node->name, route('locations.show', $node)); } } }