mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Refactor into method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
e983ee4d0f
commit
19fb45f488
|
@ -89,16 +89,8 @@ class AssetCheckinController extends Controller
|
|||
$asset->status_id = e($request->get('status_id'));
|
||||
}
|
||||
|
||||
// Check to see if any of the custom fields were included on the form and if they have any values
|
||||
if (($asset->model) && ($asset->model->fieldset) && ($asset->model->fieldset->fields)) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
if ($field->display_checkin == 1) {
|
||||
if ($request->has($field->db_column)) {
|
||||
$asset->{$field->db_column} = $request->get($field->db_column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add any custom fields that should be included in the checkout
|
||||
$asset->customFieldsForCheckinCheckout('display_checkin');
|
||||
|
||||
$this->migrateLegacyLocations($asset);
|
||||
|
||||
|
@ -136,16 +128,9 @@ class AssetCheckinController extends Controller
|
|||
});
|
||||
|
||||
session()->put('redirect_option', $request->get('redirect_option'));
|
||||
// Check to see if any of the custom fields were included on the form and if they have any values
|
||||
if (($asset->model) && ($asset->model->fieldset) && ($asset->model->fieldset->fields)) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
if ($field->display_checkin == 1) {
|
||||
if ($request->filled($field->db_column)) {
|
||||
$asset->{$field->db_column} = $request->get($field->db_column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any custom fields that should be included in the checkout
|
||||
$asset->customFieldsForCheckinCheckout('display_checkin');
|
||||
|
||||
if ($asset->save()) {
|
||||
|
||||
|
|
|
@ -99,17 +99,8 @@ class AssetCheckoutController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Check to see if any of the custom fields were included on the form and if they have any values
|
||||
if (($asset->model) && ($asset->model->fieldset) && ($asset->model->fieldset->fields)) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
if ($field->display_checkout == 1) {
|
||||
if ($request->has($field->db_column)) {
|
||||
$asset->{$field->db_column} = $request->get($field->db_column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any custom fields that should be included in the checkout
|
||||
$asset->customFieldsForCheckinCheckout('display_checkout');
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
|
|
|
@ -413,6 +413,20 @@ class Asset extends Depreciable
|
|||
return $this->rules;
|
||||
}
|
||||
|
||||
public function customFieldsForCheckinCheckout($type) {
|
||||
// Check to see if any of the custom fields were included on the form and if they have any values
|
||||
if (($this->model) && ($this->model->fieldset) && ($this->model->fieldset->fields)) {
|
||||
foreach ($this->model->fieldset->fields as $field) {
|
||||
|
||||
if ($field->{$type} == 1) {
|
||||
if (request()->has($field->db_column)) {
|
||||
$this->{$field->db_column} = request()->get($field->db_column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Establishes the asset -> depreciation relationship
|
||||
|
|
Loading…
Reference in a new issue