Pass the model_id variable in the controller and get it only if we are cloning the asset model

This commit is contained in:
Ivan Nieto Vivanco 2023-08-28 16:23:26 -06:00
parent a12a68e4e9
commit 4e4ba38038
2 changed files with 3 additions and 7 deletions

View file

@ -286,6 +286,7 @@ class AssetModelsController extends Controller
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);
}

View file

@ -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')])