@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | protected function qualifyColumns($columns) |
| 77 | 77 | { |
| 78 | 78 | foreach ($columns as &$column) { |
| 79 | - if (! in_array($column, $this->model->translatableAttributes())) { |
|
| 79 | + if (!in_array($column, $this->model->translatableAttributes())) { |
|
| 80 | 80 | continue; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | // If the given operator is not found in the list of valid operators we will |
| 169 | 169 | // assume that the developer is just short-cutting the '=' operators and |
| 170 | 170 | // we will set the operators to '=' and set the values appropriately. |
| 171 | - if (! in_array(strtolower($operator), $this->operators, true)) { |
|
| 171 | + if (!in_array(strtolower($operator), $this->operators, true)) { |
|
| 172 | 172 | [$value, $operator] = [$operator, '=']; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | // Finally we'll check whether we need to consider fallback translations. In |
| 179 | 179 | // that case we need to create a complex "ifnull" clause, otherwise we can |
| 180 | 180 | // just prepend the translation alias and add the where clause normally. |
| 181 | - if (! $this->model->shouldFallback() || $column instanceof Closure) { |
|
| 181 | + if (!$this->model->shouldFallback() || $column instanceof Closure) { |
|
| 182 | 182 | return $this->where($column, $operator, $value, $boolean); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $fallbackColumn = $this->qualifyTranslationColumn($column, true); |
| 258 | 258 | $column = $this->qualifyTranslationColumn($column); |
| 259 | 259 | |
| 260 | - if (! $this->model->shouldFallback()) { |
|
| 260 | + if (!$this->model->shouldFallback()) { |
|
| 261 | 261 | return $this->orderBy($column, $direction); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -310,14 +310,14 @@ discard block |
||
| 310 | 310 | } elseif ($this->grammar instanceof PostgresGrammar) { |
| 311 | 311 | $ifNull = 'coalesce'; |
| 312 | 312 | } else { |
| 313 | - throw new \Exception('Cannot compile IFNULL statement for grammar '.get_class($this->grammar)); |
|
| 313 | + throw new \Exception('Cannot compile IFNULL statement for grammar ' . get_class($this->grammar)); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $primary = $this->grammar->wrap($primary); |
| 317 | 317 | $fallback = $this->grammar->wrap($fallback); |
| 318 | - $alias = $alias ? ' as '.$this->grammar->wrap($alias) : ''; |
|
| 318 | + $alias = $alias ? ' as ' . $this->grammar->wrap($alias) : ''; |
|
| 319 | 319 | |
| 320 | - return "{$ifNull}($primary, $fallback)".$alias; |
|
| 320 | + return "{$ifNull}($primary, $fallback)" . $alias; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $model = new static; |
| 84 | 84 | |
| 85 | - return static::unguarded(function () use ($model, $attributes, $translations) { |
|
| 85 | + return static::unguarded(function() use ($model, $attributes, $translations) { |
|
| 86 | 86 | return $model->create($attributes, $translations); |
| 87 | 87 | }); |
| 88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $model = new static; |
| 101 | 101 | |
| 102 | - return static::unguarded(function () use ($locale, $model, $attributes, $translations) { |
|
| 102 | + return static::unguarded(function() use ($locale, $model, $attributes, $translations) { |
|
| 103 | 103 | return $model->createInLocale($locale, $attributes, $translations); |
| 104 | 104 | }); |
| 105 | 105 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function fresh($with = []) |
| 115 | 115 | { |
| 116 | - if (! $this->exists) { |
|
| 116 | + if (!$this->exists) { |
|
| 117 | 117 | return null; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function forceSaveTranslations(array $translations) |
| 161 | 161 | { |
| 162 | - return static::unguarded(function () use ($translations) { |
|
| 162 | + return static::unguarded(function() use ($translations) { |
|
| 163 | 163 | return $this->saveTranslations($translations); |
| 164 | 164 | }); |
| 165 | 165 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function forceSaveTranslation($locale, array $attributes) |
| 191 | 191 | { |
| 192 | - return static::unguarded(function () use ($locale, $attributes) { |
|
| 192 | + return static::unguarded(function() use ($locale, $attributes) { |
|
| 193 | 193 | return $this->saveTranslation($locale, $attributes); |
| 194 | 194 | }); |
| 195 | 195 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function fill(array $attributes) |
| 207 | 207 | { |
| 208 | - if (! isset(static::$i18nAttributes[$this->getTable()])) { |
|
| 208 | + if (!isset(static::$i18nAttributes[$this->getTable()])) { |
|
| 209 | 209 | $this->initTranslatableAttributes(); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | protected function getTranslatableAttributesFromSchema() |
| 235 | 235 | { |
| 236 | - if ((! $con = $this->getConnection()) || (! $builder = $con->getSchemaBuilder())) { |
|
| 236 | + if ((!$con = $this->getConnection()) || (!$builder = $con->getSchemaBuilder())) { |
|
| 237 | 237 | return []; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $found = $this->translations->where($this->getLocaleKey(), $locale)->first(); |
| 262 | 262 | |
| 263 | - if (! $found && $this->shouldFallback($locale)) { |
|
| 263 | + if (!$found && $this->shouldFallback($locale)) { |
|
| 264 | 264 | return $this->translate($this->getFallbackLocale()); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $foreignKey = $this->getForeignKey(); |
| 295 | 295 | $instance = $this->translationModel(); |
| 296 | 296 | |
| 297 | - return new HasMany($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey); |
|
| 297 | + return new HasMany($instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function translatableAttributes() |
| 327 | 327 | { |
| 328 | - if (! isset(static::$i18nAttributes[$this->getTable()])) { |
|
| 328 | + if (!isset(static::$i18nAttributes[$this->getTable()])) { |
|
| 329 | 329 | return []; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | */ |
| 429 | 429 | public function getOnlyTranslated() |
| 430 | 430 | { |
| 431 | - if (! is_null($this->overrideOnlyTranslated)) { |
|
| 431 | + if (!is_null($this->overrideOnlyTranslated)) { |
|
| 432 | 432 | return $this->overrideOnlyTranslated; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public function getWithFallback() |
| 462 | 462 | { |
| 463 | - if (! is_null($this->overrideWithFallback)) { |
|
| 463 | + if (!is_null($this->overrideWithFallback)) { |
|
| 464 | 464 | return $this->overrideWithFallback; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function getI18nTable() |
| 490 | 490 | { |
| 491 | - return $this->getTable().$this->getTranslationTableSuffix(); |
|
| 491 | + return $this->getTable() . $this->getTranslationTableSuffix(); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | */ |
| 511 | 511 | public function shouldFallback($locale = null) |
| 512 | 512 | { |
| 513 | - if (! $this->getWithFallback() || ! $this->getFallbackLocale()) { |
|
| 513 | + if (!$this->getWithFallback() || !$this->getFallbackLocale()) { |
|
| 514 | 514 | return false; |
| 515 | 515 | } |
| 516 | 516 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | { |
| 555 | 555 | $dirty = parent::getDirty(); |
| 556 | 556 | |
| 557 | - if (! $this->localeChanged) { |
|
| 557 | + if (!$this->localeChanged) { |
|
| 558 | 558 | return $dirty; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $this->i18nTable = $model->getI18nTable(); |
| 39 | 39 | $this->fallback = $model->getFallbackLocale(); |
| 40 | 40 | |
| 41 | - if (! Str::startsWith($this->table, 'laravel_reserved_')) { |
|
| 41 | + if (!Str::startsWith($this->table, 'laravel_reserved_')) { |
|
| 42 | 42 | $this->createJoin($builder, $model); |
| 43 | 43 | $this->createWhere($builder, $model); |
| 44 | 44 | $this->createSelect($builder, $model); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $builder->$joinType($this->i18nTable, $clause); |
| 60 | 60 | |
| 61 | 61 | if ($model->shouldFallback()) { |
| 62 | - $clause = $this->getJoinClause($model, $this->fallback, $this->i18nTable.'_fallback'); |
|
| 62 | + $clause = $this->getJoinClause($model, $this->fallback, $this->i18nTable . '_fallback'); |
|
| 63 | 63 | |
| 64 | 64 | $builder->$joinType("{$this->i18nTable} as {$this->i18nTable}_fallback", $clause); |
| 65 | 65 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | protected function getJoinType(Eloquent $model) |
| 76 | 76 | { |
| 77 | - $innerJoin = ! $model->shouldFallback() && $model->getOnlyTranslated(); |
|
| 77 | + $innerJoin = !$model->shouldFallback() && $model->getOnlyTranslated(); |
|
| 78 | 78 | |
| 79 | 79 | return $innerJoin ? 'join' : 'leftJoin'; |
| 80 | 80 | } |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | protected function getJoinClause(Eloquent $model, $locale, $alias) |
| 92 | 92 | { |
| 93 | - return function (JoinClause $join) use ($model, $locale, $alias) { |
|
| 93 | + return function(JoinClause $join) use ($model, $locale, $alias) { |
|
| 94 | 94 | $primary = $model->getKeyName(); |
| 95 | 95 | $foreign = $model->getForeignKey(); |
| 96 | 96 | $langKey = $model->getLocaleKey(); |
| 97 | 97 | |
| 98 | - $join->on($alias.'.'.$foreign, '=', $this->table.'.'.$primary) |
|
| 99 | - ->where($alias.'.'.$langKey, '=', $locale); |
|
| 98 | + $join->on($alias . '.' . $foreign, '=', $this->table . '.' . $primary) |
|
| 99 | + ->where($alias . '.' . $langKey, '=', $locale); |
|
| 100 | 100 | }; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $select = $this->formatColumns($builder, $model); |
| 134 | 134 | |
| 135 | - $builder->select(array_merge([$this->table.'.*'], $select)); |
|
| 135 | + $builder->select(array_merge([$this->table . '.*'], $select)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | protected function formatColumns(EloquentBuilder $builder, Eloquent $model) |
| 147 | 147 | { |
| 148 | - $map = function ($field) use ($builder, $model) { |
|
| 149 | - if (! $model->shouldFallback()) { |
|
| 148 | + $map = function($field) use ($builder, $model) { |
|
| 149 | + if (!$model->shouldFallback()) { |
|
| 150 | 150 | return "{$this->i18nTable}.{$field}"; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function extend(EloquentBuilder $builder) |
| 181 | 181 | { |
| 182 | - $builder->macro('onlyTranslated', function (EloquentBuilder $builder, $locale = null) { |
|
| 182 | + $builder->macro('onlyTranslated', function(EloquentBuilder $builder, $locale = null) { |
|
| 183 | 183 | $builder->getModel()->setOnlyTranslated(true); |
| 184 | 184 | |
| 185 | 185 | if ($locale) { |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | return $builder; |
| 190 | 190 | }); |
| 191 | 191 | |
| 192 | - $builder->macro('withUntranslated', function (EloquentBuilder $builder) { |
|
| 192 | + $builder->macro('withUntranslated', function(EloquentBuilder $builder) { |
|
| 193 | 193 | $builder->getModel()->setOnlyTranslated(false); |
| 194 | 194 | |
| 195 | 195 | return $builder; |
| 196 | 196 | }); |
| 197 | 197 | |
| 198 | - $builder->macro('withFallback', function (EloquentBuilder $builder, $fallbackLocale = null) { |
|
| 198 | + $builder->macro('withFallback', function(EloquentBuilder $builder, $fallbackLocale = null) { |
|
| 199 | 199 | $builder->getModel()->setWithFallback(true); |
| 200 | 200 | |
| 201 | 201 | if ($fallbackLocale) { |
@@ -205,13 +205,13 @@ discard block |
||
| 205 | 205 | return $builder; |
| 206 | 206 | }); |
| 207 | 207 | |
| 208 | - $builder->macro('withoutFallback', function (EloquentBuilder $builder) { |
|
| 208 | + $builder->macro('withoutFallback', function(EloquentBuilder $builder) { |
|
| 209 | 209 | $builder->getModel()->setWithFallback(false); |
| 210 | 210 | |
| 211 | 211 | return $builder; |
| 212 | 212 | }); |
| 213 | 213 | |
| 214 | - $builder->macro('translateInto', function (EloquentBuilder $builder, $locale) { |
|
| 214 | + $builder->macro('translateInto', function(EloquentBuilder $builder, $locale) { |
|
| 215 | 215 | if ($locale) { |
| 216 | 216 | $builder->getModel()->setLocale($locale); |
| 217 | 217 | } |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | return $builder; |
| 220 | 220 | }); |
| 221 | 221 | |
| 222 | - $builder->macro('withoutTranslations', function (EloquentBuilder $builder) { |
|
| 222 | + $builder->macro('withoutTranslations', function(EloquentBuilder $builder) { |
|
| 223 | 223 | $builder->withoutGlobalScope(static::class); |
| 224 | 224 | |
| 225 | 225 | return $builder; |
| 226 | 226 | }); |
| 227 | 227 | |
| 228 | - $builder->macro('withAllTranslations', function (EloquentBuilder $builder) { |
|
| 228 | + $builder->macro('withAllTranslations', function(EloquentBuilder $builder) { |
|
| 229 | 229 | $builder->withoutGlobalScope(static::class)->with('translations'); |
| 230 | 230 | |
| 231 | 231 | return $builder; |
@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function register() |
| 15 | 15 | { |
| 16 | - TranslatableConfig::cacheGetter(function ($table) { |
|
| 17 | - return $this->app['cache']->get('translatable.'.$table); |
|
| 16 | + TranslatableConfig::cacheGetter(function($table) { |
|
| 17 | + return $this->app['cache']->get('translatable.' . $table); |
|
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | - TranslatableConfig::cacheSetter(function ($table, $fields) { |
|
| 21 | - return $this->app['cache']->forever('translatable.'.$table, $fields); |
|
| 20 | + TranslatableConfig::cacheSetter(function($table, $fields) { |
|
| 21 | + return $this->app['cache']->forever('translatable.' . $table, $fields); |
|
| 22 | 22 | }); |
| 23 | 23 | |
| 24 | - TranslatableConfig::currentLocaleGetter(function () { |
|
| 24 | + TranslatableConfig::currentLocaleGetter(function() { |
|
| 25 | 25 | return $this->app->getLocale(); |
| 26 | 26 | }); |
| 27 | 27 | |
| 28 | - TranslatableConfig::fallbackLocaleGetter(function () { |
|
| 28 | + TranslatableConfig::fallbackLocaleGetter(function() { |
|
| 29 | 29 | return method_exists($this->app, 'getFallbackLocale') |
| 30 | 30 | ? $this->app->getFallbackLocale() |
| 31 | 31 | : config('app.fallback_locale'); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function boot() |
| 41 | 41 | { |
| 42 | - $config = dirname(__DIR__).'/config/translatable.php'; |
|
| 42 | + $config = dirname(__DIR__) . '/config/translatable.php'; |
|
| 43 | 43 | |
| 44 | 44 | $this->mergeConfigFrom($config, 'translatable'); |
| 45 | 45 | $this->publishes([$config => config_path('translatable.php')], 'config'); |