File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ public function getIndex() : View | RedirectResponse
4141 'licenses ' ,
4242 )->find (auth ()->id ());
4343
44+ if (Setting::getSettings ()->show_assigned_assets ) {
45+ $ user ->load ([
46+ 'assets.assignedAssets ' ,
47+ 'assets.assignedAssets.model ' ,
48+ 'assets.assignedAssets.model.fieldset.fields ' ,
49+ ]);
50+ }
51+
4452 $ field_array = array ();
4553
4654 // Loop through all the custom fields that are applied to any model the user has assigned
@@ -58,6 +66,20 @@ public function getIndex() : View | RedirectResponse
5866 }
5967 }
6068
69+ foreach ($ asset ->assignedAssets as $ assignedAsset ) {
70+ // Make sure the model has a custom fieldset before trying to loop through the associated fields
71+ if ($ assignedAsset ->model ->fieldset ) {
72+
73+ foreach ($ assignedAsset ->model ->fieldset ->fields as $ field ) {
74+ // check and make sure they're allowed to see the value of the custom field
75+ if ($ field ->display_in_user_view == '1 ' ) {
76+ $ field_array [$ field ->db_column ] = $ field ->name ;
77+ }
78+
79+ }
80+ }
81+ }
82+
6183 }
6284
6385 // Since some models may re-use the same fieldsets/fields, let's make the array unique so we don't repeat columns
Original file line number Diff line number Diff line change @@ -455,15 +455,14 @@ class="table table-striped snipe-table"
455455
456456 </thead >
457457 <tbody >
458- @php
459- $counter = 1
460- @endphp
461458 @foreach ($user -> assets as $asset )
462- <x-asset-table-row :asset =" $asset" :field_array =" $field_array" :counter =" $counter " />
459+ <x-asset-table-row :asset =" $asset" :field_array =" $field_array" :counter =" $loop->iteration " />
463460
464- @php
465- $counter ++
466- @endphp
461+ @if ($settings -> show_assigned_assets && $asset -> assignedAssets -> count () )
462+ @foreach ($asset -> assignedAssets as $assignedAsset )
463+ <x-asset-table-row :asset =" $assignedAsset" :field_array =" $field_array" :counter =" $loop->parent->iteration . '.' . $loop->iteration" />
464+ @endforeach
465+ @endif
467466 @endforeach
468467 </tbody >
469468 </table >
You can’t perform that action at this time.
0 commit comments