@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $this->modelName = $this->locateModel($this->argument('modelName')); |
| 100 | 100 | |
| 101 | - if (! $this->modelName) { |
|
| 101 | + if (!$this->modelName) { |
|
| 102 | 102 | $this->error("Model `{$this->argument('modelName')}` was not found`"); |
| 103 | 103 | |
| 104 | 104 | return 1; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $mediasParams = app($this->modelName)->mediasParams; |
| 110 | 110 | |
| 111 | - if (! isset($mediasParams[$this->roleName])) { |
|
| 111 | + if (!isset($mediasParams[$this->roleName])) { |
|
| 112 | 112 | $this->error("Role `{$this->roleName}` was not found`"); |
| 113 | 113 | |
| 114 | 114 | return 1; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function byKey($key, $section = null) |
| 36 | 36 | { |
| 37 | - $settingQuery = $this->model->when($section, function ($query) use ($section) { |
|
| 37 | + $settingQuery = $this->model->when($section, function($query) use ($section) { |
|
| 38 | 38 | $query->where('section', $section); |
| 39 | 39 | })->where('key', $key); |
| 40 | 40 | |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function getFormFields($section = null) |
| 53 | 53 | { |
| 54 | - $settings = $this->model->when($section, function ($query) use ($section) { |
|
| 54 | + $settings = $this->model->when($section, function($query) use ($section) { |
|
| 55 | 55 | $query->where('section', $section); |
| 56 | 56 | })->with('translations', 'medias')->get(); |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | if (config('twill.media_library.translated_form_fields', false)) { |
| 60 | - $medias = $settings->reduce(function ($carry, $setting) { |
|
| 60 | + $medias = $settings->reduce(function($carry, $setting) { |
|
| 61 | 61 | foreach (getLocales() as $locale) { |
| 62 | 62 | if (!empty(parent::getFormFields($setting)['medias'][$locale]) && !empty(parent::getFormFields($setting)['medias'][$locale][$setting->key])) |
| 63 | 63 | { |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | return $carry; |
| 68 | 68 | }); |
| 69 | 69 | } else { |
| 70 | - $medias = $settings->mapWithKeys(function ($setting) { |
|
| 70 | + $medias = $settings->mapWithKeys(function($setting) { |
|
| 71 | 71 | return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null]; |
| 72 | 72 | })->filter()->toArray(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - return $settings->mapWithKeys(function ($setting) { |
|
| 75 | + return $settings->mapWithKeys(function($setting) { |
|
| 76 | 76 | $settingValue = []; |
| 77 | 77 | |
| 78 | 78 | foreach ($setting->translations as $translation) { |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (config('twill.media_library.translated_form_fields', false)) { |
| 125 | 125 | foreach (getLocales() as $locale) { |
| 126 | - $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function ($media) { |
|
| 126 | + $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function($media) { |
|
| 127 | 127 | return json_decode($media, true); |
| 128 | 128 | })->filter()->toArray(); |
| 129 | 129 | } |
| 130 | 130 | } else { |
| 131 | - $medias = [ |
|
| 132 | - $role => Collection::make($settingsFields['medias'][$role])->map(function ($media) { |
|
| 131 | + $medias = [ |
|
| 132 | + $role => Collection::make($settingsFields['medias'][$role])->map(function($media) { |
|
| 133 | 133 | return json_decode($media, true); |
| 134 | 134 | })->values()->filter()->toArray(), |
| 135 | 135 | ]; |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $submittedLanguages = Collection::make($fields['languages'] ?? []); |
| 34 | 34 | |
| 35 | - $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) { |
|
| 35 | + $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) { |
|
| 36 | 36 | return $language['published']; |
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | 39 | foreach ($locales as $index => $locale) { |
| 40 | - $submittedLanguage = Arr::first($submittedLanguages->filter(function ($lang) use ($locale) { |
|
| 40 | + $submittedLanguage = Arr::first($submittedLanguages->filter(function($lang) use ($locale) { |
|
| 41 | 41 | return $lang['value'] == $locale; |
| 42 | 42 | })); |
| 43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $fields[$locale] = [ |
| 49 | 49 | 'active' => $activeField, |
| 50 | - ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 50 | + ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 51 | 51 | $attributeValue = $fields[$attribute] ?? null; |
| 52 | 52 | |
| 53 | 53 | // if we are at the last locale, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | if ($this->model->isTranslatable()) { |
| 108 | 108 | $attributes = $this->model->translatedAttributes; |
| 109 | - $query->whereHas('translations', function ($q) use ($scopes, $attributes) { |
|
| 109 | + $query->whereHas('translations', function($q) use ($scopes, $attributes) { |
|
| 110 | 110 | foreach ($attributes as $attribute) { |
| 111 | 111 | if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) { |
| 112 | 112 | $q->where($attribute, $this->getLikeOperator(), '%' . $scopes[$attribute] . '%'); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public static function bootHasMedias(): void |
| 21 | 21 | { |
| 22 | - self::deleted(static function (Model $model) { |
|
| 22 | + self::deleted(static function(Model $model) { |
|
| 23 | 23 | if (!method_exists($model, 'isForceDeleting') || $model->isForceDeleting()) { |
| 24 | 24 | /** @var \A17\Twill\Models\Behaviors\HasMedias $model */ |
| 25 | 25 | $model->medias()->detach(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | private function findMedia($role, $crop = "default") |
| 56 | 56 | { |
| 57 | 57 | $foundMedia = false; |
| 58 | - $media = $this->medias->first(function ($media) use ($role, $crop, &$foundMedia) { |
|
| 58 | + $media = $this->medias->first(function($media) use ($role, $crop, &$foundMedia) { |
|
| 59 | 59 | if (config('twill.media_library.translated_form_fields', false)) { |
| 60 | 60 | $localeScope = $media->pivot->locale === app()->getLocale(); |
| 61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | }); |
| 69 | 69 | |
| 70 | 70 | if (!$media && config('twill.media_library.translated_form_fields', false)) { |
| 71 | - $media = $this->medias->first(function ($media) use ($role, $crop, &$foundMedia) { |
|
| 71 | + $media = $this->medias->first(function($media) use ($role, $crop, &$foundMedia) { |
|
| 72 | 72 | if (!$foundMedia) { |
| 73 | 73 | $foundMedia = $media->pivot->role === $role; |
| 74 | 74 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function images($role, $crop = "default", $params = []) |
| 148 | 148 | { |
| 149 | - $medias = $this->medias->filter(function ($media) use ($role, $crop) { |
|
| 149 | + $medias = $this->medias->filter(function($media) use ($role, $crop) { |
|
| 150 | 150 | return $media->pivot->role === $role && $media->pivot->crop === $crop; |
| 151 | 151 | }); |
| 152 | 152 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function imagesWithCrops($role, $params = []) |
| 170 | 170 | { |
| 171 | - $medias = $this->medias->filter(function ($media) use ($role) { |
|
| 171 | + $medias = $this->medias->filter(function($media) use ($role) { |
|
| 172 | 172 | return $media->pivot->role === $role; |
| 173 | 173 | }); |
| 174 | 174 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public function imagesAsArrays($role, $crop = "default", $params = []) |
| 223 | 223 | { |
| 224 | - $medias = $this->medias->filter(function ($media) use ($role, $crop) { |
|
| 224 | + $medias = $this->medias->filter(function($media) use ($role, $crop) { |
|
| 225 | 225 | return $media->pivot->role === $role && $media->pivot->crop === $crop; |
| 226 | 226 | }); |
| 227 | 227 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function imagesAsArraysWithCrops($role, $params = []) |
| 245 | 245 | { |
| 246 | - $medias = $this->medias->filter(function ($media) use ($role) { |
|
| 246 | + $medias = $this->medias->filter(function($media) use ($role) { |
|
| 247 | 247 | return $media->pivot->role === $role; |
| 248 | 248 | }); |
| 249 | 249 | |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | public function imageAltText($role, $media = null) |
| 268 | 268 | { |
| 269 | 269 | if (!$media) { |
| 270 | - $media = $this->medias->first(function ($media) use ($role) { |
|
| 270 | + $media = $this->medias->first(function($media) use ($role) { |
|
| 271 | 271 | if (config('twill.media_library.translated_form_fields', false)) { |
| 272 | 272 | $localeScope = $media->pivot->locale === app()->getLocale(); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - return $media->pivot->role === $role && ($localeScope ?? true);; |
|
| 275 | + return $media->pivot->role === $role && ($localeScope ?? true); ; |
|
| 276 | 276 | }); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | public function imageCaption($role, $media = null) |
| 294 | 294 | { |
| 295 | 295 | if (!$media) { |
| 296 | - $media = $this->medias->first(function ($media) use ($role) { |
|
| 296 | + $media = $this->medias->first(function($media) use ($role) { |
|
| 297 | 297 | if (config('twill.media_library.translated_form_fields', false)) { |
| 298 | 298 | $localeScope = $media->pivot->locale === app()->getLocale(); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - return $media->pivot->role === $role && ($localeScope ?? true);; |
|
| 301 | + return $media->pivot->role === $role && ($localeScope ?? true); ; |
|
| 302 | 302 | }); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -319,12 +319,12 @@ discard block |
||
| 319 | 319 | public function imageVideo($role, $media = null) |
| 320 | 320 | { |
| 321 | 321 | if (!$media) { |
| 322 | - $media = $this->medias->first(function ($media) use ($role) { |
|
| 322 | + $media = $this->medias->first(function($media) use ($role) { |
|
| 323 | 323 | if (config('twill.media_library.translated_form_fields', false)) { |
| 324 | 324 | $localeScope = $media->pivot->locale === app()->getLocale(); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - return $media->pivot->role === $role && ($localeScope ?? true);; |
|
| 327 | + return $media->pivot->role === $role && ($localeScope ?? true); ; |
|
| 328 | 328 | }); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function imageObjects($role, $crop = "default") |
| 443 | 443 | { |
| 444 | - return $this->medias->filter(function ($media) use ($role, $crop) { |
|
| 444 | + return $this->medias->filter(function($media) use ($role, $crop) { |
|
| 445 | 445 | return $media->pivot->role === $role && $media->pivot->crop === $crop; |
| 446 | 446 | }); |
| 447 | 447 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $routesFile |
| 16 | 16 | ): void { |
| 17 | 17 | if (file_exists($routesFile)) { |
| 18 | - $hostRoutes = function ($router) use ( |
|
| 18 | + $hostRoutes = function($router) use ( |
|
| 19 | 19 | $middlewares, |
| 20 | 20 | $namespace, |
| 21 | 21 | $routesFile |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | 'namespace' => $namespace, |
| 26 | 26 | 'middleware' => $middlewares, |
| 27 | 27 | ], |
| 28 | - function ($router) use ($routesFile) { |
|
| 28 | + function($router) use ($routesFile) { |
|
| 29 | 29 | require $routesFile; |
| 30 | 30 | } |
| 31 | 31 | ); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function getCapsuleForModule(string $module): Capsule |
| 48 | 48 | { |
| 49 | - $capsule = $this->getRegisteredCapsules()->first(function (Capsule $capsule) use ($module) { |
|
| 49 | + $capsule = $this->getRegisteredCapsules()->first(function(Capsule $capsule) use ($module) { |
|
| 50 | 50 | return $capsule->getModule() === $module; |
| 51 | 51 | }); |
| 52 | 52 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getCapsuleForModel(string $model): Capsule |
| 64 | 64 | { |
| 65 | - $capsule = $this->getRegisteredCapsules()->first(function (Capsule $capsule) use ($model) { |
|
| 65 | + $capsule = $this->getRegisteredCapsules()->first(function(Capsule $capsule) use ($model) { |
|
| 66 | 66 | return $capsule->getSingular() === $model; |
| 67 | 67 | }); |
| 68 | 68 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $list |
| 93 | 93 | ->where('enabled', true) |
| 94 | - ->map(function ($capsule) use ($path) { |
|
| 94 | + ->map(function($capsule) use ($path) { |
|
| 95 | 95 | $this->registerCapsule( |
| 96 | 96 | new Capsule( |
| 97 | 97 | $capsule['name'], |
@@ -217,8 +217,7 @@ |
||
| 217 | 217 | $this->error('A capsule with this name already exists!'); |
| 218 | 218 | |
| 219 | 219 | return false; |
| 220 | - } |
|
| 221 | - catch (NoCapsuleFoundException $e) {} |
|
| 220 | + } catch (NoCapsuleFoundException $e) {} |
|
| 222 | 221 | |
| 223 | 222 | if ($this->directoryExists()) { |
| 224 | 223 | $this->error( |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - collect($files)->each(function ($file) { |
|
| 104 | + collect($files)->each(function($file) { |
|
| 105 | 105 | if (file_exists($file)) { |
| 106 | 106 | require_once $file; |
| 107 | 107 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function loadMigrations(): void |
| 117 | 117 | { |
| 118 | - $callback = function (Migrator $migrator) { |
|
| 118 | + $callback = function(Migrator $migrator) { |
|
| 119 | 119 | $migrator->path($this->getMigrationsPath()); |
| 120 | 120 | }; |
| 121 | 121 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function loadTranslations(): void { |
| 134 | - $callback = function (Translator $translator) { |
|
| 134 | + $callback = function(Translator $translator) { |
|
| 135 | 135 | $translator->addNamespace($this->getLanguagesPath(), 'twill:capsules:' . $this->getModule()); |
| 136 | 136 | }; |
| 137 | 137 | |