@@ -75,6 +75,6 @@  | 
                                                    ||
| 75 | 75 | |
| 76 | 76 | public function getShortNameAttribute()  | 
                                                        
| 77 | 77 |      { | 
                                                        
| 78 | - return $this->firstname . ' ' . substr($this->lastname, 0, 1) . '.';  | 
                                                        |
| 78 | + return $this->firstname.' '.substr($this->lastname, 0, 1).'.';  | 
                                                        |
| 79 | 79 | }  | 
                                                        
| 80 | 80 | }  | 
                                                        
@@ -19,15 +19,15 @@  | 
                                                    ||
| 19 | 19 |      { | 
                                                        
| 20 | 20 | $abilities = ['view', 'create', 'update', 'delete'];  | 
                                                        
| 21 | 21 | |
| 22 | -        return array_map(function ($val) use ($scope) { | 
                                                        |
| 23 | - return $val . '-'. $scope;  | 
                                                        |
| 22 | +        return array_map(function($val) use ($scope) { | 
                                                        |
| 23 | + return $val.'-'.$scope;  | 
                                                        |
| 24 | 24 | }, $abilities);  | 
                                                        
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | 27 | public static function getPermissionsForIndex()  | 
                                                        
| 28 | 28 |      { | 
                                                        
| 29 | 29 | $permissions = $temp = [];  | 
                                                        
| 30 | -        self::all()->each(function ($permission) use (&$permissions, &$temp) { | 
                                                        |
| 30 | +        self::all()->each(function($permission) use (&$permissions, &$temp) { | 
                                                        |
| 31 | 31 |              $model = explode("_", $permission->name, 2)[1]; | 
                                                        
| 32 | 32 |              $temp[$model][$permission->id] = explode("_", $permission->name, 2)[0]; | 
                                                        
| 33 | 33 | $permissions = $temp;  | 
                                                        
@@ -39,7 +39,7 @@ discard block  | 
                                                    ||
| 39 | 39 | Permission::findOrCreate($permission, 'chief');  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 | |
| 42 | -        $this->info('Permissions ' . implode(', ', $permissions) . ' created.'); | 
                                                        |
| 42 | +        $this->info('Permissions '.implode(', ', $permissions).' created.'); | 
                                                        |
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
| 45 | 45 | /**  | 
                                                        
@@ -56,9 +56,9 @@ discard block  | 
                                                    ||
| 56 | 56 |          foreach ($roleNames as $roleName) { | 
                                                        
| 57 | 57 |              if ($role = Role::where('name', trim($roleName))->first()) { | 
                                                        
| 58 | 58 | $role->syncPermissions($permissions);  | 
                                                        
| 59 | -                $this->info('Role ' . $roleName . ' assigned the given permissions.'); | 
                                                        |
| 60 | -            } else { | 
                                                        |
| 61 | -                $this->warn('Role not found by name ' . $roleName . '!'); | 
                                                        |
| 59 | +                $this->info('Role '.$roleName.' assigned the given permissions.'); | 
                                                        |
| 60 | +            }else { | 
                                                        |
| 61 | +                $this->warn('Role not found by name '.$roleName.'!'); | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 | }  | 
                                                        
@@ -42,7 +42,7 @@ discard block  | 
                                                    ||
| 42 | 42 | // Generate all permissions if only scope is passed  | 
                                                        
| 43 | 43 |              if (false === strpos($permissionName, '-')) { | 
                                                        
| 44 | 44 | $cleanPermissionNames = array_merge($cleanPermissionNames, Permission::generate($permissionName));  | 
                                                        
| 45 | -            } else { | 
                                                        |
| 45 | +            }else { | 
                                                        |
| 46 | 46 | // Trim the value  | 
                                                        
| 47 | 47 | $cleanPermissionNames[] = $permissionName;  | 
                                                        
| 48 | 48 | }  | 
                                                        
@@ -55,6 +55,6 @@ discard block  | 
                                                    ||
| 55 | 55 | $role->givePermissionTo($cleanPermissionName);  | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | -        $this->info('Role ' . $role->name . ' was assigned the permissions: ' . implode(',', $cleanPermissionNames)); | 
                                                        |
| 58 | +        $this->info('Role '.$role->name.' was assigned the permissions: '.implode(',', $cleanPermissionNames)); | 
                                                        |
| 59 | 59 | }  | 
                                                        
| 60 | 60 | }  | 
                                                        
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | private function removeExistingSets()  | 
                                                        
| 91 | 91 |      { | 
                                                        
| 92 | 92 |          foreach ($this->model->children() as $instance) { | 
                                                        
| 93 | -            if (! $instance instanceof StoredSetReference) { | 
                                                        |
| 93 | +            if (!$instance instanceof StoredSetReference) { | 
                                                        |
| 94 | 94 | continue;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | $this->model->rejectChild($instance);  | 
                                                        
@@ -144,7 +144,7 @@ discard block  | 
                                                    ||
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
| 146 | 146 |          foreach ($this->text_modules['replace'] as $text_module) { | 
                                                        
| 147 | -            if (! $module = FlatReferenceFactory::fromString($text_module['id'])->instance()) { | 
                                                        |
| 147 | +            if (!$module = FlatReferenceFactory::fromString($text_module['id'])->instance()) { | 
                                                        |
| 148 | 148 | continue;  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 | |
| 164 | 164 | private function removeTextualModule($module)  | 
                                                        
| 165 | 165 |      { | 
                                                        
| 166 | -        if (! $module instanceof TextModule && ! $module instanceof PagetitleModule) { | 
                                                        |
| 166 | +        if (!$module instanceof TextModule && !$module instanceof PagetitleModule) { | 
                                                        |
| 167 | 167 |              throw new \Exception('Invalid request to remove non textual module'); | 
                                                        
| 168 | 168 | }  | 
                                                        
| 169 | 169 | |
@@ -185,7 +185,7 @@ discard block  | 
                                                    ||
| 185 | 185 | continue;  | 
                                                        
| 186 | 186 | }  | 
                                                        
| 187 | 187 | |
| 188 | -            $child = $children->first(function ($c) use ($reference) { | 
                                                        |
| 188 | +            $child = $children->first(function($c) use ($reference) { | 
                                                        |
| 189 | 189 | return $c->flatReference()->get() == $reference;  | 
                                                        
| 190 | 190 | });  | 
                                                        
| 191 | 191 | |
@@ -236,7 +236,7 @@ discard block  | 
                                                    ||
| 236 | 236 | private function stripTagsBlacklist($value, $blacklist = [])  | 
                                                        
| 237 | 237 |      { | 
                                                        
| 238 | 238 |          foreach ($blacklist as $tag) { | 
                                                        
| 239 | -            $value = preg_replace('/<\/?' . $tag . '(.|\s)*?>/', '', $value); | 
                                                        |
| 239 | +            $value = preg_replace('/<\/?'.$tag.'(.|\s)*?>/', '', $value); | 
                                                        |
| 240 | 240 | }  | 
                                                        
| 241 | 241 | |
| 242 | 242 | return $value;  | 
                                                        
@@ -24,7 +24,7 @@ discard block  | 
                                                    ||
| 24 | 24 |              $menu->parent_id = ($request->get('allow_parent') && $request->get('parent_id')) ? $request->get('parent_id') : null; | 
                                                        
| 25 | 25 |              $menu->page_id = ($page_id = $request->get('page_id')) ? $this->getPage($request->get('page_id'))->id : null; | 
                                                        
| 26 | 26 |              $menu->collection_type = $request->get('collection_type', null); | 
                                                        
| 27 | -            $menu->order        = $request->get('order', 0); | 
                                                        |
| 27 | +            $menu->order = $request->get('order', 0); | 
                                                        |
| 28 | 28 | |
| 29 | 29 | $this->reorderAgainstSiblings($menu);  | 
                                                        
| 30 | 30 | $menu->save();  | 
                                                        
@@ -52,13 +52,13 @@ discard block  | 
                                                    ||
| 52 | 52 |          if (in_array($menu->order, $sequence)) { | 
                                                        
| 53 | 53 |              foreach ($sequence as $id => $order) { | 
                                                        
| 54 | 54 |                  if ($order < $menu->order) { | 
                                                        
| 55 | -                } else { | 
                                                        |
| 55 | +                }else { | 
                                                        |
| 56 | 56 | $sequence[$id]++;  | 
                                                        
| 57 | 57 | }  | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | |
| 61 | - $sequence = $sequence + [$menu->id => $menu->order];  | 
                                                        |
| 61 | + $sequence = $sequence+[$menu->id => $menu->order];  | 
                                                        |
| 62 | 62 | |
| 63 | 63 | asort($sequence);  | 
                                                        
| 64 | 64 | |
@@ -67,7 +67,7 @@ discard block  | 
                                                    ||
| 67 | 67 | |
| 68 | 68 | private function reorder(array $sequence)  | 
                                                        
| 69 | 69 |      { | 
                                                        
| 70 | -        array_walk($sequence, function ($order, $id) { | 
                                                        |
| 70 | +        array_walk($sequence, function($order, $id) { | 
                                                        |
| 71 | 71 | MenuItem::withoutGlobalScope(SoftDeletingScope::class)  | 
                                                        
| 72 | 72 |                  ->where('id', $id) | 
                                                        
| 73 | 73 | ->update(['order' => $order]);  | 
                                                        
@@ -1,5 +1,5 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | -declare(strict_types = 1);  | 
                                                        |
| 2 | +declare(strict_types=1);  | 
                                                        |
| 3 | 3 | |
| 4 | 4 | namespace Thinktomorrow\Chief\Menu;  | 
                                                        
| 5 | 5 | |
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 |      { | 
                                                        
| 27 | 27 | $collection = NodeCollection::fromArray($items);  | 
                                                        
| 28 | 28 | |
| 29 | -        $collection->mapRecursive(function ($node) { | 
                                                        |
| 29 | +        $collection->mapRecursive(function($node) { | 
                                                        |
| 30 | 30 | return $node->replaceEntry((new MenuItem())->entry($node));  | 
                                                        
| 31 | 31 | });  | 
                                                        
| 32 | 32 | |
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 | public function items(): NodeCollection  | 
                                                        
| 44 | 44 |      { | 
                                                        
| 45 | 45 |          if (!$this->includeHidden) { | 
                                                        
| 46 | -            $this->collection = $this->collection->shake(function ($node) { | 
                                                        |
| 46 | +            $this->collection = $this->collection->shake(function($node) { | 
                                                        |
| 47 | 47 | return !$node->hidden_in_menu && !$node->draft;  | 
                                                        
| 48 | 48 | });  | 
                                                        
| 49 | 49 | }  | 
                                                        
@@ -56,22 +56,22 @@ discard block  | 
                                                    ||
| 56 | 56 | $this->collection = $this->items();  | 
                                                        
| 57 | 57 | |
| 58 | 58 |          if ($id) { | 
                                                        
| 59 | -            $this->collection = $this->collection->prune(function ($node) use ($id) { | 
                                                        |
| 59 | +            $this->collection = $this->collection->prune(function($node) use ($id) { | 
                                                        |
| 60 | 60 |                  return !in_array($id, $node->pluckAncestors('id')); | 
                                                        
| 61 | 61 | });  | 
                                                        
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | -        $menu = $this->collection->mapRecursive(function ($node) { | 
                                                        |
| 64 | +        $menu = $this->collection->mapRecursive(function($node) { | 
                                                        |
| 65 | 65 | $entry = $node->entry();  | 
                                                        
| 66 | 66 | $label = $entry->label;  | 
                                                        
| 67 | -            $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())) . '>' : ''; | 
                                                        |
| 67 | +            $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())).'>' : ''; | 
                                                        |
| 68 | 68 | $entry->label .= $label;  | 
                                                        
| 69 | 69 | return $node->replaceEntry($entry);  | 
                                                        
| 70 | 70 | });  | 
                                                        
| 71 | 71 | |
| 72 | 72 | $menuitems = collect();  | 
                                                        
| 73 | -        $menu->flatten()->each(function ($node) use ($menuitems) { | 
                                                        |
| 74 | - $menuitems[] = [  | 
                                                        |
| 73 | +        $menu->flatten()->each(function($node) use ($menuitems) { | 
                                                        |
| 74 | + $menuitems[] = [  | 
                                                        |
| 75 | 75 | 'label' => $node->label,  | 
                                                        
| 76 | 76 | 'id' => $node->id  | 
                                                        
| 77 | 77 | ];  | 
                                                        
@@ -110,9 +110,9 @@ discard block  | 
                                                    ||
| 110 | 110 |              if ($item->collection_type) { | 
                                                        
| 111 | 111 | $pages = Morphables::instance($item->collection_type)->getAllPublished();  | 
                                                        
| 112 | 112 | |
| 113 | -                $pages->each(function (ActsAsMenuItem $page) use (&$collectionItems, $item) { | 
                                                        |
| 113 | +                $pages->each(function(ActsAsMenuItem $page) use (&$collectionItems, $item) { | 
                                                        |
| 114 | 114 | $collectionItems->push(MenuItem::make([  | 
                                                        
| 115 | - 'id' => 1000 . $item->id . $page->id, // Unique integer identifier since model->id is automatically casted to int.  | 
                                                        |
| 115 | + 'id' => 1000.$item->id.$page->id, // Unique integer identifier since model->id is automatically casted to int.  | 
                                                        |
| 116 | 116 | 'label' => $page->menuLabel(),  | 
                                                        
| 117 | 117 | 'url' => self::composePageUrl($item, $page),  | 
                                                        
| 118 | 118 | 'parent_id' => $item->id,  | 
                                                        
@@ -127,7 +127,7 @@ discard block  | 
                                                    ||
| 127 | 127 |              if ($item->ofType(static::TYPE_INTERNAL) && $page = $item->page) { | 
                                                        
| 128 | 128 |                  if ($page->isArchived()) { | 
                                                        
| 129 | 129 | unset($items[$k]);  | 
                                                        
| 130 | -                } else { | 
                                                        |
| 130 | +                }else { | 
                                                        |
| 131 | 131 | $item->url = self::composePageUrl($item, $page);  | 
                                                        
| 132 | 132 | $item->page_label = $page->menuLabel();  | 
                                                        
| 133 | 133 | $item->hidden_in_menu = $page->hidden_in_menu;  | 
                                                        
@@ -172,11 +172,11 @@ discard block  | 
                                                    ||
| 172 | 172 | */  | 
                                                        
| 173 | 173 | public function entry(Node $node)  | 
                                                        
| 174 | 174 |      { | 
                                                        
| 175 | - return (object) [  | 
                                                        |
| 175 | + return (object)[  | 
                                                        |
| 176 | 176 | 'id' => $node->id,  | 
                                                        
| 177 | 177 | 'type' => $node->type,  | 
                                                        
| 178 | 178 | 'label' => $node->label,  | 
                                                        
| 179 | - 'page_label' => $node->page_label, // Extra info when dealing with internal links  | 
                                                        |
| 179 | + 'page_label' => $node->page_label, // Extra info when dealing with internal links  | 
                                                        |
| 180 | 180 | 'url' => $node->url,  | 
                                                        
| 181 | 181 | 'order' => $node->order,  | 
                                                        
| 182 | 182 | 'page_id' => $node->page_id,  | 
                                                        
@@ -27,14 +27,14 @@ discard block  | 
                                                    ||
| 27 | 27 |      { | 
                                                        
| 28 | 28 |          $types = config('thinktomorrow.chief.menus', []); | 
                                                        
| 29 | 29 | |
| 30 | -        return collect($types)->map(function ($menu, $key) { | 
                                                        |
| 30 | +        return collect($types)->map(function($menu, $key) { | 
                                                        |
| 31 | 31 | return new static($key, $menu['label'], $menu['view']);  | 
                                                        
| 32 | 32 | });  | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | 34 | |
| 35 | 35 | public static function find($key): ?self  | 
                                                        
| 36 | 36 |      { | 
                                                        
| 37 | -        return static::all()->filter(function ($menu) use ($key) { | 
                                                        |
| 37 | +        return static::all()->filter(function($menu) use ($key) { | 
                                                        |
| 38 | 38 | return $menu->key() == $key;  | 
                                                        
| 39 | 39 | })->first();  | 
                                                        
| 40 | 40 | }  | 
                                                        
@@ -83,7 +83,7 @@ discard block  | 
                                                    ||
| 83 | 83 |      { | 
                                                        
| 84 | 84 | $menu = [];  | 
                                                        
| 85 | 85 | |
| 86 | -        $this->items()->each(function ($item) use (&$menu) { | 
                                                        |
| 86 | +        $this->items()->each(function($item) use (&$menu) { | 
                                                        |
| 87 | 87 |              $menu[] = sprintf('<li><a href="%s">%s</a></li>', $item->url, $item->label); | 
                                                        
| 88 | 88 | });  | 
                                                        
| 89 | 89 | |