@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if (method_exists($query->getModel(), 'translations')) { |
| 36 | 36 | $locale = $locale == null ? app()->getLocale() : $locale; |
| 37 | 37 | |
| 38 | - $query->whereHas('translations', function ($query) use ($locale) { |
|
| 38 | + $query->whereHas('translations', function($query) use ($locale) { |
|
| 39 | 39 | $query->whereActive(true); |
| 40 | 40 | $query->whereLocale($locale); |
| 41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | - return $query->with(['translations' => function ($query) use ($locale) { |
|
| 47 | + return $query->with(['translations' => function($query) use ($locale) { |
|
| 48 | 48 | $query->whereActive(true); |
| 49 | 49 | $query->whereLocale($locale); |
| 50 | 50 | |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | $locale = $locale == null ? app()->getLocale() : $locale; |
| 72 | 72 | |
| 73 | 73 | return $query |
| 74 | - ->join($translationTable, function (JoinClause $join) use ($translationTable, $localeKey, $table, $keyName) { |
|
| 74 | + ->join($translationTable, function(JoinClause $join) use ($translationTable, $localeKey, $table, $keyName) { |
|
| 75 | 75 | $join |
| 76 | - ->on($translationTable.'.'.$this->getRelationKey(), '=', $table.'.'.$keyName) |
|
| 77 | - ->where($translationTable.'.'.$localeKey, $this->locale()); |
|
| 76 | + ->on($translationTable . '.' . $this->getRelationKey(), '=', $table . '.' . $keyName) |
|
| 77 | + ->where($translationTable . '.' . $localeKey, $this->locale()); |
|
| 78 | 78 | }) |
| 79 | - ->where($translationTable.'.'.$this->getLocaleKey(), $locale) |
|
| 80 | - ->orderBy($translationTable.'.'.$orderField, $orderType) |
|
| 81 | - ->select($table.'.*') |
|
| 79 | + ->where($translationTable . '.' . $this->getLocaleKey(), $locale) |
|
| 80 | + ->orderBy($translationTable . '.' . $orderField, $orderType) |
|
| 81 | + ->select($table . '.*') |
|
| 82 | 82 | ->with('translations'); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function getActiveLanguages() |
| 132 | 132 | { |
| 133 | - return $this->translations->map(function ($translation) { |
|
| 133 | + return $this->translations->map(function($translation) { |
|
| 134 | 134 | return [ |
| 135 | 135 | 'shortlabel' => strtoupper($translation->locale), |
| 136 | 136 | 'label' => getLanguageLabelFromLocaleCode($translation->locale), |
| 137 | 137 | 'value' => $translation->locale, |
| 138 | 138 | 'published' => $translation->active ?? false, |
| 139 | 139 | ]; |
| 140 | - })->sortBy(function ($translation) { |
|
| 140 | + })->sortBy(function($translation) { |
|
| 141 | 141 | $localesOrdered = getLocales(); |
| 142 | 142 | return array_search($translation['value'], $localesOrdered); |
| 143 | 143 | })->values(); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function translatedAttribute($key) |
| 153 | 153 | { |
| 154 | - return $this->translations->mapWithKeys(function ($translation) use ($key) { |
|
| 154 | + return $this->translations->mapWithKeys(function($translation) use ($key) { |
|
| 155 | 155 | return [$translation->locale => $this->translate($translation->locale)->$key]; |
| 156 | 156 | }); |
| 157 | 157 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $fields = $this->getRelatedElementsAsCollection($object, $relation); |
| 153 | 153 | |
| 154 | 154 | if ($fields->isNotEmpty()) { |
| 155 | - return $fields->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 155 | + return $fields->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 156 | 156 | return [ |
| 157 | 157 | 'id' => $relatedElement->id, |
| 158 | 158 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function getFormFieldsForRelatedBrowser($object, $relation, $titleKey = 'title') |
| 176 | 176 | { |
| 177 | - return $object->getRelated($relation)->map(function ($relatedElement) use ($titleKey) { |
|
| 177 | + return $object->getRelated($relation)->map(function($relatedElement) use ($titleKey) { |
|
| 178 | 178 | return ($relatedElement != null) ? [ |
| 179 | 179 | 'id' => $relatedElement->id, |
| 180 | 180 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | ]) + (classHasTrait($relatedElement, HasMedias::class) ? [ |
| 185 | 185 | 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 186 | 186 | ] : []) : []; |
| 187 | - })->reject(function ($item) { |
|
| 187 | + })->reject(function($item) { |
|
| 188 | 188 | return empty($item); |
| 189 | 189 | })->values()->toArray(); |
| 190 | 190 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function getBrowsers() |
| 199 | 199 | { |
| 200 | - return collect($this->browsers)->map(function ($browser, $key) { |
|
| 200 | + return collect($this->browsers)->map(function($browser, $key) { |
|
| 201 | 201 | $browserName = is_string($browser) ? $browser : $key; |
| 202 | 202 | $moduleName = !empty($browser['moduleName']) ? $browser['moduleName'] : $this->inferModuleNameFromBrowserName($browserName); |
| 203 | 203 | |
@@ -19,17 +19,17 @@ |
||
| 19 | 19 | public function renderNamedBlocks($name = 'default', $renderChilds = true, $blockViewMappings = [], $data = []) |
| 20 | 20 | { |
| 21 | 21 | return $this->blocks |
| 22 | - ->filter(function ($block) use ($name) { |
|
| 22 | + ->filter(function($block) use ($name) { |
|
| 23 | 23 | return $name === 'default' |
| 24 | 24 | ? ($block->editor_name === $name || $block->editor_name === null) |
| 25 | 25 | : $block->editor_name === $name; |
| 26 | 26 | }) |
| 27 | 27 | ->where('parent_id', null) |
| 28 | - ->map(function ($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 28 | + ->map(function($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 29 | 29 | if ($renderChilds) { |
| 30 | 30 | $childBlocks = $this->blocks->where('parent_id', $block->id); |
| 31 | 31 | |
| 32 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($blockViewMappings, $data) { |
|
| 32 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($blockViewMappings, $data) { |
|
| 33 | 33 | $view = $this->getBlockView($childBlock->type, $blockViewMappings); |
| 34 | 34 | return view($view, $data)->with('block', $childBlock)->render(); |
| 35 | 35 | })->implode(''); |
@@ -34,8 +34,7 @@ |
||
| 34 | 34 | public function scopeEditor($query, $name = 'default') |
| 35 | 35 | { |
| 36 | 36 | return $name === 'default' ? |
| 37 | - $query->where('editor_name', $name)->orWhereNull('editor_name') : |
|
| 38 | - $query->where('editor_name', $name); |
|
| 37 | + $query->where('editor_name', $name)->orWhereNull('editor_name') : $query->where('editor_name', $name); |
|
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | public function blockable() |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $this->isNewFormat = $this->isNewFormat($contents); |
| 205 | 205 | $this->contents = $contents; |
| 206 | 206 | |
| 207 | - $this->parseMixedProperty('titleField', $contents, $this->name, function ($value, $options) { |
|
| 207 | + $this->parseMixedProperty('titleField', $contents, $this->name, function($value, $options) { |
|
| 208 | 208 | $this->titleField = $value; |
| 209 | 209 | $this->hideTitlePrefix = (boolean) ($options['hidePrefix'] ?? false); |
| 210 | 210 | }); |
@@ -311,14 +311,14 @@ discard block |
||
| 311 | 311 | return $value; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if ($configBlock = collect(config("twill.block_editor.blocks"))->filter(function ($block) use ($blockName) { |
|
| 314 | + if ($configBlock = collect(config("twill.block_editor.blocks"))->filter(function($block) use ($blockName) { |
|
| 315 | 315 | return Str::contains($block['component'], $blockName); |
| 316 | 316 | })->first()) { |
| 317 | 317 | if ($value = ($configBlock[$property] ?? null)) { |
| 318 | 318 | return $value; |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | - if ($configRepeater = collect(config("twill.block_editor.repeaters"))->filter(function ($repeater) use ($blockName) { |
|
| 321 | + if ($configRepeater = collect(config("twill.block_editor.repeaters"))->filter(function($repeater) use ($blockName) { |
|
| 322 | 322 | return Str::contains($repeater['component'], $blockName); |
| 323 | 323 | })->first()) { |
| 324 | 324 | if ($value = ($configRepeater[$property] ?? null)) { |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | |
| 124 | 124 | try { |
| 125 | 125 | $process->start(); |
| 126 | - } catch(\Exception $e) { |
|
| 126 | + } catch (\Exception $e) { |
|
| 127 | 127 | $this->warn("Could not start the chokidar watcher ({$e->getMessage()})\n"); |
| 128 | 128 | } |
| 129 | 129 | } else { |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | if ($frontend) { |
| 55 | 55 | $view = config('twill.frontend.views_path') . ".errors.$statusCode"; |
| 56 | 56 | |
| 57 | - return view()->exists($view)? $view : "errors::{$statusCode}"; |
|
| 57 | + return view()->exists($view) ? $view : "errors::{$statusCode}"; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $view = "admin.errors.$statusCode"; |
@@ -17,11 +17,11 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function hydrateHandleRevisions($object, $fields) |
| 19 | 19 | { |
| 20 | - foreach($this->getRepeaters() as $repeater) { |
|
| 20 | + foreach ($this->getRepeaters() as $repeater) { |
|
| 21 | 21 | $this->hydrateRepeater($object, $fields, $repeater['relation'], $repeater['model']); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - foreach($this->getBrowsers() as $browser) { |
|
| 24 | + foreach ($this->getBrowsers() as $browser) { |
|
| 25 | 25 | $this->hydrateBrowser($object, $fields, $browser['relation'], $browser['positionAttribute'], $browser['model']); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $modules = Collection::make($this->config->get('twill.dashboard.modules')); |
| 110 | 110 | |
| 111 | - return $modules->filter(function ($module) { |
|
| 111 | + return $modules->filter(function($module) { |
|
| 112 | 112 | return ($module['search'] ?? false); |
| 113 | - })->map(function ($module) use ($request) { |
|
| 113 | + })->map(function($module) use ($request) { |
|
| 114 | 114 | $repository = $this->getRepository($module['name'], $module['repository'] ?? null); |
| 115 | 115 | |
| 116 | 116 | $found = $repository->cmsSearch($request->get('search'), $module['search_fields'] ?? ['title'])->take(10); |
| 117 | 117 | |
| 118 | - return $found->map(function ($item) use ($module) { |
|
| 118 | + return $found->map(function($item) use ($module) { |
|
| 119 | 119 | try { |
| 120 | 120 | $author = $item->revisions()->latest()->first()->user->name ?? 'Admin'; |
| 121 | 121 | } catch (\Exception $e) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function getAllActivities() |
| 144 | 144 | { |
| 145 | - return Activity::take(20)->latest()->get()->map(function ($activity) { |
|
| 145 | + return Activity::take(20)->latest()->get()->map(function($activity) { |
|
| 146 | 146 | return $this->formatActivity($activity); |
| 147 | 147 | })->filter()->values(); |
| 148 | 148 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | private function getLoggedInUserActivities() |
| 154 | 154 | { |
| 155 | - return Activity::where('causer_id', $this->authFactory->guard('twill_users')->user()->id)->take(20)->latest()->get()->map(function ($activity) { |
|
| 155 | + return Activity::where('causer_id', $this->authFactory->guard('twill_users')->user()->id)->take(20)->latest()->get()->map(function($activity) { |
|
| 156 | 156 | return $this->formatActivity($activity); |
| 157 | 157 | })->filter()->values(); |
| 158 | 158 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | 'date' => $activity->created_at->toIso8601String(), |
| 180 | 180 | 'author' => $activity->causer->name ?? twillTrans('twill::lang.dashboard.unknown-author'), |
| 181 | 181 | 'name' => $activity->subject->titleInDashboard ?? $activity->subject->title, |
| 182 | - 'activity' => twillTrans('twill::lang.dashboard.activities.'.$activity->description), |
|
| 182 | + 'activity' => twillTrans('twill::lang.dashboard.activities.' . $activity->description), |
|
| 183 | 183 | ] + (classHasTrait($activity->subject, HasMedias::class) ? [ |
| 184 | 184 | 'thumbnail' => $activity->subject->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 185 | 185 | ] : []) + (!$activity->subject->trashed() ? [ |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | return []; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $statsByDate = Collection::make($response['rows'] ?? [])->map(function (array $dateRow) { |
|
| 208 | + $statsByDate = Collection::make($response['rows'] ?? [])->map(function(array $dateRow) { |
|
| 209 | 209 | return [ |
| 210 | 210 | 'date' => $dateRow[0], |
| 211 | 211 | 'users' => (int) $dateRow[1], |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | 'yesterday', |
| 221 | 221 | 'week', |
| 222 | 222 | 'month', |
| 223 | - ])->mapWithKeys(function ($period) use ($statsByDate) { |
|
| 223 | + ])->mapWithKeys(function($period) use ($statsByDate) { |
|
| 224 | 224 | $stats = $this->getPeriodStats($period, $statsByDate); |
| 225 | 225 | return [ |
| 226 | 226 | $period => [ |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | 'stats' => $stats = $statsByDate->first(), |
| 258 | 258 | 'moreUsers' => $stats['users'] > $statsByDate->get(1)['users'], |
| 259 | 259 | 'morePageViews' => $stats['pageViews'] > $statsByDate->get(1)['pageViews'], |
| 260 | - 'usersData' => $statsByDate->take(7)->map(function ($stat) { |
|
| 260 | + 'usersData' => $statsByDate->take(7)->map(function($stat) { |
|
| 261 | 261 | return $stat['users']; |
| 262 | 262 | }), |
| 263 | - 'pageViewsData' => $statsByDate->take(7)->map(function ($stat) { |
|
| 263 | + 'pageViewsData' => $statsByDate->take(7)->map(function($stat) { |
|
| 264 | 264 | return $stat['pageViews']; |
| 265 | 265 | }), |
| 266 | 266 | ]; |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | 'stats' => $stats = $statsByDate->get(1), |
| 270 | 270 | 'moreUsers' => $stats['users'] > $statsByDate->get(2)['users'], |
| 271 | 271 | 'morePageViews' => $stats['pageViews'] > $statsByDate->get(2)['pageViews'], |
| 272 | - 'usersData' => $statsByDate->slice(1)->take(7)->map(function ($stat) { |
|
| 272 | + 'usersData' => $statsByDate->slice(1)->take(7)->map(function($stat) { |
|
| 273 | 273 | return $stat['users']; |
| 274 | 274 | }), |
| 275 | - 'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function ($stat) { |
|
| 275 | + 'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function($stat) { |
|
| 276 | 276 | return $stat['pageViews']; |
| 277 | 277 | }), |
| 278 | 278 | ]; |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | 'stats' => $stats, |
| 296 | 296 | 'moreUsers' => $stats['users'] > $compareStats['users'], |
| 297 | 297 | 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'], |
| 298 | - 'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 298 | + 'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 299 | 299 | return $stat['users']; |
| 300 | 300 | }), |
| 301 | - 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 301 | + 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 302 | 302 | return $stat['pageViews']; |
| 303 | 303 | }), |
| 304 | 304 | ]; |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | 'stats' => $stats, |
| 322 | 322 | 'moreUsers' => $stats['users'] > $compareStats['users'], |
| 323 | 323 | 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'], |
| 324 | - 'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 324 | + 'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 325 | 325 | return $stat['users']; |
| 326 | 326 | }), |
| 327 | - 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 327 | + 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 328 | 328 | return $stat['pageViews']; |
| 329 | 329 | }), |
| 330 | 330 | ]; |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | private function getShortcuts($modules) |
| 352 | 352 | { |
| 353 | - return $modules->filter(function ($module) { |
|
| 353 | + return $modules->filter(function($module) { |
|
| 354 | 354 | return ($module['count'] ?? false) || ($module['create'] ?? false); |
| 355 | - })->map(function ($module) { |
|
| 355 | + })->map(function($module) { |
|
| 356 | 356 | $repository = $this->getRepository($module['name'], $module['repository'] ?? null); |
| 357 | 357 | |
| 358 | 358 | $moduleOptions = [ |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | private function getDrafts($modules) |
| 391 | 391 | { |
| 392 | - return $modules->filter(function ($module) { |
|
| 392 | + return $modules->filter(function($module) { |
|
| 393 | 393 | return ($module['draft'] ?? false); |
| 394 | - })->map(function ($module) { |
|
| 394 | + })->map(function($module) { |
|
| 395 | 395 | $repository = $this->getRepository($module['name'], $module['repository'] ?? null); |
| 396 | 396 | |
| 397 | 397 | $query = $repository->draft()->limit(3)->latest(); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | $drafts = $query->get(); |
| 404 | 404 | |
| 405 | - return $drafts->map(function ($draft) use ($module) { |
|
| 405 | + return $drafts->map(function($draft) use ($module) { |
|
| 406 | 406 | return [ |
| 407 | 407 | 'type' => ucfirst($module['label_singular'] ?? Str::singular($module['name'])), |
| 408 | 408 | 'name' => $draft->titleInDashboard ?? $draft->title, |