2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
2016-09-06 19:39:42 -07:00
|
|
|
use App\Models\Loggable;
|
2016-03-25 01:18:05 -07:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-03-25 13:46:57 -07:00
|
|
|
use App\Notifications\CheckoutLicenseNotification;
|
|
|
|
use App\Notifications\CheckinLicenseNotification;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class LicenseSeat extends Model implements ICompanyableChild
|
|
|
|
{
|
|
|
|
use CompanyableChildTrait;
|
|
|
|
use SoftDeletes;
|
2016-09-06 19:39:42 -07:00
|
|
|
use Loggable;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
protected $guarded = 'id';
|
|
|
|
protected $table = 'license_seats';
|
|
|
|
|
2018-03-25 13:46:57 -07:00
|
|
|
/**
|
|
|
|
* Set static properties to determine which checkout/checkin handlers we should use
|
|
|
|
*/
|
|
|
|
public static $checkoutClass = CheckoutLicenseNotification::class;
|
|
|
|
public static $checkinClass = CheckinLicenseNotification::class;
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
public function getCompanyableParents()
|
|
|
|
{
|
|
|
|
return ['asset', 'license'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function license()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\License', 'license_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\User', 'assigned_to')->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asset()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed();
|
|
|
|
}
|
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
|
|
|
}
|