initial fetch working

This commit is contained in:
slong753 2023-03-28 20:31:24 -05:00
parent e03a961bcc
commit 804a788a27
2 changed files with 26 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -28,6 +28,8 @@
<div class="box box-default">
<div class="box-body">
<!-- Purchase Date -->
<div class="form-group {{ $errors->has('purchase_date') ? ' has-error' : '' }}">
<label for="purchase_date" class="col-md-3 control-label">{{ trans('admin/hardware/form.date') }}</label>
@ -181,6 +183,16 @@
</div>
</div>
@foreach ($custom_fields as $key => $value)
<p>
<label>
({{ $value->id }}) | {{ $value->name}} - {{ $value->format }}
</label>
</p>
@endforeach
@foreach ($assets as $key => $value)
<input type="hidden" name="ids[{{ $value }}]" value="1">
@endforeach