A free open source IT asset/license management system
initial commit: adds migration, input area and transformer modifications for depreciation minimum value [ch15358]
Godfrey M01037cf9cb66
diff --git a/app/Http/Controllers/Api/DepreciationsController.php b/app/Http/Controllers/Api/DepreciationsController.phpindex 931d751d22..12c2a9ac9b 100644--- a/app/Http/Controllers/Api/DepreciationsController.php+++ b/app/Http/Controllers/Api/DepreciationsController.php@@ -20,9 +20,9 @@ class DepreciationsController extends Controllerpublic function index(Request $request){$this->authorize('view', Depreciation::class);- $allowed_columns = ['id','name','months','created_at'];+ $allowed_columns = ['id','name','months','depreciation_min','created_at'];- $depreciations = Depreciation::select('id','name','months','user_id','created_at','updated_at');+ $depreciations = Depreciation::select('id','name','months','depreciation_min','user_id','created_at','updated_at');if ($request->filled('search')) {$depreciations = $depreciations->TextSearch($request->input('search'));diff --git a/app/Http/Controllers/DepreciationsController.php b/app/Http/Controllers/DepreciationsController.phpindex d7177829ea..92cc2326cd 100755--- a/app/Http/Controllers/DepreciationsController.php+++ b/app/Http/Controllers/DepreciationsController.php@@ -69,6 +69,7 @@ class DepreciationsController extends Controller// Depreciation data$depreciation->name = $request->input('name');$depreciation->months = $request->input('months');+ $depreciation->depreciations_min= $request->input('depreciation_min');$depreciation->user_id = Auth::id();// Was the asset created?@@ -125,8 +126,9 @@ class DepreciationsController extends Controller$this->authorize('update', $depreciation);// Depreciation data- $depreciation->name = $request->input('name');- $depreciation->months = $request->input('months');+ $depreciation->name = $request->input('name');+ $depreciation->months = $request->input('months');+ $depreciation->depreciation_min = $request->input('depreciation_min');// Was the asset created?if ($depreciation->save()) {diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.phpindex 0b9d011e23..bd391adf6b 100644--- a/app/Http/Transformers/DepreciationsTransformer.php+++ b/app/Http/Transformers/DepreciationsTransformer.php@@ -24,6 +24,7 @@ class DepreciationsTransformer'id' => (int) $depreciation->id,'name' => e($depreciation->name),'months' => $depreciation->months . ' '. trans('general.months'),+ 'depreciation_min' => $depreciation->depreciation_min,'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime'),];diff --git a/database/migrations/2021_08_11_005206_add_depreciation_minimum_value.php b/database/migrations/2021_08_11_005206_add_depreciation_minimum_value.phpnew file mode 100644index 0000000000..a6a646e127--- /dev/null+++ b/database/migrations/2021_08_11_005206_add_depreciation_minimum_value.php@@ -0,0 +1,32 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++class AddDepreciationMinimumValue extends Migration+{+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::table('depreciations', function (Blueprint $table) {+ $table->decimal('depreciation_min', 8,2)->after('months')->nullable();+ });+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ Schema::table('depreciations', function (Blueprint $table) {+ $table->dropColumn('depreciation_min');+ });+ }+}diff --git a/package-lock.json b/package-lock.jsonindex b0bfa7df2b..fe9d234a9d 100644--- a/package-lock.json+++ b/package-lock.json@@ -11629,7 +11629,8 @@"picomatch": {"version": "2.2.2","resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",- "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg=="+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",+ "optional": true},"pify": {"version": "2.3.0",@@ -14235,6 +14236,7 @@"version": "4.0.1","resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz","integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",+ "optional": true,"requires": {"is-extglob": "^2.1.1"}@@ -14248,7 +14250,8 @@"normalize-path": {"version": "3.0.0","resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",- "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",+ "optional": true},"readdirp": {"version": "3.4.0",@@ -18323,7 +18326,8 @@"version": "2.2.2","resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz","integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",- "dev": true+ "dev": true,+ "optional": true},"pify": {"version": "2.3.0",diff --git a/resources/lang/en/admin/depreciations/general.php b/resources/lang/en/admin/depreciations/general.phpindex 1fca0e2cb7..a5dec994c2 100644--- a/resources/lang/en/admin/depreciations/general.php+++ b/resources/lang/en/admin/depreciations/general.php@@ -8,5 +8,6 @@ return array('depreciation_name' => 'Depreciation Name','number_of_months' => 'Number of Months','update' => 'Update Depreciation',+ 'depreciation_min' => 'Minimum Value after Depreciation');diff --git a/resources/views/depreciations/edit.blade.php b/resources/views/depreciations/edit.blade.phpindex 95df4eda1a..3a011cfb16 100755--- a/resources/views/depreciations/edit.blade.php+++ b/resources/views/depreciations/edit.blade.php@@ -22,5 +22,14 @@</div>{!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}</div>-+<!-- Depreciation Minimum -->+<div class="form-group {{ $errors->has('depreciation_min') ? ' has-error' : '' }}">+ <label for="depreciation_min" class="col-md-3 control-label">+ {{ trans('admin/depreciations/general.depreciation_min') }}+ </label>+ <div class="col-md-2" style="padding-left:0px">+ <input class="form-control" name="depreciation_min" id="depreciation_min" value="{{ Request::old('depreciation_min', $item->depreciation_min) }}" style="width: 80px; margin-left:15px" />+ </div>+ {!! $errors->first('depreciation_min', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}+</div>@stop