diff --git a/Entities/ContentType.php b/Entities/ContentType.php index f10ac66..3f67be6 100644 --- a/Entities/ContentType.php +++ b/Entities/ContentType.php @@ -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) { @@ -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']); diff --git a/Http/Controllers/Frontend/PublicController.php b/Http/Controllers/Frontend/PublicController.php index eb03801..5d3f876 100644 --- a/Http/Controllers/Frontend/PublicController.php +++ b/Http/Controllers/Frontend/PublicController.php @@ -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); } } @@ -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); } } diff --git a/Vue/vaahvue b/Vue/vaahvue index e959abf..177129f 160000 --- a/Vue/vaahvue +++ b/Vue/vaahvue @@ -1 +1 @@ -Subproject commit e959abf7eaf2537904fd69cfdca2d0b262568485 +Subproject commit 177129fb5c616e6c882d8d6d9abd1e1be4462fb5