++ fix permessi assegnazioni
This commit is contained in:
@@ -12,6 +12,8 @@ class TerritorioCestino extends Component
|
||||
|
||||
public function restore(int $id)
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$territorio = Territorio::onlyTrashed()->findOrFail($id);
|
||||
$territorio->restore();
|
||||
activity()->causedBy(auth()->user())
|
||||
@@ -22,6 +24,8 @@ class TerritorioCestino extends Component
|
||||
|
||||
public function forceDelete(int $id)
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$territorio = Territorio::onlyTrashed()->findOrFail($id);
|
||||
|
||||
if ($territorio->assegnazioni()->exists()) {
|
||||
|
||||
@@ -36,6 +36,8 @@ class TerritorioCreate extends Component
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$this->validate();
|
||||
|
||||
$data = [
|
||||
|
||||
@@ -49,6 +49,8 @@ class TerritorioEdit extends Component
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$this->validate();
|
||||
|
||||
$data = [
|
||||
@@ -82,6 +84,8 @@ class TerritorioEdit extends Component
|
||||
|
||||
public function removePdf()
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
if ($this->territorio->pdf_path) {
|
||||
Storage::disk('public')->delete($this->territorio->pdf_path);
|
||||
if ($this->territorio->thumbnail_path) {
|
||||
|
||||
@@ -96,6 +96,11 @@ class TerritorioIndex extends Component
|
||||
|
||||
public function toggleActive(Territorio $territorio)
|
||||
{
|
||||
// La lista è ora visibile agli utenti operativi (territori.assign), ma
|
||||
// modificare/eliminare i territori resta riservato all'amministratore.
|
||||
// Il check DEVE stare nel metodo: la rotta index non lo garantisce più.
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$territorio->update(['attivo' => !$territorio->attivo]);
|
||||
activity()->causedBy(auth()->user())
|
||||
->performedOn($territorio)
|
||||
@@ -105,6 +110,8 @@ class TerritorioIndex extends Component
|
||||
|
||||
public function togglePriority(Territorio $territorio)
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
$territorio->update(['prioritario' => !$territorio->prioritario]);
|
||||
activity()->causedBy(auth()->user())
|
||||
->performedOn($territorio)
|
||||
@@ -114,6 +121,8 @@ class TerritorioIndex extends Component
|
||||
|
||||
public function deleteTerritorio(Territorio $territorio)
|
||||
{
|
||||
$this->authorize('territori.manage');
|
||||
|
||||
activity()->causedBy(auth()->user())
|
||||
->performedOn($territorio)
|
||||
->log('soft_deleted');
|
||||
|
||||
Reference in New Issue
Block a user