mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
Allow auto increment through the API (#4690)
* Allow auto incrementing asset_id from the API when the setting is enabled * Cleaned up the if else statement * Added prefix to the orWhereRaw which causes a database error if the configuration uses a prefix * Auto incrementing through the API
This commit is contained in:
parent
b2469bb34f
commit
f786e07179
|
@ -344,7 +344,7 @@ class AssetsController extends Controller
|
|||
$asset->model_id = $request->get('model_id');
|
||||
$asset->order_number = $request->get('order_number');
|
||||
$asset->notes = $request->get('notes');
|
||||
$asset->asset_tag = $request->get('asset_tag');
|
||||
$asset->asset_tag = $request->get('asset_tag', Asset::autoincrement_asset());
|
||||
$asset->user_id = Auth::id();
|
||||
$asset->archived = '0';
|
||||
$asset->physical = '1';
|
||||
|
|
|
@ -36,13 +36,16 @@ class AssetRequest extends Request
|
|||
'checkin_date' => 'date',
|
||||
'supplier_id' => 'integer|nullable',
|
||||
'status' => 'integer|nullable',
|
||||
'asset_tag' => 'required',
|
||||
'purchase_cost' => 'numeric|nullable',
|
||||
"assigned_user" => 'sometimes:required_without_all:assigned_asset,assigned_location',
|
||||
"assigned_asset" => 'sometimes:required_without_all:assigned_user,assigned_location',
|
||||
"assigned_location" => 'sometimes:required_without_all:assigned_user,assigned_asset',
|
||||
];
|
||||
|
||||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
$rules['asset_tag'] = ($settings->auto_increment_assets == '1') ? 'max:255' : 'required';
|
||||
|
||||
$model = AssetModel::find($this->request->get('model_id'));
|
||||
|
||||
if (($model) && ($model->fieldset)) {
|
||||
|
|
Loading…
Reference in a new issue