From 01037cf9cb66f78f45c066be69d136c75105b97d Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 10 Aug 2021 18:26:43 -0700 Subject: [PATCH] initial commit: adds migration, input area and transformer modifications for depreciation minimum value [ch15358] --- .../Api/DepreciationsController.php | 4 +-- .../Controllers/DepreciationsController.php | 6 ++-- .../Transformers/DepreciationsTransformer.php | 1 + ..._005206_add_depreciation_minimum_value.php | 32 +++++++++++++++++++ package-lock.json | 10 ++++-- .../lang/en/admin/depreciations/general.php | 1 + resources/views/depreciations/edit.blade.php | 11 ++++++- 7 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 database/migrations/2021_08_11_005206_add_depreciation_minimum_value.php diff --git a/app/Http/Controllers/Api/DepreciationsController.php b/app/Http/Controllers/Api/DepreciationsController.php index 931d751d22..12c2a9ac9b 100644 --- a/app/Http/Controllers/Api/DepreciationsController.php +++ b/app/Http/Controllers/Api/DepreciationsController.php @@ -20,9 +20,9 @@ class DepreciationsController extends Controller public 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.php index 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.php index 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.php new file mode 100644 index 0000000000..a6a646e127 --- /dev/null +++ b/database/migrations/2021_08_11_005206_add_depreciation_minimum_value.php @@ -0,0 +1,32 @@ +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.json index 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.php index 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.php index 95df4eda1a..3a011cfb16 100755 --- a/resources/views/depreciations/edit.blade.php +++ b/resources/views/depreciations/edit.blade.php @@ -22,5 +22,14 @@ {!! $errors->first('months', '') !!} - + +
+ +
+ +
+ {!! $errors->first('depreciation_min', '') !!} +
@stop