@@ -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 | } |
@@ -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,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | protected function formatColumns(EloquentBuilder $builder, Eloquent $model) |
| 147 | 147 | { |
| 148 | - $map = function ($field) use ($builder, $model) { |
|
| 148 | + $map = function($field) use ($builder, $model) { |
|
| 149 | 149 | if (!$model->shouldFallback()) { |
| 150 | 150 | return "{$this->i18nTable}.{$field}"; |
| 151 | 151 | } |
@@ -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; |
@@ -314,14 +314,14 @@ |
||
| 314 | 314 | } elseif ($this->grammar instanceof PostgresGrammar) { |
| 315 | 315 | $ifNull = 'coalesce'; |
| 316 | 316 | } else { |
| 317 | - throw new \Exception('Cannot compile IFNULL statement for grammar '.get_class($this->grammar)); |
|
| 317 | + throw new \Exception('Cannot compile IFNULL statement for grammar ' . get_class($this->grammar)); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $primary = $this->grammar->wrap($primary); |
| 321 | 321 | $fallback = $this->grammar->wrap($fallback); |
| 322 | - $alias = $alias ? ' as '.$this->grammar->wrap($alias) : ''; |
|
| 322 | + $alias = $alias ? ' as ' . $this->grammar->wrap($alias) : ''; |
|
| 323 | 323 | |
| 324 | - return "{$ifNull}($primary, $fallback)".$alias; |
|
| 324 | + return "{$ifNull}($primary, $fallback)" . $alias; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -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 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $model = new static; |
| 102 | 102 | |
| 103 | - return static::unguarded(function () use ($locale, $model, $attributes, $translations) { |
|
| 103 | + return static::unguarded(function() use ($locale, $model, $attributes, $translations) { |
|
| 104 | 104 | return $model->createInLocale($locale, $attributes, $translations); |
| 105 | 105 | }); |
| 106 | 106 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function forceSaveTranslations(array $translations) |
| 162 | 162 | { |
| 163 | - return static::unguarded(function () use ($translations) { |
|
| 163 | + return static::unguarded(function() use ($translations) { |
|
| 164 | 164 | return $this->saveTranslations($translations); |
| 165 | 165 | }); |
| 166 | 166 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function forceSaveTranslation($locale, array $attributes) |
| 192 | 192 | { |
| 193 | - return static::unguarded(function () use ($locale, $attributes) { |
|
| 193 | + return static::unguarded(function() use ($locale, $attributes) { |
|
| 194 | 194 | return $this->saveTranslation($locale, $attributes); |
| 195 | 195 | }); |
| 196 | 196 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $foreignKey = $this->getForeignKey(); |
| 297 | 297 | $instance = $this->translationModel(); |
| 298 | 298 | |
| 299 | - return new HasMany($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey); |
|
| 299 | + return new HasMany($instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public function getI18nTable() |
| 492 | 492 | { |
| 493 | - return $this->getTable().$this->getTranslationTableSuffix(); |
|
| 493 | + return $this->getTable() . $this->getTranslationTableSuffix(); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |