feat(auth): enhance authorization checks in Livewire components for resource management
This commit is contained in:
@@ -3,10 +3,13 @@
|
||||
namespace App\Livewire\Project;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeleteProject extends Component
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
public array $parameters;
|
||||
|
||||
public int $project_id;
|
||||
@@ -27,6 +30,8 @@ class DeleteProject extends Component
|
||||
'project_id' => 'required|int',
|
||||
]);
|
||||
$project = Project::findOrFail($this->project_id);
|
||||
$this->authorize('delete', $project);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
$project->delete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user