Skip to content

A free open source IT asset/license management system

Small code re-org for clarity

snipeaf1c55cd7eb7
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index 84e7a87ae1..0b544e69e9 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -2,7 +2,6 @@
namespace App\Models;
-use App\Helpers\Helper;
use App\Models\Traits\Acceptable;
use App\Models\Traits\CompanyableTrait;
use App\Models\Traits\HasUploads;
@@ -21,21 +20,23 @@ use Watson\Validating\ValidatingTrait;
*/
class Accessory extends SnipeModel
{
- use HasFactory;
-
- protected $presenter = \App\Presenters\AccessoryPresenter::class;
+ use Acceptable;
use CompanyableTrait;
+ use HasFactory;
use HasUploads;
- use Loggable, Presentable;
+ use Loggable;
+ use Presentable;
+ use Searchable;
use SoftDeletes;
+ use ValidatingTrait;
protected $table = 'accessories';
protected $casts = [
'purchase_date' => 'datetime',
'requestable' => 'boolean', ];
- use Searchable;
- use Acceptable;
+ protected $presenter = \App\Presenters\AccessoryPresenter::class;
+
/**
* The attributes that should be included when searching the model.
@@ -80,7 +81,7 @@ class Accessory extends SnipeModel
* @var bool
*/
protected $injectUniqueIdentifier = true;
- use ValidatingTrait;
+
/**
* The attributes that are mass assignable.
diff --git a/app/Models/Location.php b/app/Models/Location.php
index ed8524f519..22d311b2e9 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -15,14 +15,18 @@ use Watson\Validating\ValidatingTrait;
class Location extends SnipeModel
{
- use HasFactory;
use CompanyableTrait;
+ use HasFactory;
+ use HasUploads;
use Loggable;
-
- protected $presenter = \App\Presenters\LocationPresenter::class;
use Presentable;
+ use Searchable;
use SoftDeletes;
- use HasUploads;
+ use UniqueUndeletedTrait;
+ use ValidatingTrait;
+
+
+ protected $presenter = \App\Presenters\LocationPresenter::class;
protected $table = 'locations';
protected $rules = [
@@ -53,8 +57,7 @@ class Location extends SnipeModel
* @var bool
*/
protected $injectUniqueIdentifier = true;
- use ValidatingTrait;
- use UniqueUndeletedTrait;
+
/**
* The attributes that are mass assignable.
@@ -80,16 +83,28 @@ class Location extends SnipeModel
'tag_color',
'notes',
];
+
protected $hidden = ['user_id'];
- use Searchable;
/**
* The attributes that should be included when searching the model.
*
* @var array
*/
- protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax', 'notes'];
+ protected $searchableAttributes =
+ [
+ 'name',
+ 'address',
+ 'city',
+ 'state',
+ 'zip',
+ 'created_at',
+ 'ldap_ou',
+ 'phone',
+ 'fax',
+ 'notes'
+ ];
/**
* The relations and their attributes that should be included when searching the model.
@@ -114,7 +129,6 @@ class Location extends SnipeModel
*/
public function isDeletable()
{
-
return Gate::allows('delete', $this)
&& ($this->deleted_at == '')
&& (($this->assets_count ?? $this->assets()->count()) === 0)