diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index f7fea069c12f..e0f3fe6bf409 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -189,10 +189,10 @@ public function postEdit($assetId = null) // Declare the rules for the form validation $rules = array( - 'name' => 'required|min:3', - 'asset_tag' => 'required|min:3', + 'name' => 'required|alpha_dash|min:3', + 'asset_tag' => 'required|alpha_dash|min:3', 'model_id' => 'required', - 'serial' => 'required|min:3', + 'serial' => 'required|alpha_dash|min:3', 'warranty_months' => 'integer|min:1', ); diff --git a/app/models/Asset.php b/app/models/Asset.php index 43dd6150e1dc..a3f58192ad2e 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -8,9 +8,8 @@ class Asset extends Elegant { 'name' => 'required|alpha_dash|min:3', 'asset_tag' => 'required|min:3|unique:assets', 'model_id' => 'required', - 'serial' => 'required|min:3', + 'serial' => 'required|alpha_dash|min:3', 'warranty_months' => 'integer|min:1', - 'purchase_cost' => 'integer|min:1', ); @@ -113,6 +112,15 @@ public function warrantee_expires() date_add($date, date_interval_create_from_date_string($this->warranty_months.' months')); return date_format($date, 'Y-m-d'); + } + + public function months_until_depreciated() + { + + $date = date_create($this->purchase_date); + date_add($date, date_interval_create_from_date_string($this->depreciation()->months.' months')); + return date_format($date, 'Y-m-d'); + } public function depreciation()