Added uploads method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
9d313eb2d9
commit
00092a079f
1 changed files with 18 additions and 0 deletions
|
@ -20,6 +20,7 @@ class Location extends SnipeModel
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use CompanyableTrait;
|
use CompanyableTrait;
|
||||||
|
use Loggable;
|
||||||
|
|
||||||
protected $presenter = \App\Presenters\LocationPresenter::class;
|
protected $presenter = \App\Presenters\LocationPresenter::class;
|
||||||
use Presentable;
|
use Presentable;
|
||||||
|
@ -288,6 +289,23 @@ class Location extends SnipeModel
|
||||||
return $this->attributes['ldap_ou'] = empty($ldap_ou) ? null : $ldap_ou;
|
return $this->attributes['ldap_ou'] = empty($ldap_ou) ? null : $ldap_ou;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get uploads for this location
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v4.0]
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||||
|
*/
|
||||||
|
public function uploads()
|
||||||
|
{
|
||||||
|
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||||
|
->where('item_type', '=', Location::class)
|
||||||
|
->where('action_type', '=', 'uploaded')
|
||||||
|
->whereNotNull('filename')
|
||||||
|
->orderBy('created_at', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope to order on parent
|
* Query builder scope to order on parent
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue