Files
construprogress/app/Livewire/ProjectList.php
T
javier 941dbd5997 restore: bring back f8a1310 (security review) state
Restores all files to the f8a1310 security-review snapshot as requested,
plus the 2 boot-critical fixes from a24c8a2 (config/session.php env()
instead of app()->environment(), and removal of the duplicate $activeTab
in ProjectMap.php) so the application actually boots.

Forward commit, no history rewrite. The 7d854ff state remains in history.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 10:36:44 +02:00

42 lines
1.2 KiB
PHP

<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\WithPagination;
use App\Models\Project;
use Illuminate\Support\Facades\Auth;
class ProjectList extends Component
{
use WithPagination;
public $search = '';
public $statusFilter = '';
public function deleteProject($id)
{
$user = Auth::user();
if (!$user->can('delete projects')) {
session()->flash('error', 'Sin permisos para eliminar proyectos.');
return;
}
// Scope to accessible projects to prevent IDOR (deleting another user's project by ID)
$project = Project::accessibleBy($user)->findOrFail($id);
$project->delete();
session()->flash('message', 'Proyecto eliminado');
}
public function render()
{
$query = Project::accessibleBy(Auth::user());
if ($this->search) {
$query->where('name', 'like', '%' . $this->search . '%');
}
if ($this->statusFilter) {
$query->where('status', $this->statusFilter);
}
$projects = $query->with('phases')->latest()->paginate(10);
return view('livewire.projects.project-list', ['projects' => $projects]);
}
}