*/ public array $bindings = [ StockItemGroupRepository::class => EloquentStockItemGroupRepository::class, StockItemRepository::class => EloquentStockItemRepository::class, StockMovementRepository::class => EloquentStockMovementRepository::class, StockQueries::class => EloquentStockQueries::class, StockItemImages::class => StockItemImageFiles::class, TaskMaterialSuggestionRepository::class => EloquentTaskMaterialSuggestionRepository::class, StockTasks::class => TasksForStock::class, InventoryCountRepository::class => EloquentInventoryCountRepository::class, InventoryCountQueries::class => EloquentInventoryCountQueries::class, ]; public function register(): void { // Registered after TimeTracking: a task with material is kept like one with hours. $this->app->extend(TaskUsage::class, fn (TaskUsage $usage): TaskUsage => new TaskUsageWithStock($usage)); } public function boot(): void { Event::listen(TaskMaterialsSuggested::class, fn (TaskMaterialsSuggested $event) => app(TaskMaterials::class)->suggest($event->taskId, $event->materials)); $presentationPath = dirname(__DIR__, 2).'/Presentation'; Livewire::addNamespace('inventory', viewPath: $presentationPath.'/Livewire'); if (! $this->app->routesAreCached()) { $this->loadRoutesFrom($presentationPath.'/Routes/web.php'); } $staff = fn (User $user): bool => $user->role !== Role::Subcontractor; $managers = fn (User $user): bool => in_array($user->role, [Role::Admin, Role::Management], true); Gate::define('inventory.view', $staff); Gate::define('inventory.record-use', $staff); Gate::define('inventory.count', $staff); Gate::define('inventory.manage', $managers); Gate::define('inventory.manage-counts', $managers); Gate::define('inventory.reverse-any', $managers); Gate::define('inventory.see-value', $managers); // The menu shows stock pages only when a service unit uses stock (spec 19). Gate::define('inventory.menu', fn (User $user): bool => $staff($user) && app(CatalogQueries::class)->stockServiceUnitIds() !== []); } }