@@ -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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | if ($this->isPreviewAllowed()) { |
| 25 | 25 | $pages = Page::all(); |
| 26 | - } else { |
|
| 26 | + }else { |
|
| 27 | 27 | $pages = Page::getAllPublished(); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | if ($this->isPreviewAllowed()) { |
| 36 | 36 | $page = Page::findBySlug($request->slug); |
| 37 | - } else { |
|
| 37 | + }else { |
|
| 38 | 38 | $page = Page::findPublishedBySlug($request->slug); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $this->addChildToCollection($i, $child); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return $this->sets->values()->map(function (PresentForParent $child) { |
|
| 81 | + return $this->sets->values()->map(function(PresentForParent $child) { |
|
| 82 | 82 | return ($this->withSnippets && method_exists($child, 'withSnippets')) |
| 83 | 83 | ? $child->withSnippets()->presentForParent($this->parent) |
| 84 | 84 | : $child->presentForParent($this->parent); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | private function addChildToCollection($index, ActsAsChild $child) |
| 95 | 95 | { |
| 96 | 96 | // Only published pages you fool! |
| 97 | - if (method_exists($child, 'isPublished') && ! $child->isPublished()) { |
|
| 97 | + if (method_exists($child, 'isPublished') && !$child->isPublished()) { |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -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 | ]; |