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,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Catalog\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Database\Factories\ServiceFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Catalog Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $service_unit_id
|
||||
* @property string $name
|
||||
* @property bool $is_active
|
||||
* @property int $sort_order
|
||||
*/
|
||||
#[Table('services')]
|
||||
#[Fillable(['service_unit_id', 'name', 'is_active', 'sort_order'])]
|
||||
#[UseFactory(ServiceFactory::class)]
|
||||
class ServiceModel extends Model
|
||||
{
|
||||
/** @use HasFactory<ServiceFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'service_unit_id' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Catalog\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Database\Factories\ServiceUnitFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Catalog Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property bool $is_shared
|
||||
* @property bool $is_active
|
||||
* @property int $sort_order
|
||||
*/
|
||||
#[Table('service_units')]
|
||||
#[Fillable(['name', 'is_shared', 'is_active', 'sort_order'])]
|
||||
#[UseFactory(ServiceUnitFactory::class)]
|
||||
class ServiceUnitModel extends Model
|
||||
{
|
||||
/** @use HasFactory<ServiceUnitFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_shared' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Catalog\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Database\Factories\WorkTypeFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Catalog Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $service_unit_id
|
||||
* @property int|null $service_id
|
||||
* @property string $name
|
||||
* @property bool $is_active
|
||||
* @property int $sort_order
|
||||
*/
|
||||
#[Table('work_types')]
|
||||
#[Fillable(['service_unit_id', 'service_id', 'name', 'is_active', 'sort_order'])]
|
||||
#[UseFactory(WorkTypeFactory::class)]
|
||||
class WorkTypeModel extends Model
|
||||
{
|
||||
/** @use HasFactory<WorkTypeFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'service_unit_id' => 'integer',
|
||||
'service_id' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user