2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
2016-09-06 19:39:42 -07:00
|
|
|
use App\Models\Loggable;
|
2018-07-28 03:43:09 -07:00
|
|
|
use App\Notifications\CheckinLicenseNotification;
|
|
|
|
use App\Notifications\CheckoutLicenseNotification;
|
|
|
|
use App\Presenters\Presentable;
|
2016-03-25 01:18:05 -07:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
2018-07-28 03:43:09 -07:00
|
|
|
class LicenseSeat extends SnipeModel implements ICompanyableChild
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
|
|
|
use CompanyableChildTrait;
|
|
|
|
use SoftDeletes;
|
2016-09-06 19:39:42 -07:00
|
|
|
use Loggable;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2018-07-28 03:43:09 -07:00
|
|
|
protected $presenter = 'App\Presenters\LicenseSeatPresenter';
|
|
|
|
use Presentable;
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
protected $guarded = 'id';
|
|
|
|
protected $table = 'license_seats';
|
|
|
|
|
|
|
|
public function getCompanyableParents()
|
|
|
|
{
|
|
|
|
return ['asset', 'license'];
|
|
|
|
}
|
|
|
|
|
2018-07-28 03:43:09 -07:00
|
|
|
public function getEula() {
|
|
|
|
return $this->license->getEula();
|
|
|
|
}
|
|
|
|
|
2018-08-01 00:06:41 -07:00
|
|
|
/**
|
|
|
|
* Establishes the seat -> license relationship
|
|
|
|
*
|
|
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
|
|
* @since [v1.0]
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
public function license()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\License', 'license_id');
|
|
|
|
}
|
|
|
|
|
2018-08-01 00:06:41 -07:00
|
|
|
/**
|
|
|
|
* Establishes the seat -> assignee relationship
|
|
|
|
*
|
|
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
|
|
* @since [v1.0]
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\User', 'assigned_to')->withTrashed();
|
|
|
|
}
|
|
|
|
|
2018-08-01 00:06:41 -07:00
|
|
|
/**
|
|
|
|
* Establishes the seat -> asset relationship
|
|
|
|
*
|
|
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
|
|
* @since [v4.0]
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
public function asset()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed();
|
|
|
|
}
|
2018-01-10 20:34:44 -08:00
|
|
|
|
2018-08-01 00:06:41 -07:00
|
|
|
/**
|
|
|
|
* Determines the assigned seat's location based on user
|
|
|
|
* or asset its assigned to
|
|
|
|
*
|
|
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
|
|
* @since [v4.0]
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-10 20:34:44 -08:00
|
|
|
public function location()
|
|
|
|
{
|
|
|
|
if (($this->user) && ($this->user->location)) {
|
|
|
|
return $this->user->location;
|
|
|
|
|
|
|
|
} elseif (($this->asset) && ($this->asset->location)) {
|
|
|
|
return $this->asset->location;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
2018-07-24 19:35:26 -07:00
|
|
|
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|