@@ -78,7 +78,7 @@ |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if (!$item && config('translatable.use_property_fallback', false)) { |
| 81 | - $item = (clone $query)->orWhere(function ($query) { |
|
| 81 | + $item = (clone $query)->orWhere(function($query) { |
|
| 82 | 82 | return $query->withActiveTranslations(config('translatable.fallback_locale')); |
| 83 | 83 | })->forFallbackLocaleSlug($slug)->first(); |
| 84 | 84 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $filesCollection = Collection::make(); |
| 24 | 24 | $filesFromFields = $this->getFiles($fields); |
| 25 | 25 | |
| 26 | - $filesFromFields->each(function ($file) use ($object, $filesCollection) { |
|
| 26 | + $filesFromFields->each(function($file) use ($object, $filesCollection) { |
|
| 27 | 27 | $newFile = File::withTrashed()->find($file['id']); |
| 28 | 28 | $pivot = $newFile->newPivot($object, Arr::except($file, ['id']), 'fileables', true); |
| 29 | 29 | $newFile->setRelation('pivot', $pivot); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $object->files()->sync([]); |
| 50 | 50 | |
| 51 | - $this->getFiles($fields)->each(function ($file) use ($object) { |
|
| 51 | + $this->getFiles($fields)->each(function($file) use ($object) { |
|
| 52 | 52 | $object->files()->attach($file['id'], Arr::except($file, ['id'])); |
| 53 | 53 | }); |
| 54 | 54 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if (in_array($role, $this->model->filesParams ?? []) |
| 75 | 75 | || in_array($role, config('twill.block_editor.files', []))) { |
| 76 | 76 | |
| 77 | - Collection::make($filesForRole)->each(function ($file) use (&$files, $role, $locale) { |
|
| 77 | + Collection::make($filesForRole)->each(function($file) use (&$files, $role, $locale) { |
|
| 78 | 78 | $files->push([ |
| 79 | 79 | 'id' => $file['id'], |
| 80 | 80 | 'role' => $role, |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | if ($object->has('files')) { |
| 100 | 100 | foreach ($object->files->groupBy('pivot.role') as $role => $filesByRole) { |
| 101 | 101 | foreach ($filesByRole->groupBy('pivot.locale') as $locale => $filesByLocale) { |
| 102 | - $fields['files'][$locale][$role] = $filesByLocale->map(function ($file) { |
|
| 102 | + $fields['files'][$locale][$role] = $filesByLocale->map(function($file) { |
|
| 103 | 103 | return $file->toCmsArray(); |
| 104 | 104 | }); |
| 105 | 105 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | foreach ($fields as $field) { |
| 180 | 180 | if (in_array($field, $translatedAttributes)) { |
| 181 | - $query->orWhereHas('translations', function ($q) use ($field, $search) { |
|
| 181 | + $query->orWhereHas('translations', function($q) use ($field, $search) { |
|
| 182 | 182 | $q->where($field, $this->getLikeOperator(), "%{$search}%"); |
| 183 | 183 | }); |
| 184 | 184 | } else { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function create($fields) |
| 207 | 207 | { |
| 208 | - return DB::transaction(function () use ($fields) { |
|
| 208 | + return DB::transaction(function() use ($fields) { |
|
| 209 | 209 | $original_fields = $fields; |
| 210 | 210 | |
| 211 | 211 | $fields = $this->prepareFieldsBeforeCreate($fields); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function update($id, $fields) |
| 262 | 262 | { |
| 263 | - DB::transaction(function () use ($id, $fields) { |
|
| 263 | + DB::transaction(function() use ($id, $fields) { |
|
| 264 | 264 | $object = $this->model->findOrFail($id); |
| 265 | 265 | |
| 266 | 266 | $this->beforeSave($object, $fields); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public function updateBasic($id, $values, $scopes = []) |
| 285 | 285 | { |
| 286 | - return DB::transaction(function () use ($id, $values, $scopes) { |
|
| 286 | + return DB::transaction(function() use ($id, $values, $scopes) { |
|
| 287 | 287 | // apply scopes if no id provided |
| 288 | 288 | if (is_null($id)) { |
| 289 | 289 | $query = $this->model->query(); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | $query->update($values); |
| 296 | 296 | |
| 297 | - $query->get()->each(function ($object) use ($values) { |
|
| 297 | + $query->get()->each(function($object) use ($values) { |
|
| 298 | 298 | $this->afterUpdateBasic($object, $values); |
| 299 | 299 | }); |
| 300 | 300 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $query = $this->model->whereIn('id', $id); |
| 307 | 307 | $query->update($values); |
| 308 | 308 | |
| 309 | - $query->get()->each(function ($object) use ($values) { |
|
| 309 | + $query->get()->each(function($object) use ($values) { |
|
| 310 | 310 | $this->afterUpdateBasic($object, $values); |
| 311 | 311 | }); |
| 312 | 312 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function setNewOrder($ids) |
| 331 | 331 | { |
| 332 | - DB::transaction(function () use ($ids) { |
|
| 332 | + DB::transaction(function() use ($ids) { |
|
| 333 | 333 | $this->model->setNewOrder($ids); |
| 334 | 334 | }, 3); |
| 335 | 335 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public function delete($id) |
| 342 | 342 | { |
| 343 | - return DB::transaction(function () use ($id) { |
|
| 343 | + return DB::transaction(function() use ($id) { |
|
| 344 | 344 | if (($object = $this->model->find($id)) === null) { |
| 345 | 345 | return false; |
| 346 | 346 | } |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | public function bulkDelete($ids) |
| 362 | 362 | { |
| 363 | - return DB::transaction(function () use ($ids) { |
|
| 363 | + return DB::transaction(function() use ($ids) { |
|
| 364 | 364 | try { |
| 365 | - Collection::make($ids)->each(function ($id) { |
|
| 365 | + Collection::make($ids)->each(function($id) { |
|
| 366 | 366 | $this->delete($id); |
| 367 | 367 | }); |
| 368 | 368 | } catch (\Exception $e) { |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function restore($id) |
| 382 | 382 | { |
| 383 | - return DB::transaction(function () use ($id) { |
|
| 383 | + return DB::transaction(function() use ($id) { |
|
| 384 | 384 | if (($object = $this->model->withTrashed()->find($id)) != null) { |
| 385 | 385 | $object->restore(); |
| 386 | 386 | $this->afterRestore($object); |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function bulkRestore($ids) |
| 399 | 399 | { |
| 400 | - return DB::transaction(function () use ($ids) { |
|
| 400 | + return DB::transaction(function() use ($ids) { |
|
| 401 | 401 | try { |
| 402 | 402 | $query = $this->model->withTrashed()->whereIn('id', $ids); |
| 403 | 403 | $objects = $query->get(); |
| 404 | 404 | |
| 405 | 405 | $query->restore(); |
| 406 | 406 | |
| 407 | - $objects->each(function ($object) { |
|
| 407 | + $objects->each(function($object) { |
|
| 408 | 408 | $this->afterRestore($object); |
| 409 | 409 | }); |
| 410 | 410 | } catch (\Exception $e) { |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | */ |
| 665 | 665 | public function getFormFieldsForBrowser($object, $relation, $routePrefix = null, $titleKey = 'title', $moduleName = null) |
| 666 | 666 | { |
| 667 | - return $object->$relation->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 667 | + return $object->$relation->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 668 | 668 | return [ |
| 669 | 669 | 'id' => $relatedElement->id, |
| 670 | 670 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | */ |
| 684 | 684 | public function getFormFieldsForRelatedBrowser($object, $relation) |
| 685 | 685 | { |
| 686 | - return $object->getRelated($relation)->map(function ($relatedElement) { |
|
| 686 | + return $object->getRelated($relation)->map(function($relatedElement) { |
|
| 687 | 687 | return ($relatedElement != null) ? [ |
| 688 | 688 | 'id' => $relatedElement->id, |
| 689 | 689 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | ]) + (classHasTrait($relatedElement, HasMedias::class) ? [ |
| 694 | 694 | 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 695 | 695 | ] : []) : []; |
| 696 | - })->reject(function ($item) { |
|
| 696 | + })->reject(function($item) { |
|
| 697 | 697 | return empty($item); |
| 698 | 698 | })->values()->toArray(); |
| 699 | 699 | } |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | { |
| 789 | 789 | if (isset($scopes[$scopeField])) { |
| 790 | 790 | $id = $scopes[$scopeField]; |
| 791 | - $query->whereHas($scopeRelation, function ($query) use ($id, $scopeField) { |
|
| 791 | + $query->whereHas($scopeRelation, function($query) use ($id, $scopeField) { |
|
| 792 | 792 | $query->where($scopeField, $id); |
| 793 | 793 | }); |
| 794 | 794 | unset($scopes[$scopeField]); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | { |
| 820 | 820 | |
| 821 | 821 | if (isset($scopes[$scopeField]) && is_string($scopes[$scopeField])) { |
| 822 | - $query->where(function ($query) use (&$scopes, $scopeField, $orFields) { |
|
| 822 | + $query->where(function($query) use (&$scopes, $scopeField, $orFields) { |
|
| 823 | 823 | foreach ($orFields as $field) { |
| 824 | 824 | $query->orWhere($field, $this->getLikeOperator(), '%' . $scopes[$scopeField] . '%'); |
| 825 | 825 | unset($scopes[$field]); |
@@ -56,14 +56,14 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $blocksFromConfig = $this->config->get('twill.block_editor.' . ($repeater ? 'repeaters' : 'blocks')); |
| 58 | 58 | |
| 59 | - $block['type'] = Collection::make($blocksFromConfig)->search(function ($blockConfig) use ($block) { |
|
| 59 | + $block['type'] = Collection::make($blocksFromConfig)->search(function($blockConfig) use ($block) { |
|
| 60 | 60 | return $blockConfig['component'] === $block['type']; |
| 61 | 61 | }); |
| 62 | 62 | |
| 63 | 63 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
| 64 | 64 | |
| 65 | 65 | if ($block['browsers']) { |
| 66 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
| 66 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
| 67 | 67 | return Collection::make($items)->pluck('id'); |
| 68 | 68 | })->toArray(); |
| 69 | 69 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | if (Schema::hasTable('fileables') && Schema::hasColumn('fileables', 'locale')) { |
| 11 | - Schema::table('fileables', function (Blueprint $table) { |
|
| 11 | + Schema::table('fileables', function(Blueprint $table) { |
|
| 12 | 12 | $table->string('locale', 7)->change(); |
| 13 | 13 | }); |
| 14 | 14 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public function down() |
| 18 | 18 | { |
| 19 | 19 | if (Schema::hasTable('fileables') && Schema::hasColumn('fileables', 'locale')) { |
| 20 | - Schema::table('fileables', function (Blueprint $table) { |
|
| 20 | + Schema::table('fileables', function(Blueprint $table) { |
|
| 21 | 21 | $table->string('locale', 6)->change(); |
| 22 | 22 | }); |
| 23 | 23 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('related', function (Blueprint $table) { |
|
| 16 | + Schema::create('related', function(Blueprint $table) { |
|
| 17 | 17 | $table->integer('subject_id')->nullable()->unsigned(); |
| 18 | 18 | $table->string('subject_type', 255); |
| 19 | 19 | $table->integer('related_id')->nullable()->unsigned(); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $twillUsersTable = config('twill.users_table', 'twill_users'); |
| 17 | 17 | |
| 18 | 18 | if (!Schema::hasTable($twillUsersTable)) { |
| 19 | - Schema::create($twillUsersTable, function (Blueprint $table) { |
|
| 19 | + Schema::create($twillUsersTable, function(Blueprint $table) { |
|
| 20 | 20 | createDefaultTableFields($table); |
| 21 | 21 | $table->string('name'); |
| 22 | 22 | $table->string('email')->unique(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $twillPasswordResetsTable = config('twill.password_resets_table', 'twill_password_resets'); |
| 32 | 32 | |
| 33 | 33 | if (!Schema::hasTable($twillPasswordResetsTable)) { |
| 34 | - Schema::create($twillPasswordResetsTable, function (Blueprint $table) { |
|
| 34 | + Schema::create($twillPasswordResetsTable, function(Blueprint $table) { |
|
| 35 | 35 | $table->string('email')->index(); |
| 36 | 36 | $table->string('token')->index(); |
| 37 | 37 | $table->timestamp('created_at')->nullable(); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('settings', function (Blueprint $table) { |
|
| 16 | + Schema::create('settings', function(Blueprint $table) { |
|
| 17 | 17 | $table->increments('id'); |
| 18 | 18 | $table->timestamps(); |
| 19 | 19 | $table->softDeletes(); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $table->string('section')->nullable()->index(); |
| 22 | 22 | }); |
| 23 | 23 | |
| 24 | - Schema::create('setting_translations', function (Blueprint $table) { |
|
| 24 | + Schema::create('setting_translations', function(Blueprint $table) { |
|
| 25 | 25 | createDefaultTranslationsTableFields($table, 'setting'); |
| 26 | 26 | $table->text('value')->nullable(); |
| 27 | 27 | }); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | if (Schema::hasTable('mediables') && !Schema::hasColumn('mediables', 'locale')) { |
| 11 | - Schema::table('mediables', function (Blueprint $table) { |
|
| 11 | + Schema::table('mediables', function(Blueprint $table) { |
|
| 12 | 12 | $table->string('locale', 7)->default($this->getCurrentLocale())->index(); |
| 13 | 13 | }); |
| 14 | 14 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public function down() |
| 18 | 18 | { |
| 19 | 19 | if (Schema::hasTable('mediables') && Schema::hasColumn('mediables', 'locale')) { |
| 20 | - Schema::table('mediables', function (Blueprint $table) { |
|
| 20 | + Schema::table('mediables', function(Blueprint $table) { |
|
| 21 | 21 | $table->dropIndex('mediables_locale_index'); |
| 22 | 22 | $table->dropColumn('locale'); |
| 23 | 23 | }); |