From 804a788a27535a57662dac8e660749d60e53ae6c Mon Sep 17 00:00:00 2001 From: slong753 Date: Tue, 28 Mar 2023 20:31:24 -0500 Subject: [PATCH] initial fetch working --- .../Controllers/Assets/BulkAssetsController.php | 15 ++++++++++++++- resources/views/hardware/bulk.blade.php | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 7f9e812ab4..f0f01c6577 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -13,6 +13,8 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Session; use App\Http\Requests\AssetCheckoutRequest; +use App\Models\CustomField; +use Illuminate\Support\Collection; class BulkAssetsController extends Controller { @@ -40,6 +42,16 @@ class BulkAssetsController extends Controller session(['bulk_back_url' => $bulk_back_url]); $asset_ids = array_values(array_unique($request->input('ids'))); + + //custom fields logic for bulk edit + $asset_custom_field = Asset::whereIn('id', $asset_ids)->whereHas('model', function ($query) { + return $query->where('fieldset_id', '!=', null); + })->get(); + $custom_fields = new Collection(); + foreach ($asset_custom_field as $asset_key => $asset) { + $custom_fields->push($asset->model->fieldset->fields); + } + $custom_fields = $custom_fields->flatten()->unique('id'); if ($request->filled('bulk_actions')) { switch ($request->input('bulk_actions')) { @@ -59,7 +71,8 @@ class BulkAssetsController extends Controller case 'edit': return view('hardware/bulk') ->with('assets', $asset_ids) - ->with('statuslabel_list', Helper::statusLabelList()); + ->with('statuslabel_list', Helper::statusLabelList()) + ->with('custom_fields', $custom_fields); } } diff --git a/resources/views/hardware/bulk.blade.php b/resources/views/hardware/bulk.blade.php index 1cacc4086f..76299871c3 100755 --- a/resources/views/hardware/bulk.blade.php +++ b/resources/views/hardware/bulk.blade.php @@ -28,6 +28,8 @@
+ +
@@ -181,6 +183,16 @@
+ @foreach ($custom_fields as $key => $value) +

+ +

+ @endforeach + + + @foreach ($assets as $key => $value) @endforeach