Add catalog module for service units, services and work types
Phase 1, item 3: the hierarchy customer jobs, tasks and time entries will refer to. - New Catalog module: service unit > optional service > work type. Names are unique per level (case-insensitive); items are never deleted, only deactivated, and foreign keys restrict deletes. - Pohjatiedot page (/catalog, admins and management): add, rename, reorder with move up/down buttons (keyboard-friendly, focus kept and announced) and an "in use" checkbox per row. Work types can move to another service of the same unit. - A migration inserts the starting catalog from the specification when the tables are empty, so every installation has it. - CatalogQueries gives other modules the active service units and the work types of chosen units plus the shared ones. - Spec and CLAUDE.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Catalog\Infrastructure\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
||||
use App\Modules\Catalog\Domain\Contracts\ServiceRepository;
|
||||
use App\Modules\Catalog\Domain\Contracts\ServiceUnitRepository;
|
||||
use App\Modules\Catalog\Domain\Contracts\WorkTypeRepository;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Repositories\EloquentCatalogQueries;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Repositories\EloquentServiceRepository;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Repositories\EloquentServiceUnitRepository;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Repositories\EloquentWorkTypeRepository;
|
||||
use App\Modules\Users\Domain\Enums\Role;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Livewire\Livewire;
|
||||
|
||||
/**
|
||||
* Wires the Catalog module (service units, services, work types) into
|
||||
* Laravel: bindings, routes, the `catalog::` Livewire namespace and the
|
||||
* `catalog.manage` ability.
|
||||
*/
|
||||
class CatalogServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
public array $bindings = [
|
||||
ServiceUnitRepository::class => EloquentServiceUnitRepository::class,
|
||||
ServiceRepository::class => EloquentServiceRepository::class,
|
||||
WorkTypeRepository::class => EloquentWorkTypeRepository::class,
|
||||
CatalogQueries::class => EloquentCatalogQueries::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$presentationPath = dirname(__DIR__, 2).'/Presentation';
|
||||
|
||||
Livewire::addNamespace('catalog', viewPath: $presentationPath.'/Livewire');
|
||||
|
||||
if (! $this->app->routesAreCached()) {
|
||||
$this->loadRoutesFrom($presentationPath.'/Routes/web.php');
|
||||
}
|
||||
|
||||
// Catalog data (pohjatiedot) is managed by admins and management.
|
||||
Gate::define('catalog.manage', fn (User $user): bool => in_array($user->role, [Role::Admin, Role::Management], true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user