diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 0a1d005..5cb882e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -19,15 +19,6 @@ class ProjectController extends Controller return view('projects.index'); } - /** - * Show the form for creating a new resource. - */ - public function create() - { - Gate::authorize('create projects'); - return view('projects.create'); - } - /** * Store a newly created resource in storage. */ @@ -58,15 +49,6 @@ class ProjectController extends Controller return redirect()->route('projects.map', $project); } - /** - * Show the form for editing the specified resource. - */ - public function edit(Project $project) // <--- ROUTE MODEL BINDING - { - Gate::authorize('edit projects', $project); - return view('projects.edit', compact('project')); - } - /** * Update the specified resource in storage. */ diff --git a/app/Livewire/LayerUpload.php b/app/Livewire/LayerUpload.php deleted file mode 100644 index 9a40ca1..0000000 --- a/app/Livewire/LayerUpload.php +++ /dev/null @@ -1,124 +0,0 @@ - 'required|file|max:51200', - 'layerName' => 'required|string|max:255', - 'layerColor' => 'nullable|string|size:7', - ]; - - public function mount($projectId = null, $phaseId = null) - { - $this->projectId = $projectId; - $this->phaseId = $phaseId; - } - - public function upload() - { - $user = Auth::user(); - if (!$user->can('upload layers') && !$user->hasRole('Admin')) { - session()->flash('error', 'Sin permisos.'); - return; - } - - $this->validate(); - - if (!$this->projectId || !$this->phaseId) { - session()->flash('error', 'Faltan datos del proyecto/fase.'); - return; - } - - $project = Project::findOrFail($this->projectId); - $phase = Phase::findOrFail($this->phaseId); - - $extension = strtolower($this->uploadFile->getClientOriginalExtension()); - $mime = $this->uploadFile->getMimeType(); - - $allowedExtensions = ['geojson', 'kmz', 'kml', 'shp', 'dwg', 'zip']; - $allowedMimes = [ - 'application/vnd.google-earth.kml+xml', - 'application/vnd.google-earth.kmz', - 'application/zip', - 'application/x-zip-compressed', - 'application/x-shapefile', - 'image/vnd.dwg', - 'application/acad', - 'application/geo+json', - 'text/xml', - 'application/xml', - ]; - - if (!in_array($extension, $allowedExtensions) && !in_array($mime, $allowedMimes)) { - session()->flash('error', 'Tipo de archivo no permitido.'); - return; - } - - $projectDir = "uploads/projects/{$project->id}/layers"; - $originalPath = $this->uploadFile->store($projectDir, 'public'); - $geojson = SpatialFileConverter::convertToGeoJson($this->uploadFile); - - if (!$geojson) { - session()->flash('error', 'Conversión fallida.'); - return; - } - - $layerColor = $this->layerColor ?: '#3b82f6'; - $geojson['style'] = ['color' => $layerColor]; - - $layer = Layer::create([ - 'project_id' => $project->id, - 'phase_id' => $phase->id, - 'name' => $this->layerName, - 'color' => $layerColor, - 'original_file' => $originalPath, - 'uploaded_by' => $user->id, - ]); - - if (isset($geojson['features'])) { - foreach ($geojson['features'] as $featureData) { - Feature::create([ - 'layer_id' => $layer->id, - 'name' => $featureData['properties']['name'] ?? null, - 'geometry' => $featureData['geometry'], - 'properties' => $featureData['properties'] ?? [], - 'template_id' => $featureData['properties']['template_id'] ?? null, - 'progress' => $featureData['properties']['progress'] ?? 0, - 'responsible' => $featureData['properties']['responsible'] ?? null, - ]); - } - } - - $this->reset(['uploadFile', 'layerName']); - session()->flash('message', "Capa '{$layer->name}' importada correctamente con " . count($geojson['features'] ?? []) . ' elementos.'); - $this->dispatch('layerUploaded', projectId: $project->id); - } - - public function render() - { - $projects = Project::accessibleBy(Auth::user())->get(); - $phases = $this->projectId ? Phase::where('project_id', $this->projectId)->orderBy('order')->get() : collect(); - - return view('livewire.layer-upload', compact('projects', 'phases')); - } -} \ No newline at end of file diff --git a/app/Livewire/ProjectEditTabs.php b/app/Livewire/ProjectEditTabs.php deleted file mode 100644 index 081839f..0000000 --- a/app/Livewire/ProjectEditTabs.php +++ /dev/null @@ -1,42 +0,0 @@ -project = $project; - } - - public function setActiveTab($tab) - { - $this->activeTab = $tab; - } - - public function tabChanged($tab, $projectId) - { - if ($projectId == $this->project->id) { - $this->activeTab = $tab; - } - } - - public function updateProject() - { - $this->project->save(); - - session()->flash('message', __('Project updated successfully.')); - $this->dispatch('project-updated'); - } - - public function render() - { - return view('livewire.project-edit-tabs'); - } -} \ No newline at end of file diff --git a/resources/views/livewire/layer-upload.blade.php b/resources/views/livewire/layer-upload.blade.php deleted file mode 100644 index 2cf5709..0000000 --- a/resources/views/livewire/layer-upload.blade.php +++ /dev/null @@ -1,57 +0,0 @@ -