Snipe-IT
Open Source Asset Management
FEATURES
DEMO
DOWNLOAD
DOCUMENTATION
HOSTED SOLUTION
SUPPORT
Intro
Namespaces
Classes
Files
Misc
snipe-it
app
Models
Supplier.php
Go to the documentation of this file.
1
<?php
2
namespace
App\Models
;
3
4
use
Illuminate\Database\Eloquent\Model
;
5
use
Illuminate\Database\Eloquent\SoftDeletes
;
6
use
Watson\Validating\ValidatingTrait
;
7
8
class
Supplier
extends
Model
9
{
10
use
SoftDeletes
;
11
protected
$dates
= [
'deleted_at'
];
12
13
protected
$rules
= array(
14
'name'
=>
'required|min:3|max:255|unique:suppliers,name,NULL,deleted_at'
,
15
'address'
=>
'min:3|max:255'
,
16
'address2'
=>
'min:2|max:255'
,
17
'city'
=>
'min:3|max:255'
,
18
'state'
=>
'min:0|max:32'
,
19
'country'
=>
'min:0|max:2'
,
20
'fax'
=>
'min:7|max:20'
,
21
'phone'
=>
'min:7|max:20'
,
22
'contact'
=>
'min:0|max:255'
,
23
'notes'
=>
'min:0|max:255'
,
24
'email'
=>
'email|min:5|max:150'
,
25
'zip'
=>
'min:0|max:10'
,
26
'url'
=>
'min:3|max:250'
,
27
);
28
36
protected
$injectUniqueIdentifier
=
true
;
37
use
ValidatingTrait
;
38
44
protected
$fillable
= [
'name'
];
45
46
47
public
function
assets
()
48
{
49
return
$this->hasMany(
'\App\Models\Asset'
,
'supplier_id'
);
50
}
51
52
public
function
asset_maintenances
()
53
{
54
return
$this->hasMany(
'\App\Models\AssetMaintenance'
,
'supplier_id'
);
55
}
56
57
public
function
num_assets
()
58
{
59
return
$this->hasMany(
'\App\Models\Asset'
,
'supplier_id'
)->count();
60
}
61
62
public
function
licenses
()
63
{
64
return
$this->hasMany(
'\App\Models\License'
,
'supplier_id'
);
65
}
66
67
public
function
num_licenses
()
68
{
69
return
$this->hasMany(
'\App\Models\License'
,
'supplier_id'
)->count();
70
}
71
72
public
function
addhttp
($url)
73
{
74
if
(!preg_match(
"~^(?:f|ht)tps?://~i"
, $url)) {
75
$url =
"http://"
. $url;
76
}
77
return
$url;
78
}
79
88
public
function
scopeTextSearch
($query, $search)
89
{
90
91
return
$query->where(
function
($query) use ($search) {
92
93
$query->where(
'name'
,
'LIKE'
,
'%'
.$search.
'%'
);
94
});
95
}
96
}
App\Models\Supplier\$injectUniqueIdentifier
$injectUniqueIdentifier
Definition:
Supplier.php:36
App\Models\Supplier\$dates
$dates
Definition:
Supplier.php:11
Model
SoftDeletes
App\Models\Supplier\addhttp
addhttp($url)
Definition:
Supplier.php:72
App\Models\Supplier\scopeTextSearch
scopeTextSearch($query, $search)
Query builder scope to search on text.
Definition:
Supplier.php:88
App\Models\Supplier\$rules
$rules
Definition:
Supplier.php:13
App\Models\Supplier\licenses
licenses()
Definition:
Supplier.php:62
App\Models\Supplier\asset_maintenances
asset_maintenances()
Definition:
Supplier.php:52
App\Models
Definition:
Accessory.php:2
App\Models\Supplier\$fillable
$fillable
Definition:
Supplier.php:44
SoftDeletes
App\Models\Supplier\num_licenses
num_licenses()
Definition:
Supplier.php:67
ValidatingTrait
ValidatingTrait
App\Models\Supplier\assets
assets()
Definition:
Supplier.php:47
App\Models\Supplier\num_assets
num_assets()
Definition:
Supplier.php:57
App\Models\Supplier
Definition:
Supplier.php:8