Skip to content

Commit

Permalink
Pass the model_id variable in the controller and get it only if we ar…
Browse files Browse the repository at this point in the history
…e cloning the asset model
  • Loading branch information
inietov committed Aug 28, 2023
1 parent a12a68e commit 4e4ba38
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/AssetModelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public function getClone($modelId = null)
return view('models/edit')
->with('depreciation_list', Helper::depreciationList())
->with('item', $model)
->with('model_id', $model_to_clone->id)
->with('clone_model', $model_to_clone);
}

Expand Down
9 changes: 2 additions & 7 deletions resources/views/models/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@
</div>
</div>

@php
$model_id = $item->id;
if (is_null($model_id)){
$model_id = $item->getOriginal('id');
}
@endphp
<!-- Custom Fieldset -->
@livewire('custom-field-set-default-values-for-model',["model_id" => $model_id])
<!-- If $item->id is null we are cloning the model and we need the $model_id variable -->
@livewire('custom-field-set-default-values-for-model',["model_id" => ($item->id) ? $item->id : $model_id])

@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/models/general.requestable')])
Expand Down

0 comments on commit 4e4ba38

Please sign in to comment.