24 'name' =>
'required|string|min:3|max:255',
25 'serial' =>
'required|min:5',
26 'seats' =>
'required|min:1|max:10000|integer',
27 'license_email' =>
'email|min:0|max:120',
28 'license_name' =>
'string|min:0|max:100',
30 'notes' =>
'string|min:0',
31 'company_id' =>
'integer',
36 return $this->belongsTo(
'\App\Models\Company',
'company_id');
44 return $this->belongsToMany(
'\App\Models\User',
'license_seats',
'assigned_to',
'license_id');
52 return $this->hasMany(
'\App\Models\Actionlog',
'asset_id')
53 ->where(
'asset_type',
'=',
'software')
54 ->orderBy(
'created_at',
'desc');
62 return $this->hasMany(
'\App\Models\Actionlog',
'asset_id')
63 ->where(
'asset_type',
'=',
'software')
64 ->where(
'action_type',
'=',
'uploaded')
65 ->whereNotNull(
'filename')
66 ->orderBy(
'created_at',
'desc');
75 return $this->belongsTo(
'\App\Models\User',
'user_id');
83 return LicenseSeat::whereNull(
'deleted_at')
93 return LicenseSeat::where(
'license_id',
'=', $this->
id)
94 ->whereNull(
'deleted_at')
104 return LicenseSeat::whereNull(
'assigned_to')
105 ->whereNull(
'asset_id')
106 ->whereNull(
'deleted_at')
115 return LicenseSeat::whereNull(
'assigned_to')
116 ->whereNull(
'asset_id')
117 ->where(
'license_id',
'=', $this->
id)
118 ->whereNull(
'deleted_at')
129 return \App\Models\LicenseSeat::where(
'license_id',
'=', $this->
id)
130 ->where(
function ($query) {
132 $query->whereNotNull(
'assigned_to')
133 ->orWhereNotNull(
'asset_id');
144 $diff = ($total - $taken);
155 $diff = ($avail + $taken);
164 return $this->hasMany(
'\App\Models\LicenseSeat');
169 return $this->belongsTo(
'\App\Models\Supplier',
'supplier_id');
174 $seat = LicenseSeat::where(
'license_id',
'=', $this->
id)
175 ->whereNull(
'deleted_at')
176 ->whereNull(
'assigned_to')
177 ->whereNull(
'asset_id')
185 return License::whereNotNull(
'expiration_date')
186 ->whereNull(
'deleted_at')
187 ->whereRaw(DB::raw(
'DATE_SUB(`expiration_date`,INTERVAL '.$days.
' DAY) <= DATE(NOW()) '))
188 ->where(
'expiration_date',
'>', date(
"Y-m-d"))
189 ->orderBy(
'expiration_date',
'ASC')
205 return $query->where(
function ($query) use ($search) {
207 $query->where(
'name',
'LIKE',
'%'.$search.
'%')
208 ->orWhere(
'serial',
'LIKE',
'%'.$search.
'%')
209 ->orWhere(
'notes',
'LIKE',
'%'.$search.
'%')
210 ->orWhere(
'order_number',
'LIKE',
'%'.$search.
'%')
211 ->orWhere(
'purchase_date',
'LIKE',
'%'.$search.
'%')
212 ->orWhere(
'purchase_cost',
'LIKE',
'%'.$search.
'%');
uploads()
Get uploads for this asset.
totalcount()
Get the total number of seats.
adminuser()
Get admin user for this asset.
assignedusers()
Get the assigned user.
scopeTextSearch($query, $search)
Query builder scope to search on text.
static assetcount()
Get total licenses.
availcount()
Get the number of available seats.
static availassetcount()
Get total licenses not checked out.
totalSeatsByLicenseID()
Get total licenses.
assignedcount()
Get the number of assigned seats.
static getExpiringLicenses($days=60)
licenseseats()
Get license seat data.
assetlog()
Get asset logs for this asset.