1
1
<?php
2
2
3
- class Asset extends Elegant
3
+ class Asset extends Depreciable
4
4
{
5
5
use SoftDeletingTrait;
6
6
protected $ dates = ['deleted_at ' ];
@@ -15,24 +15,19 @@ class Asset extends Elegant
15
15
'notes ' => 'alpha_space ' ,
16
16
'pysical ' => 'integer ' ,
17
17
'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',
21
18
'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}',
23
20
'status ' => 'integer '
24
21
);
25
22
26
- /**
27
- * Handle depreciation
28
- */
29
- public function depreciate ()
23
+ public function depreciation ()
30
24
{
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 ;
36
31
}
37
32
38
33
/**
@@ -132,33 +127,6 @@ public function warrantee_expires()
132
127
return date_format ($ date , 'Y-m-d ' );
133
128
}
134
129
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
-
162
130
public function model ()
163
131
{
164
132
return $ this ->belongsTo ('Model ' ,'model_id ' );
@@ -167,13 +135,13 @@ public function model()
167
135
/**
168
136
* Get the license seat information
169
137
**/
170
- public function licenses ()
138
+ public function licenses ()
171
139
{
172
140
return $ this ->belongsToMany ('License ' , 'license_seats ' , 'asset_id ' , 'license_id ' );
173
141
174
142
}
175
143
176
- public function licenseseats ()
144
+ public function licenseseats ()
177
145
{
178
146
return $ this ->hasMany ('LicenseSeat ' , 'asset_id ' );
179
147
}
@@ -210,7 +178,7 @@ public function eol_date()
210
178
/**
211
179
* Get total assets
212
180
*/
213
- public static function autoincrement_asset ()
181
+ public static function autoincrement_asset ()
214
182
{
215
183
$ settings = Setting::getSettings ();
216
184
0 commit comments