da0c8bd134
Login authenticated fine but the landing page crashed (so it looked like
'login doesn't work'):
- bootstrap/app.php didn't register Spatie's middleware aliases -> any route
with role:/permission: threw 'Target class [role] does not exist'.
Registered role / permission / role_or_permission.
- config/livewire.php absent -> default layout is the non-existent
components.layouts.app. ProjectList, PhaseProgress and ReportsDashboard
lacked #[Layout('layouts.app')] -> MissingLayoutException. Added it (the
other 10 routed components already had it).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Livewire\Attributes\Layout;
|
|
use App\Models\Project;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
#[Layout('layouts.app')]
|
|
class ProjectList extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public $search = '';
|
|
public $statusFilter = '';
|
|
|
|
public function deleteProject($id)
|
|
{
|
|
$project = Project::findOrFail($id);
|
|
if (Auth::user()->can('delete projects')) {
|
|
$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]);
|
|
}
|
|
} |