22 'name' =>
'required|min:2|max:255',
23 'modelno' =>
'min:1|max:255',
24 'category_id' =>
'required|integer',
25 'manufacturer_id' =>
'required|integer',
26 'eol' =>
'integer:min:0|max:240',
27 'user_id' =>
'integer',
45 protected $fillable = [
'name',
'manufacturer_id',
'category_id',
'eol'];
51 return $this->hasMany(
'\App\Models\Asset',
'model_id');
56 return $this->belongsTo(
'\App\Models\Category',
'category_id');
61 return $this->belongsTo(
'\App\Models\Depreciation',
'depreciation_id');
66 return $this->belongsTo(
'\App\Models\User',
'user_id');
71 return $this->belongsTo(
'\App\Models\Manufacturer',
'manufacturer_id');
76 return $this->belongsTo(
'\App\Models\CustomFieldset',
'fieldset_id');
82 $Parsedown = new \Parsedown();
85 return $Parsedown->text(e($this->note));
105 return $query->whereNotNull(
'deleted_at');
122 return $query->whereIn(
'category_id', $categoryIdListing);
136 return $query->where(
'name',
'LIKE',
"%$search%")
137 ->orWhere(
'modelno',
'LIKE',
"%$search%")
138 ->orWhere(
function ($query) use ($search) {
139 $query->whereHas(
'depreciation',
function ($query) use ($search) {
140 $query->where(
'name',
'LIKE',
'%'.$search.
'%');
143 ->orWhere(
function ($query) use ($search) {
144 $query->whereHas(
'category',
function ($query) use ($search) {
145 $query->where(
'name',
'LIKE',
'%'.$search.
'%');
148 ->orWhere(
function ($query) use ($search) {
149 $query->whereHas(
'manufacturer',
function ($query) use ($search) {
150 $query->where(
'name',
'LIKE',
'%'.$search.
'%');
scopeTextSearch($query, $search)
Query builder scope to search on text.
scopeInCategory($query, array $categoryIdListing)
scopeInCategory Get all models that are in the array of category ids
scopeDeleted($query)
BEGIN QUERY SCOPES