mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-22 19:21:58 -08:00
Added type casting and a few more validation rules
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
a44d1cc0cf
commit
fa5134603f
|
@ -76,6 +76,14 @@ class Asset extends Depreciable
|
|||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
'model_id' => 'integer',
|
||||
'status_id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
'location_id' => 'integer',
|
||||
'rtd_company_id' => 'integer',
|
||||
'supplier_id' => 'integer',
|
||||
];
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'max:255|nullable',
|
||||
|
@ -86,13 +94,15 @@ class Asset extends Depreciable
|
|||
'physical' => 'numeric|max:1|nullable',
|
||||
'checkout_date' => 'date|max:10|min:10|nullable',
|
||||
'checkin_date' => 'date|max:10|min:10|nullable',
|
||||
'supplier_id' => 'numeric|nullable',
|
||||
'supplier_id' => 'exists:suppliers,id|numeric|nullable',
|
||||
'location_id' => 'exists:locations,id|nullable',
|
||||
'rtd_location_id' => 'exists:locations,id|nullable',
|
||||
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
||||
'status' => 'integer',
|
||||
'serial' => 'unique_serial|nullable',
|
||||
'purchase_cost' => 'numeric|nullable',
|
||||
'next_audit_date' => 'date|nullable',
|
||||
'last_audit_date' => 'date|nullable',
|
||||
'next_audit_date' => 'date|nullable',
|
||||
'last_audit_date' => 'date|nullable',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,11 +24,11 @@ class AssetModel extends SnipeModel
|
|||
|
||||
// Declare the rules for the model validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:1|max:255',
|
||||
'name' => 'required|min:1|max:255',
|
||||
'model_number' => 'max:255|nullable',
|
||||
'category_id' => 'required|integer|exists:categories,id',
|
||||
'manufacturer_id' => 'required|integer|exists:manufacturers,id',
|
||||
'eol' => 'integer:min:0|max:240|nullable',
|
||||
'eol' => 'integer:min:0|max:240|nullable',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,12 @@ class Category extends SnipeModel
|
|||
protected $table = 'categories';
|
||||
protected $hidden = ['user_id','deleted_at'];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
|
|
|
@ -20,10 +20,15 @@ class Consumable extends SnipeModel
|
|||
protected $dates = ['deleted_at', 'purchase_date'];
|
||||
protected $table = 'consumables';
|
||||
protected $casts = [
|
||||
'requestable' => 'boolean'
|
||||
'requestable' => 'boolean',
|
||||
'category_id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
'qty' => 'integer',
|
||||
'min_amt' => 'integer',
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Category validation rules
|
||||
*/
|
||||
|
|
|
@ -19,6 +19,12 @@ class Department extends SnipeModel
|
|||
|
||||
use ValidatingTrait, UniqueUndeletedTrait;
|
||||
|
||||
protected $casts = [
|
||||
'manager_id' => 'integer',
|
||||
'location_id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
];
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|max:255',
|
||||
'location_id' => 'numeric|nullable',
|
||||
|
|
|
@ -36,6 +36,13 @@ class License extends Depreciable
|
|||
|
||||
protected $guarded = 'id';
|
||||
protected $table = 'licenses';
|
||||
|
||||
protected $casts = [
|
||||
'seats' => 'integer',
|
||||
'category_id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
];
|
||||
|
||||
protected $rules = array(
|
||||
'name' => 'required|string|min:3|max:255',
|
||||
'seats' => 'required|min:1|max:999|integer',
|
||||
|
|
|
@ -27,9 +27,14 @@ class Location extends SnipeModel
|
|||
'address2' => 'max:80|nullable',
|
||||
'zip' => 'min:3|max:10|nullable',
|
||||
'manager_id' => 'exists:users,id|nullable',
|
||||
'parent_id' => 'nullable|different:id',
|
||||
'parent_id' => 'nullable|exists:locations,id|different:id',
|
||||
);
|
||||
|
||||
protected $casts = [
|
||||
'parent_id' => 'integer',
|
||||
'manager_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
|
|
|
@ -55,7 +55,10 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
];
|
||||
|
||||
protected $casts = [
|
||||
'activated' => 'boolean',
|
||||
'activated' => 'boolean',
|
||||
'manager_id' => 'integer',
|
||||
'location_id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -71,7 +74,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
'password' => 'required|min:8',
|
||||
'locale' => 'max:10|nullable',
|
||||
'website' => 'url|nullable',
|
||||
'manager_id' => 'nullable|different:id',
|
||||
'manager_id' => 'nullable|exists:users,id|different:users.id',
|
||||
'location_id' => 'exists:locations,id|nullable',
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
|
Loading…
Reference in a new issue