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:
@@ -13,31 +13,31 @@ use App\Models\Phase;
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class MediaController extends Controller
|
||||
{
|
||||
private array $map = [
|
||||
'feature' => Feature::class,
|
||||
'issue' => Issue::class,
|
||||
'issue_task' => IssueTask::class,
|
||||
'feature' => Feature::class,
|
||||
'issue' => Issue::class,
|
||||
'issue_task' => IssueTask::class,
|
||||
'issue_comment' => IssueComment::class,
|
||||
'project' => Project::class,
|
||||
'phase' => Phase::class,
|
||||
'layer' => Layer::class,
|
||||
'project' => Project::class,
|
||||
'phase' => Phase::class,
|
||||
'layer' => Layer::class,
|
||||
];
|
||||
|
||||
/** Upload a file (multipart) and attach it to a parent record. Idempotent by uuid. */
|
||||
public function upload(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'uuid' => ['required', 'uuid'],
|
||||
'uuid' => ['required', 'uuid'],
|
||||
'parent_entity' => ['required', Rule::in(array_keys($this->map))],
|
||||
'parent_id' => ['required', 'integer'],
|
||||
'file' => ['required', 'file', 'max:20480'], // 20 MB
|
||||
'category' => ['nullable', 'in:image,document,other'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'parent_id' => ['required', 'integer'],
|
||||
'file' => ['required', 'file', 'max:20480'], // 20 MB
|
||||
'category' => ['nullable', 'in:image,document,other'],
|
||||
'description' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
// Idempotency: same uuid already uploaded → return it.
|
||||
@@ -59,15 +59,15 @@ class MediaController extends Controller
|
||||
$mime = $file->getClientMimeType();
|
||||
|
||||
$media = $parent->media()->create([
|
||||
'uuid' => $data['uuid'],
|
||||
'name' => $file->getClientOriginalName(),
|
||||
'file_path' => $path,
|
||||
'file_type' => $mime,
|
||||
'file_extension' => $file->getClientOriginalExtension(),
|
||||
'file_size' => $file->getSize(),
|
||||
'category' => $data['category'] ?? (Str::startsWith($mime, 'image/') ? 'image' : 'document'),
|
||||
'description' => $data['description'] ?? null,
|
||||
'uploaded_by' => $user->id,
|
||||
'uuid' => $data['uuid'],
|
||||
'name' => $file->getClientOriginalName(),
|
||||
'file_path' => $path,
|
||||
'file_type' => $mime,
|
||||
'file_extension' => $file->getClientOriginalExtension(),
|
||||
'file_size' => $file->getSize(),
|
||||
'category' => $data['category'] ?? (Str::startsWith($mime, 'image/') ? 'image' : 'document'),
|
||||
'description' => $data['description'] ?? null,
|
||||
'uploaded_by' => $user->id,
|
||||
'client_updated_at' => $request->input('client_updated_at'),
|
||||
]);
|
||||
|
||||
@@ -77,14 +77,14 @@ class MediaController extends Controller
|
||||
private function projectOf(string $entity, $parent): ?Project
|
||||
{
|
||||
return match ($entity) {
|
||||
'project' => $parent,
|
||||
'phase' => $parent->project,
|
||||
'layer' => $parent->phase?->project,
|
||||
'feature' => $parent->layer?->phase?->project,
|
||||
'issue' => $parent->project,
|
||||
'issue_task' => $parent->issue?->project,
|
||||
'project' => $parent,
|
||||
'phase' => $parent->project,
|
||||
'layer' => $parent->phase?->project,
|
||||
'feature' => $parent->layer?->phase?->project,
|
||||
'issue' => $parent->project,
|
||||
'issue_task' => $parent->issue?->project,
|
||||
'issue_comment' => $parent->issue?->project,
|
||||
default => null,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ class MediaController extends Controller
|
||||
if (! $project) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->can('manage all')
|
||||
|| $project->users()->where('user_id', $user->id)->exists();
|
||||
}
|
||||
@@ -100,12 +101,12 @@ class MediaController extends Controller
|
||||
private function payload(Media $m): array
|
||||
{
|
||||
return [
|
||||
'id' => $m->id,
|
||||
'uuid' => $m->uuid,
|
||||
'url' => $m->url,
|
||||
'name' => $m->name,
|
||||
'file_type' => $m->file_type,
|
||||
'category' => $m->category,
|
||||
'id' => $m->id,
|
||||
'uuid' => $m->uuid,
|
||||
'url' => $m->url,
|
||||
'name' => $m->name,
|
||||
'file_type' => $m->file_type,
|
||||
'category' => $m->category,
|
||||
'updated_at' => $m->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user