mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Added fieldset sync
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
5eeca937cb
commit
15dc4e4779
|
@ -94,6 +94,18 @@ class CustomFieldsetsController extends Controller
|
||||||
$fieldset->fill($request->all());
|
$fieldset->fill($request->all());
|
||||||
|
|
||||||
if ($fieldset->save()) {
|
if ($fieldset->save()) {
|
||||||
|
// Sync fieldset with auto_add_to_fieldsets
|
||||||
|
$fields = CustomField::select('id')->where('auto_add_to_fieldsets', '=', '1')->get();
|
||||||
|
|
||||||
|
if ($fields->count() > 0) {
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$field_ids[] = $field->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fieldset->fields()->sync($field_ids);
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.create.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.create.success')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,16 +93,27 @@ class CustomFieldsetsController extends Controller
|
||||||
{
|
{
|
||||||
$this->authorize('create', CustomField::class);
|
$this->authorize('create', CustomField::class);
|
||||||
|
|
||||||
$cfset = new CustomFieldset([
|
$fieldset = new CustomFieldset([
|
||||||
'name' => e($request->get('name')),
|
'name' => e($request->get('name')),
|
||||||
'user_id' => Auth::user()->id,
|
'user_id' => Auth::user()->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$validator = Validator::make($request->all(), $cfset->rules);
|
$validator = Validator::make($request->all(), $fieldset->rules);
|
||||||
if ($validator->passes()) {
|
|
||||||
$cfset->save();
|
|
||||||
|
|
||||||
return redirect()->route('fieldsets.show', [$cfset->id])
|
if ($validator->passes()) {
|
||||||
|
$fieldset->save();
|
||||||
|
|
||||||
|
// Sync fieldset with auto_add_to_fieldsets
|
||||||
|
$fields = CustomField::select('id')->where('auto_add_to_fieldsets', '=', '1')->get();
|
||||||
|
if ($fields->count() > 0) {
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$field_ids[] = $field->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fieldset->fields()->sync($field_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('fieldsets.show', [$fieldset->id])
|
||||||
->with('success', trans('admin/custom_fields/message.fieldset.create.success'));
|
->with('success', trans('admin/custom_fields/message.fieldset.create.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue