Added/refactorerd isDeletable()

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2023-11-22 18:03:26 +00:00
parent f7ccef16e7
commit 19877244cd
4 changed files with 38 additions and 2 deletions
+16
View File
@@ -6,6 +6,7 @@ use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Storage;
use Watson\Validating\ValidatingTrait;
@@ -188,6 +189,21 @@ class AssetModel extends SnipeModel
return false;
}
/**
* Checks if the model is deletable
*
* @author A. Gianotto <snipe@snipe.net>
* @since [v6.3.4]
* @return bool
*/
public function isDeletable()
{
return Gate::allows('delete', $this)
&& ($this->assets_count == 0)
&& ($this->deleted_at == '');
}
/**
* Get uploads for this model
*