chore: cleanup dead code + format with Pint

- Remove unused FeaturesController (empty stubs, no routes)
- Remove ConvertSpatialFile CLI command (unused; service used in LayerManager)
- Remove MigrateGeojsonToFeatures CLI command (one-shot migration, not referenced)
- Remove .claude/worktrees/ (11 old agent worktrees from June)
- Apply Laravel Pint formatting across 219 files (style only, no functional changes)

Tests: 101 passing (319 assertions)
API routes: unchanged (8 routes intact)
This commit is contained in:
Javier Braña
2026-08-28 13:04:28 +02:00
parent 2dccd59385
commit 90630379fb
139 changed files with 2888 additions and 2510 deletions
+102 -100
View File
@@ -30,12 +30,12 @@ class SyncController extends Controller
public function sync(Request $request)
{
$data = $request->validate([
'operations' => ['required', 'array'],
'operations.*.entity' => ['required', 'string'],
'operations.*.op' => ['required', 'string'],
'operations.*.uuid' => ['required', 'uuid'],
'operations.*.data' => ['required', 'array'],
'operations.*.client_updated_at' => ['nullable', 'date'],
'operations' => ['required', 'array'],
'operations.*.entity' => ['required', 'string'],
'operations.*.op' => ['required', 'string'],
'operations.*.uuid' => ['required', 'uuid'],
'operations.*.data' => ['required', 'array'],
'operations.*.client_updated_at' => ['nullable', 'date'],
]);
$user = $request->user();
@@ -74,16 +74,16 @@ class SyncController extends Controller
}
try {
$result = match ($op['entity'] . '.' . $op['op']) {
$result = match ($op['entity'].'.'.$op['op']) {
'progress_update.create' => $this->progressUpdateCreate($user, $uuid, $op),
'inspection.create' => $this->inspectionCreate($user, $uuid, $op),
'issue.create' => $this->issueCreate($user, $uuid, $op),
'issue.update' => $this->issueUpdate($user, $uuid, $op),
'issue_task.create' => $this->issueTaskCreate($user, $uuid, $op),
'issue_task.update' => $this->issueTaskUpdate($user, $uuid, $op),
'issue_comment.create' => $this->issueCommentCreate($user, $uuid, $op),
'feature.update' => $this->featureUpdate($user, $uuid, $op),
default => $this->error($uuid, 'unsupported entity/op: ' . $op['entity'] . '.' . $op['op']),
'inspection.create' => $this->inspectionCreate($user, $uuid, $op),
'issue.create' => $this->issueCreate($user, $uuid, $op),
'issue.update' => $this->issueUpdate($user, $uuid, $op),
'issue_task.create' => $this->issueTaskCreate($user, $uuid, $op),
'issue_task.update' => $this->issueTaskUpdate($user, $uuid, $op),
'issue_comment.create' => $this->issueCommentCreate($user, $uuid, $op),
'feature.update' => $this->featureUpdate($user, $uuid, $op),
default => $this->error($uuid, 'unsupported entity/op: '.$op['entity'].'.'.$op['op']),
};
} catch (\Throwable $e) {
$result = $this->error($uuid, $e->getMessage());
@@ -92,11 +92,11 @@ class SyncController extends Controller
// Record only terminal successes so conflicts/errors can be safely retried.
if ($result['status'] === 'applied') {
SyncLog::create([
'user_id' => $user->id,
'op_uuid' => $uuid,
'entity' => $op['entity'],
'op' => $op['op'],
'status' => 'applied',
'user_id' => $user->id,
'op_uuid' => $uuid,
'entity' => $op['entity'],
'op' => $op['op'],
'status' => 'applied',
'server_id' => $result['server_id'] ?? null,
]);
}
@@ -115,11 +115,11 @@ class SyncController extends Controller
$v = Validator::make($op['data'], [
'phase_id' => ['required', 'integer', 'exists:phases,id'],
'progress' => ['required', 'integer', 'min:0', 'max:100'],
'comment' => ['nullable', 'string'],
'comment' => ['nullable', 'string'],
'location' => ['nullable', 'array'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -129,12 +129,12 @@ class SyncController extends Controller
}
$pu = ProgressUpdate::create([
'uuid' => $uuid,
'phase_id' => $phase->id,
'user_id' => $user->id,
'progress_percent' => $d['progress'],
'comment' => $d['comment'] ?? null,
'location' => $d['location'] ?? null,
'uuid' => $uuid,
'phase_id' => $phase->id,
'user_id' => $user->id,
'progress_percent' => $d['progress'],
'comment' => $d['comment'] ?? null,
'location' => $d['location'] ?? null,
'client_updated_at' => $op['client_updated_at'] ?? null,
]);
@@ -153,15 +153,15 @@ class SyncController extends Controller
}
$v = Validator::make($op['data'], [
'feature_id' => ['required', 'integer', 'exists:features,id'],
'feature_id' => ['required', 'integer', 'exists:features,id'],
'template_id' => ['nullable', 'integer', 'exists:inspection_templates,id'],
'data' => ['nullable', 'array'],
'status' => ['nullable', 'string'],
'result' => ['nullable', 'string'],
'notes' => ['nullable', 'string'],
'data' => ['nullable', 'array'],
'status' => ['nullable', 'string'],
'result' => ['nullable', 'string'],
'notes' => ['nullable', 'string'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -172,16 +172,16 @@ class SyncController extends Controller
}
$inspection = Inspection::create([
'uuid' => $uuid,
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $d['template_id'] ?? null,
'user_id' => $user->id,
'data' => $d['data'] ?? [],
'status' => $d['status'] ?? 'completed',
'result' => $d['result'] ?? null,
'notes' => $d['notes'] ?? null,
'uuid' => $uuid,
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $d['template_id'] ?? null,
'user_id' => $user->id,
'data' => $d['data'] ?? [],
'status' => $d['status'] ?? 'completed',
'result' => $d['result'] ?? null,
'notes' => $d['notes'] ?? null,
'client_updated_at' => $op['client_updated_at'] ?? null,
]);
@@ -197,16 +197,16 @@ class SyncController extends Controller
}
$v = Validator::make($op['data'], [
'project_id' => ['required', 'integer', 'exists:projects,id'],
'feature_id' => ['nullable', 'integer', 'exists:features,id'],
'title' => ['required', 'string', 'max:255'],
'project_id' => ['required', 'integer', 'exists:projects,id'],
'feature_id' => ['nullable', 'integer', 'exists:features,id'],
'title' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'priority' => ['nullable', 'in:' . implode(',', Issue::PRIORITIES)],
'status' => ['nullable', 'in:' . implode(',', Issue::STATUSES)],
'type' => ['nullable', 'in:' . implode(',', Issue::TYPES)],
'priority' => ['nullable', 'in:'.implode(',', Issue::PRIORITIES)],
'status' => ['nullable', 'in:'.implode(',', Issue::STATUSES)],
'type' => ['nullable', 'in:'.implode(',', Issue::TYPES)],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -216,15 +216,15 @@ class SyncController extends Controller
}
$issue = Issue::create([
'uuid' => $uuid,
'project_id' => $project->id,
'feature_id' => $d['feature_id'] ?? null,
'title' => $d['title'],
'description' => $d['description'] ?? null,
'priority' => $d['priority'] ?? 'medium',
'status' => $d['status'] ?? 'open',
'type' => $d['type'] ?? 'other',
'reported_by' => $user->id,
'uuid' => $uuid,
'project_id' => $project->id,
'feature_id' => $d['feature_id'] ?? null,
'title' => $d['title'],
'description' => $d['description'] ?? null,
'priority' => $d['priority'] ?? 'medium',
'status' => $d['status'] ?? 'open',
'type' => $d['type'] ?? 'other',
'reported_by' => $user->id,
'client_updated_at' => $op['client_updated_at'] ?? null,
]);
@@ -234,17 +234,17 @@ class SyncController extends Controller
private function issueUpdate(User $user, string $uuid, array $op): array
{
$v = Validator::make($op['data'], [
'id' => ['required', 'integer', 'exists:issues,id'],
'title' => ['nullable', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'priority' => ['nullable', 'in:' . implode(',', Issue::PRIORITIES)],
'status' => ['nullable', 'in:' . implode(',', Issue::STATUSES)],
'type' => ['nullable', 'in:' . implode(',', Issue::TYPES)],
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
'id' => ['required', 'integer', 'exists:issues,id'],
'title' => ['nullable', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'priority' => ['nullable', 'in:'.implode(',', Issue::PRIORITIES)],
'status' => ['nullable', 'in:'.implode(',', Issue::STATUSES)],
'type' => ['nullable', 'in:'.implode(',', Issue::TYPES)],
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
'resolution_notes' => ['nullable', 'string'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -276,14 +276,14 @@ class SyncController extends Controller
}
$v = Validator::make($op['data'], [
'issue_id' => ['required', 'integer', 'exists:issues,id'],
'title' => ['required', 'string', 'max:255'],
'issue_id' => ['required', 'integer', 'exists:issues,id'],
'title' => ['required', 'string', 'max:255'],
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
'due_date' => ['nullable', 'date'],
'is_done' => ['nullable', 'boolean'],
'due_date' => ['nullable', 'date'],
'is_done' => ['nullable', 'boolean'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -294,15 +294,15 @@ class SyncController extends Controller
$done = $d['is_done'] ?? false;
$task = IssueTask::create([
'uuid' => $uuid,
'issue_id' => $issue->id,
'title' => $d['title'],
'assigned_to' => $d['assigned_to'] ?? null,
'due_date' => $d['due_date'] ?? null,
'is_done' => $done,
'done_at' => $done ? now() : null,
'done_by' => $done ? $user->id : null,
'order' => ((int) $issue->tasks()->max('order')) + 1,
'uuid' => $uuid,
'issue_id' => $issue->id,
'title' => $d['title'],
'assigned_to' => $d['assigned_to'] ?? null,
'due_date' => $d['due_date'] ?? null,
'is_done' => $done,
'done_at' => $done ? now() : null,
'done_by' => $done ? $user->id : null,
'order' => ((int) $issue->tasks()->max('order')) + 1,
'client_updated_at' => $op['client_updated_at'] ?? null,
]);
@@ -312,14 +312,14 @@ class SyncController extends Controller
private function issueTaskUpdate(User $user, string $uuid, array $op): array
{
$v = Validator::make($op['data'], [
'id' => ['required', 'integer', 'exists:issue_tasks,id'],
'title' => ['nullable', 'string', 'max:255'],
'id' => ['required', 'integer', 'exists:issue_tasks,id'],
'title' => ['nullable', 'string', 'max:255'],
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
'due_date' => ['nullable', 'date'],
'is_done' => ['nullable', 'boolean'],
'due_date' => ['nullable', 'date'],
'is_done' => ['nullable', 'boolean'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -354,10 +354,10 @@ class SyncController extends Controller
$v = Validator::make($op['data'], [
'issue_id' => ['required', 'integer', 'exists:issues,id'],
'body' => ['required', 'string', 'max:5000'],
'body' => ['required', 'string', 'max:5000'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -367,10 +367,10 @@ class SyncController extends Controller
}
$comment = IssueComment::create([
'uuid' => $uuid,
'issue_id' => $issue->id,
'user_id' => $user->id,
'body' => $d['body'],
'uuid' => $uuid,
'issue_id' => $issue->id,
'user_id' => $user->id,
'body' => $d['body'],
'client_updated_at' => $op['client_updated_at'] ?? null,
]);
@@ -382,15 +382,15 @@ class SyncController extends Controller
private function featureUpdate(User $user, string $uuid, array $op): array
{
$v = Validator::make($op['data'], [
'id' => ['required', 'integer', 'exists:features,id'],
'status' => ['nullable', 'string'],
'progress' => ['nullable', 'integer', 'min:0', 'max:100'],
'responsible' => ['nullable', 'string'],
'is_active' => ['nullable', 'boolean'],
'id' => ['required', 'integer', 'exists:features,id'],
'status' => ['nullable', 'string'],
'progress' => ['nullable', 'integer', 'min:0', 'max:100'],
'responsible' => ['nullable', 'string'],
'is_active' => ['nullable', 'boolean'],
'feature_type_id' => ['nullable', 'integer', 'exists:feature_types,id'],
]);
if ($v->fails()) {
return $this->error($uuid, 'validation: ' . $v->errors()->first());
return $this->error($uuid, 'validation: '.$v->errors()->first());
}
$d = $v->validated();
@@ -424,6 +424,7 @@ class SyncController extends Controller
if (! $project) {
return false;
}
return $user->can('manage all')
|| $project->users()->where('user_id', $user->id)->exists();
}
@@ -440,11 +441,12 @@ class SyncController extends Controller
$clientAt = Carbon::parse($op['client_updated_at']);
if ($model->updated_at && $model->updated_at->gt($clientAt)) {
return [
'uuid' => $uuid,
'uuid' => $uuid,
'status' => 'conflict',
'server' => $model->fresh()->toArray(),
];
}
return null;
}