11<?php
22
3- class Asset extends Elegant
3+ class Asset extends Depreciable
44{
55 use SoftDeletingTrait;
66 protected $ dates = ['deleted_at ' ];
@@ -15,24 +15,19 @@ class Asset extends Elegant
1515 'notes ' => 'alpha_space ' ,
1616 'pysical ' => 'integer ' ,
1717 'supplier_id ' => 'integer ' ,
18- //'asset_tag' => 'required|alpha_space|min:3|max:255|unique:assets,asset_tag,{id},deleted_at,NULL',
19- //'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL',
20- //'asset_tag' => 'required|alpha_space|min:2|max:255|unique:assets,asset_tag,deleted_at,NULL',
2118 'asset_tag ' => 'required|alpha_space|min:3|max:255|unique:assets,asset_tag,{id} ' ,
22- 'serial ' => 'required|alpha_dash|min:3|max:255|unique:assets,serial,{id} ' ,
19+ // 'serial' => 'required|alpha_dash|min:3|max:255|unique:assets,serial,{id}',
2320 'status ' => 'integer '
2421 );
2522
26- /**
27- * Handle depreciation
28- */
29- public function depreciate ()
23+ public function depreciation ()
3024 {
31- return $ this ->getCurrentValue (
32- Model::find ($ this ->model_id )->depreciation_id ,
33- $ this ->purchase_cost ,
34- $ this ->purchase_date
35- );
25+ return $ this ->model ->belongsTo ('Depreciation ' ,'depreciation_id ' );
26+ }
27+
28+ public function get_depreciation ()
29+ {
30+ return $ this ->model ->depreciation ;
3631 }
3732
3833 /**
@@ -132,33 +127,6 @@ public function warrantee_expires()
132127 return date_format ($ date , 'Y-m-d ' );
133128 }
134129
135- public function months_until_depreciated ()
136- {
137- $ today = date ("Y-m-d " );
138-
139- // @link http://www.php.net/manual/en/class.datetime.php
140- $ d1 = new DateTime ($ today );
141- $ d2 = new DateTime ($ this ->depreciated_date ());
142-
143- // @link http://www.php.net/manual/en/class.dateinterval.php
144- $ interval = $ d1 ->diff ($ d2 );
145- return $ interval ;
146- }
147-
148-
149- public function depreciated_date ()
150- {
151- $ date = date_create ($ this ->purchase_date );
152- date_add ($ date , date_interval_create_from_date_string ($ this ->depreciation ->months .' months ' ));
153- return date_format ($ date , 'Y-m-d ' );
154- }
155-
156-
157- public function depreciation ()
158- {
159- return $ this ->model ->belongsTo ('Depreciation ' ,'depreciation_id ' );
160- }
161-
162130 public function model ()
163131 {
164132 return $ this ->belongsTo ('Model ' ,'model_id ' );
@@ -167,13 +135,13 @@ public function model()
167135 /**
168136 * Get the license seat information
169137 **/
170- public function licenses ()
138+ public function licenses ()
171139 {
172140 return $ this ->belongsToMany ('License ' , 'license_seats ' , 'asset_id ' , 'license_id ' );
173141
174142 }
175143
176- public function licenseseats ()
144+ public function licenseseats ()
177145 {
178146 return $ this ->hasMany ('LicenseSeat ' , 'asset_id ' );
179147 }
@@ -210,7 +178,7 @@ public function eol_date()
210178 /**
211179 * Get total assets
212180 */
213- public static function autoincrement_asset ()
181+ public static function autoincrement_asset ()
214182 {
215183 $ settings = Setting::getSettings ();
216184
0 commit comments