Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Entities/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,16 @@ public static function getItemWithRelations($id)
public static function syncWithFormGroups(ContentType $content_type, $groups_array)
{

$stored_groups = $content_type->groups()->get()->pluck('slug')->toArray();

$stored_groups = $content_type->groups()->get()->pluck('id')->toArray();

$input_groups = collect($groups_array)->pluck('id')->toArray();
$input_groups = collect($groups_array)->pluck('slug')->toArray();
$groups_to_delete = array_diff($stored_groups, $input_groups);


if(count($groups_to_delete) > 0)
{
FormGroup::deleteItems($groups_to_delete);
}



foreach($groups_array as $g_index => $group)
{

Expand All @@ -362,6 +358,11 @@ public static function syncWithFormGroups(ContentType $content_type, $groups_arr
$stored_group = $content_type->groups()->create($group_fillable);
}

foreach ($group['fields'] as $key => $field){
if(!isset($field['slug']) || !$field['slug']){
$group['fields'][$key]['slug'] = Str::slug($field['name']);
}
}

FormGroup::syncWithFormFields($stored_group, $group['fields']);

Expand Down
4 changes: 2 additions & 2 deletions Http/Controllers/Frontend/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function page(Request $request, $permalink)
if (view()->exists($view)) {
return view($view);
} else {
throw new \Exception($view." not found.");
return abort(404);
}

}
Expand All @@ -60,7 +60,7 @@ public function content(Request $request, $content_type, $permalink)
if (view()->exists($view)) {
return view($view);
} else {
throw new \Exception($view." not found.");
return abort(404);
}

}
Expand Down