From 073b044f7e673ce3fcca6a1f4cdaa13ed14eaabf Mon Sep 17 00:00:00 2001 From: petertsoisstuff <33865429+petertsoisstuff@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:10:18 +0800 Subject: [PATCH 01/14] handle locale value in afterDuplicateHandleMedias copy the locale value when duplicate. --- src/Repositories/Behaviors/HandleMedias.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repositories/Behaviors/HandleMedias.php b/src/Repositories/Behaviors/HandleMedias.php index c2a716a95..4d38b58c1 100644 --- a/src/Repositories/Behaviors/HandleMedias.php +++ b/src/Repositories/Behaviors/HandleMedias.php @@ -206,6 +206,7 @@ public function afterDuplicateHandleMedias(TwillModelContract $original, TwillMo 'crop_x' => $media->pivot->crop_x, 'crop_y' => $media->pivot->crop_y, 'metadatas' => $media->pivot->metadatas, + 'locale' => $media->pivot->locale, ]; $newObject->medias()->attach($media->id, $newPushData); From 7be10cc72f46d3347e8baacfacccc79e9275c07e Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 30 May 2023 19:54:26 +0600 Subject: [PATCH 02/14] handling groups of fields fix Use native fields cleaning to avoid a deep values removing --- src/Repositories/Behaviors/HandleFieldsGroups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/Behaviors/HandleFieldsGroups.php b/src/Repositories/Behaviors/HandleFieldsGroups.php index c35ff27ff..f2f1f7d6c 100644 --- a/src/Repositories/Behaviors/HandleFieldsGroups.php +++ b/src/Repositories/Behaviors/HandleFieldsGroups.php @@ -119,7 +119,7 @@ protected function handleFieldsGroups($fields) $fields[$group] = null; } - Arr::forget($fields, $groupFields); + $fields = array_filter($fields, fn($key) => !in_array($key, $groupFields), ARRAY_FILTER_USE_KEY); } return $fields; From 777ad6fb6b7b051c421be9da126a794f2d3858a7 Mon Sep 17 00:00:00 2001 From: Mike Byrne Date: Mon, 19 Jun 2023 20:50:54 +0100 Subject: [PATCH 03/14] adds `direction` option to form inputs It maybe that you content entry is in a RTL language, such as Arabic, but, you want to LTR content such as a URL or an email address. Or, it maybe your content entry is in a LTR language and you need a single RTL entry field. This commit adds `direction` for this purpose: ``` Input::make() ->name('url') ->label(twillTrans('Url')) ->direction('ltr') ``` --- frontend/js/mixins/input.js | 4 ++++ frontend/js/mixins/locale.js | 3 +++ src/Services/Forms/Fields/Input.php | 2 ++ .../Forms/Fields/Traits/HasDirection.php | 18 ++++++++++++++++++ src/Services/Forms/Fields/Wysiwyg.php | 2 ++ src/View/Components/Fields/Input.php | 1 + views/partials/form/_input.blade.php | 2 ++ 7 files changed, 32 insertions(+) create mode 100644 src/Services/Forms/Fields/Traits/HasDirection.php diff --git a/frontend/js/mixins/input.js b/frontend/js/mixins/input.js index 2fb813dd8..8be4ea446 100755 --- a/frontend/js/mixins/input.js +++ b/frontend/js/mixins/input.js @@ -12,6 +12,10 @@ export default { type: String, default: '' }, + direction: { + type: String, + default: 'auto' + }, name: { default: '' }, diff --git a/frontend/js/mixins/locale.js b/frontend/js/mixins/locale.js index e12e639c3..d191648d0 100755 --- a/frontend/js/mixins/locale.js +++ b/frontend/js/mixins/locale.js @@ -41,6 +41,9 @@ export default { else return false }, dirLocale: function () { + if (this.direction && this.direction !== 'auto') { + return this.direction; + } return (this.isLocaleRTL ? 'rtl' : 'auto') }, displayedLocale: function () { diff --git a/src/Services/Forms/Fields/Input.php b/src/Services/Forms/Fields/Input.php index 932aa409d..75137be44 100644 --- a/src/Services/Forms/Fields/Input.php +++ b/src/Services/Forms/Fields/Input.php @@ -7,6 +7,7 @@ use A17\Twill\Services\Forms\Fields\Traits\HasMin; use A17\Twill\Services\Forms\Fields\Traits\HasOnChange; use A17\Twill\Services\Forms\Fields\Traits\HasPlaceholder; +use A17\Twill\Services\Forms\Fields\Traits\HasDirection; use A17\Twill\Services\Forms\Fields\Traits\IsTranslatable; /** @@ -19,6 +20,7 @@ class Input extends BaseFormField use HasMax; use HasMaxlength; use HasPlaceholder; + use HasDirection; use HasOnChange; /** diff --git a/src/Services/Forms/Fields/Traits/HasDirection.php b/src/Services/Forms/Fields/Traits/HasDirection.php new file mode 100644 index 000000000..65cc22fe9 --- /dev/null +++ b/src/Services/Forms/Fields/Traits/HasDirection.php @@ -0,0 +1,18 @@ +direction = $direction === 'ltr' || $direction === 'rtl' ? $direction : 'auto'; + + return $this; + } +} diff --git a/src/Services/Forms/Fields/Wysiwyg.php b/src/Services/Forms/Fields/Wysiwyg.php index 985376788..e84e6e871 100644 --- a/src/Services/Forms/Fields/Wysiwyg.php +++ b/src/Services/Forms/Fields/Wysiwyg.php @@ -6,6 +6,7 @@ use A17\Twill\Services\Forms\Fields\Traits\HasMaxlength; use A17\Twill\Services\Forms\Fields\Traits\HasOnChange; use A17\Twill\Services\Forms\Fields\Traits\HasPlaceholder; +use A17\Twill\Services\Forms\Fields\Traits\HasDirection; use A17\Twill\Services\Forms\Fields\Traits\IsTranslatable; class Wysiwyg extends BaseFormField @@ -13,6 +14,7 @@ class Wysiwyg extends BaseFormField use IsTranslatable; use HasMaxlength; use HasPlaceholder; + use HasDirection; use HasOnChange; public bool $hideCounter = false; diff --git a/src/View/Components/Fields/Input.php b/src/View/Components/Fields/Input.php index d7f8e9ae7..64890cc37 100644 --- a/src/View/Components/Fields/Input.php +++ b/src/View/Components/Fields/Input.php @@ -21,6 +21,7 @@ public function __construct( // Component specific public string $type = 'text', public ?string $placeholder = '', + public ?string $direction = 'auto', public ?int $maxlength = null, public ?int $rows = null, public ?string $ref = null, diff --git a/views/partials/form/_input.blade.php b/views/partials/form/_input.blade.php index 77b6ade1a..b45c150f7 100644 --- a/views/partials/form/_input.blade.php +++ b/views/partials/form/_input.blade.php @@ -8,6 +8,7 @@ @if ($required) required: true, @endif @if ($note) note: '{{ $note }}', @endif @if ($placeholder) placeholder: '{{ addslashes($placeholder) }}', @endif + @if ($direction) direction: '{{ $direction }}', @endif @if ($maxlength) maxlength: {{ $maxlength }}, @endif @if ($disabled) disabled: true, @endif @if ($readOnly) readonly: true, @endif @@ -35,6 +36,7 @@ @if ($required) :required="true" @endif @if ($note) note="{{ $note }}" @endif @if ($placeholder) placeholder="{{ $placeholder }}" @endif + @if ($direction) direction="{{ $direction }}" @endif @if ($maxlength) :maxlength="{{ $maxlength }}" @endif @if ($disabled) disabled @endif @if ($readOnly) readonly @endif From 83fbeeb9b75c3603f61c52eb8a6ea91e087b1a05 Mon Sep 17 00:00:00 2001 From: Mike Byrne Date: Tue, 20 Jun 2023 11:34:29 +0100 Subject: [PATCH 04/14] add `direction` option to WYSIWYG --- src/View/Components/Fields/Wysiwyg.php | 1 + views/partials/form/_wysiwyg.blade.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/View/Components/Fields/Wysiwyg.php b/src/View/Components/Fields/Wysiwyg.php index aa291a101..df20d382d 100644 --- a/src/View/Components/Fields/Wysiwyg.php +++ b/src/View/Components/Fields/Wysiwyg.php @@ -21,6 +21,7 @@ public function __construct( // Component specific public bool $hideCounter = false, public ?string $placeholder = null, + public ?string $direction = 'auto', public bool $editSource = false, public ?array $toolbarOptions = null, public ?int $maxlength = null, diff --git a/views/partials/form/_wysiwyg.blade.php b/views/partials/form/_wysiwyg.blade.php index 067e9d74f..378b7fe3a 100644 --- a/views/partials/form/_wysiwyg.blade.php +++ b/views/partials/form/_wysiwyg.blade.php @@ -15,6 +15,7 @@ @if ($required) required: true, @endif @if ($options) options: {!! e(json_encode($options)) !!}, @endif @if ($placeholder) placeholder: '{{ addslashes($placeholder) }}', @endif + @if ($direction) direction: '{{ $direction }}', @endif @if ($maxlength) maxlength: {{ $maxlength }}, @endif @if ($hideCounter) showCounter: false, @endif @if ($disabled) disabled: true, @endif @@ -38,6 +39,7 @@ @if ($required) :required="true" @endif @if ($options) :options='{!! json_encode($options) !!}' @endif @if ($placeholder) placeholder='{{ $placeholder }}' @endif + @if ($direction) direction="{{ $direction }}" @endif @if ($maxlength) :maxlength='{{ $maxlength }}' @endif @if ($hideCounter) :showCounter='false' @endif @if ($disabled) disabled @endif @@ -64,6 +66,7 @@ @if ($required) required: true, @endif @if ($options) options: {!! e(json_encode($options)) !!}, @endif @if ($placeholder) placeholder: '{{ addslashes($placeholder) }}', @endif + @if ($direction) direction: '{{ $direction }}', @endif @if ($maxlength) maxlength: {{ $maxlength }}, @endif @if ($hideCounter) showCounter: false, @endif @if ($disabled) disabled: true, @endif @@ -86,6 +89,7 @@ @if ($required) :required="true" @endif @if ($options) :options='{!! json_encode($options) !!}' @endif @if ($placeholder) placeholder='{{ $placeholder }}' @endif + @if ($direction) direction="{{ $direction }}" @endif @if ($maxlength) :maxlength='{{ $maxlength }}' @endif @if ($hideCounter) :showCounter='false' @endif @if ($disabled) disabled @endif From 21ef1fcb5e58db99940f9beb6373bf6944fd5944 Mon Sep 17 00:00:00 2001 From: Mike Byrne Date: Tue, 20 Jun 2023 11:48:40 +0100 Subject: [PATCH 05/14] adds `direction` notes to docs --- docs/content/1_docs/4_form-fields/01_input.md | 15 +++++++- .../1_docs/4_form-fields/02_wysiwyg.md | 35 +++++++++++-------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/docs/content/1_docs/4_form-fields/01_input.md b/docs/content/1_docs/4_form-fields/01_input.md index dd45621d5..66d4e3746 100644 --- a/docs/content/1_docs/4_form-fields/01_input.md +++ b/docs/content/1_docs/4_form-fields/01_input.md @@ -37,6 +37,7 @@ Input::make() type="textarea" :rows="3" :translated="true" + direction="ltr" /> ``` @@ -62,7 +63,8 @@ Input::make() 'note' => 'Hint message goes here', 'placeholder' => 'Placeholder goes here', 'type' => 'textarea', - 'rows' => 3 + 'rows' => 3, + 'direction' => 'ltr' ]) ``` @@ -85,6 +87,7 @@ Input::make() | readonly | Sets the field as readonly | boolean | false | | default | Sets a default value if empty | string | | | mask | Set a mask using the alpinejs mask plugin | string | | +| direction | Set custom input direction (from `v3.0.3`) | ltr
rtl
auto | auto | Specific options for the "number" type: @@ -122,3 +125,13 @@ Schema::table('articles', function (Blueprint $table) { ``` When used in a [block](../5_block-editor), no migration is needed, as data contained in blocks, including componentBlocks, is stored in a separate table from the model, which is managed by Twill for you. + +## Manually setting input direction + +Introduced in `v3.0.3` + +For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input. + +For example, maybe you have an Arabic translated page and need URL which mixes Arabic with an `ltr` domain name and TLD. In this case content entry maybe proving difficult for your CMS users with a `rtl` input; in which case you may find setting the direction to `ltr` beneficial. + +You may also simply just need a single Hebrew text entry in an otherwise `ltr` form. diff --git a/docs/content/1_docs/4_form-fields/02_wysiwyg.md b/docs/content/1_docs/4_form-fields/02_wysiwyg.md index e95d733b2..097c2fd0d 100644 --- a/docs/content/1_docs/4_form-fields/02_wysiwyg.md +++ b/docs/content/1_docs/4_form-fields/02_wysiwyg.md @@ -101,20 +101,21 @@ $wysiwygOptions = [ ``` -| Option | Description | Type/values | Default value | -|:---------------|:-------------------------------------------------------------------------------------------------------------------------|:-----------------|:--------------| -| name | Name of the field | string | | -| label | Label of the field | string | | -| type | Type of wysiwyg field | quill
tiptap | tiptap | -| toolbarOptions | Array of options/tools that will be displayed in the editor | | See above | -| editSource | Displays a button to view source code | boolean | false | -| hideCounter | Hide the character counter displayed at the bottom | boolean | false | -| limitHeight | Limit the editor height from growing beyond the viewport | boolean | false | -| translated | Defines if the field is translatable | boolean | false | -| maxlength | Max character count of the field | integer | | -| note | Hint message displayed above the field | string | | -| placeholder | Text displayed as a placeholder in the field | string | | -| required | Displays an indicator that this field is required
A backend validation rule is required to prevent users from saving | boolean | false | +| Option | Description | Type/values | Default value | +|:---------------|:-------------------------------------------------------------------------------------------------------------------------|:--------------------|:--------------| +| name | Name of the field | string | | +| label | Label of the field | string | | +| type | Type of wysiwyg field | quill
tiptap | tiptap | +| toolbarOptions | Array of options/tools that will be displayed in the editor | | See above | +| editSource | Displays a button to view source code | boolean | false | +| hideCounter | Hide the character counter displayed at the bottom | boolean | false | +| limitHeight | Limit the editor height from growing beyond the viewport | boolean | false | +| translated | Defines if the field is translatable | boolean | false | +| maxlength | Max character count of the field | integer | | +| note | Hint message displayed above the field | string | | +| placeholder | Text displayed as a placeholder in the field | string | | +| required | Displays an indicator that this field is required
A backend validation rule is required to prevent users from saving | boolean | false | +| direction | Set custom input direction (from `v3.0.3`) | ltr
rtl
auto | auto | Note that Quill outputs CSS classes in the HTML for certain toolbar modules (indent, font, align, etc.), and that the image module is not integrated with Twill's media library. It outputs the base64 representation of the uploaded image. It is not a recommended way of using and storing images, prefer using one or multiple `medias` form fields or blocks fields for flexible content. This will give you greater control over your frontend output. @@ -171,3 +172,9 @@ For regular fields on models you will have to manually call `parseInternalLinks` ```blade {{ \A17\Twill\Facades\TwillUtil::parseInternalLinks($item->description) }} ``` + +## Manually setting input direction + +Introduced in `v3.0.3` + +For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input; for example you may need a single Hebrew text entry in an otherwise `ltr` form. From 6e363cdc12a2869bd41fdb26b666978a540d43bf Mon Sep 17 00:00:00 2001 From: Mike Byrne Date: Tue, 20 Jun 2023 14:34:17 +0100 Subject: [PATCH 06/14] update `directions` release version --- docs/content/1_docs/4_form-fields/01_input.md | 4 ++-- docs/content/1_docs/4_form-fields/02_wysiwyg.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content/1_docs/4_form-fields/01_input.md b/docs/content/1_docs/4_form-fields/01_input.md index 66d4e3746..555265b7a 100644 --- a/docs/content/1_docs/4_form-fields/01_input.md +++ b/docs/content/1_docs/4_form-fields/01_input.md @@ -87,7 +87,7 @@ Input::make() | readonly | Sets the field as readonly | boolean | false | | default | Sets a default value if empty | string | | | mask | Set a mask using the alpinejs mask plugin | string | | -| direction | Set custom input direction (from `v3.0.3`) | ltr
rtl
auto | auto | +| direction | Set custom input direction (from `v3.1.0`) | ltr
rtl
auto | auto | Specific options for the "number" type: @@ -128,7 +128,7 @@ When used in a [block](../5_block-editor), no migration is needed, as data conta ## Manually setting input direction -Introduced in `v3.0.3` +Introduced in `v3.1.0` For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input. diff --git a/docs/content/1_docs/4_form-fields/02_wysiwyg.md b/docs/content/1_docs/4_form-fields/02_wysiwyg.md index 097c2fd0d..64e146acb 100644 --- a/docs/content/1_docs/4_form-fields/02_wysiwyg.md +++ b/docs/content/1_docs/4_form-fields/02_wysiwyg.md @@ -115,7 +115,7 @@ $wysiwygOptions = [ | note | Hint message displayed above the field | string | | | placeholder | Text displayed as a placeholder in the field | string | | | required | Displays an indicator that this field is required
A backend validation rule is required to prevent users from saving | boolean | false | -| direction | Set custom input direction (from `v3.0.3`) | ltr
rtl
auto | auto | +| direction | Set custom input direction (from `v3.1.0`) | ltr
rtl
auto | auto | Note that Quill outputs CSS classes in the HTML for certain toolbar modules (indent, font, align, etc.), and that the image module is not integrated with Twill's media library. It outputs the base64 representation of the uploaded image. It is not a recommended way of using and storing images, prefer using one or multiple `medias` form fields or blocks fields for flexible content. This will give you greater control over your frontend output. @@ -175,6 +175,6 @@ For regular fields on models you will have to manually call `parseInternalLinks` ## Manually setting input direction -Introduced in `v3.0.3` +Introduced in `v3.1.0` For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input; for example you may need a single Hebrew text entry in an otherwise `ltr` form. From 35d0bbcb8a35e04bd3c52de4b82c54bd095d977f Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 23 Jun 2023 15:11:10 -0400 Subject: [PATCH 07/14] Allow dashboard modules to wrap onto next line --- frontend/js/components/dashboard/shortcutCreator.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/js/components/dashboard/shortcutCreator.vue b/frontend/js/components/dashboard/shortcutCreator.vue index f78614bd2..a5de344d4 100755 --- a/frontend/js/components/dashboard/shortcutCreator.vue +++ b/frontend/js/components/dashboard/shortcutCreator.vue @@ -83,13 +83,19 @@ border-bottom: 1px solid $color__border; } + .shortcutCreator .wrapper--reverse { + @include breakpoint('medium+') { + flex-flow: row-reverse; + } + } + .shortcutCreator__listing { display: flex; flex-grow: 1; flex-flow: column nowrap; @include breakpoint('small+') { - flex-flow: row nowrap; + flex-flow: row wrap; } } From f9a096a6e6b579798f09e2773b33a06a95189a00 Mon Sep 17 00:00:00 2001 From: Keania Eric Date: Thu, 19 Oct 2023 18:04:17 +0100 Subject: [PATCH 08/14] configure permissions and roles table names --- config/twill.php | 2 ++ .../2020_04_20_000001_support_permission.php | 33 +++++++++++-------- src/Models/Permission.php | 6 ++++ src/Models/Role.php | 6 ++++ 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/config/twill.php b/config/twill.php index 26644077e..d66899fc7 100644 --- a/config/twill.php +++ b/config/twill.php @@ -143,6 +143,8 @@ 'tags_table' => 'twill_tags', 'users_oauth_table' => 'twill_users_oauth', 'users_table' => 'twill_users', + 'permissions_table' => 'permissions', + 'roles_table' => 'roles', /* |-------------------------------------------------------------------------- diff --git a/migrations/optional/permissions-management/2020_04_20_000001_support_permission.php b/migrations/optional/permissions-management/2020_04_20_000001_support_permission.php index 8faf8e869..bc4048a8e 100644 --- a/migrations/optional/permissions-management/2020_04_20_000001_support_permission.php +++ b/migrations/optional/permissions-management/2020_04_20_000001_support_permission.php @@ -16,15 +16,18 @@ class SupportPermission extends Migration */ public function up() { - if (!Schema::hasTable('permissions') + $permissionsTableName = config('twill.permissions_table', 'permissions'); + $rolesTableName = config('twill.roles_table', 'roles'); + + if (!Schema::hasTable($permissionsTableName) && !Schema::hasTable('groups') - && !Schema::hasTable('roles') + && !Schema::hasTable($rolesTableName) && !Schema::hasTable('permission_twill_user') && !Schema::hasTable('group_twill_user') && !Schema::hasTable('group_permission') && !Schema::hasTable('permission_role') ) { - Schema::create('permissions', function (Blueprint $table) { + Schema::create($permissionsTableName, function (Blueprint $table) { createDefaultTableFields($table); $table->string('name'); $table->string('display_name')->nullable(); @@ -40,14 +43,14 @@ public function up() $table->boolean('is_everyone_group')->default(false); }); - Schema::create('roles', function (Blueprint $table) { + Schema::create($rolesTableName, function (Blueprint $table) { createDefaultTableFields($table); $table->string('name', 255)->nullable(); $table->boolean('in_everyone_group')->default(true); $table->integer('position')->unsigned()->nullable(); }); - Schema::create('permission_twill_user', function (Blueprint $table) { + Schema::create('permission_twill_user', function (Blueprint $table) use($permissionsTableName) { $table->bigInteger('twill_user_id')->unsigned()->nullable(); $table->foreign('twill_user_id') ->references('id') @@ -57,7 +60,7 @@ public function up() $table->bigInteger('permission_id')->unsigned()->nullable(); $table->foreign('permission_id') ->references('id') - ->on('permissions') + ->on($permissionsTableName) ->onDelete('cascade'); }); @@ -77,11 +80,11 @@ public function up() $table->integer('position')->unsigned()->nullable(); }); - Schema::create('group_permission', function (Blueprint $table) { + Schema::create('group_permission', function (Blueprint $table) use($permissionsTableName) { $table->bigInteger('permission_id')->unsigned()->nullable(); $table->foreign('permission_id') ->references('id') - ->on('permissions') + ->on($permissionsTableName) ->onDelete('cascade'); $table->bigInteger('group_id')->unsigned()->nullable(); @@ -91,17 +94,17 @@ public function up() ->onDelete('cascade'); }); - Schema::create('permission_role', function (Blueprint $table) { + Schema::create('permission_role', function (Blueprint $table) use($permissionsTableName, $rolesTableName) { $table->bigInteger('permission_id')->unsigned()->nullable(); $table->foreign('permission_id') ->references('id') - ->on('permissions') + ->on($permissionsTableName) ->onDelete('cascade'); $table->bigInteger('role_id')->unsigned()->nullable(); $table->foreign('role_id') ->references('id') - ->on('roles') + ->on($rolesTableName) ->onDelete('cascade'); }); @@ -118,13 +121,17 @@ public function up() */ public function down() { + $permissionsTableName = config('twill.permissions_table', 'permissions'); + $rolesTableName = config('twill.roles_table', 'roles'); + + Schema::dropIfExists('permission_twill_user'); Schema::dropIfExists('group_twill_user'); Schema::dropIfExists('group_permission'); Schema::dropIfExists('permission_role'); - Schema::dropIfExists('permissions'); + Schema::dropIfExists($permissionsTableName); Schema::dropIfExists('groups'); - Schema::dropIfExists('roles'); + Schema::dropIfExists($rolesTableName); } private function seedBasicPermissions() diff --git a/src/Models/Permission.php b/src/Models/Permission.php index 9c34b6ea5..743a39142 100644 --- a/src/Models/Permission.php +++ b/src/Models/Permission.php @@ -42,6 +42,12 @@ class Permission extends BaseModel 'is_default', ]; + public function __construct(array $attributes = []) + { + $this->table = config('twill.permissions_table', 'permissions'); + parent::__construct($attributes); + } + protected $appends = ['permissionable_module']; /** diff --git a/src/Models/Role.php b/src/Models/Role.php index 343256eb4..a3fa1c715 100644 --- a/src/Models/Role.php +++ b/src/Models/Role.php @@ -38,6 +38,12 @@ class Role extends BaseModel implements Sortable, TwillModelContract 'deleted_at' => 'datetime' ]; + public function __construct(array $attributes = []) + { + $this->table = config('twill.roles_table', 'roles'); + parent::__construct($attributes); + } + public function scopeAccessible($query): Builder { $currentUser = auth('twill_users')->user(); From c97ef8da2db4675e4ed5e6b38d0e3cfe506c500f Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Thu, 2 Nov 2023 21:25:21 +0300 Subject: [PATCH 09/14] Fix artisan command --- docs/content/1_docs/4_form-fields/06_multi-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/1_docs/4_form-fields/06_multi-select.md b/docs/content/1_docs/4_form-fields/06_multi-select.md index ed61942f7..e71efe692 100644 --- a/docs/content/1_docs/4_form-fields/06_multi-select.md +++ b/docs/content/1_docs/4_form-fields/06_multi-select.md @@ -168,7 +168,7 @@ In this case that it can be implemented as follows: - Create a Sectors [module](../3_modules/2_cli-generator.md) ``` -php artisan twill:module sectors +php artisan twill:make:module sectors ``` - Create a migration for a pivot table. From 7bdba63093646e82cff2becb6750d88f158ef782 Mon Sep 17 00:00:00 2001 From: Roy de Vos Burchart Date: Fri, 3 Nov 2023 14:37:34 +0100 Subject: [PATCH 10/14] Always include `locale` in the mediables pivot --- src/Models/Behaviors/HasMedias.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Models/Behaviors/HasMedias.php b/src/Models/Behaviors/HasMedias.php index a3814e9df..685d14305 100644 --- a/src/Models/Behaviors/HasMedias.php +++ b/src/Models/Behaviors/HasMedias.php @@ -44,20 +44,18 @@ public function medias() Media::class, 'mediable', config('twill.mediables_table', 'twill_mediables') - )->withPivot( - array_merge([ - 'crop', - 'role', - 'crop_w', - 'crop_h', - 'crop_x', - 'crop_y', - 'lqip_data', - 'ratio', - 'metadatas', - ], config('twill.media_library.translated_form_fields', false) ? ['locale'] : []) - ) - ->withTimestamps()->orderBy(config('twill.mediables_table', 'twill_mediables') . '.id', 'asc'); + )->withPivot([ + 'crop', + 'role', + 'crop_w', + 'crop_h', + 'crop_x', + 'crop_y', + 'lqip_data', + 'ratio', + 'metadatas', + 'locale', + ])->withTimestamps()->orderBy(config('twill.mediables_table', 'twill_mediables') . '.id', 'asc'); } private function findMedia($role, $crop = 'default') From fa64cac62958ae6a16e2a076c8a0c360f091451c Mon Sep 17 00:00:00 2001 From: Cole Geissinger Date: Thu, 2 Nov 2023 19:12:11 -0700 Subject: [PATCH 11/14] [Docs] Fix typo in create page module --- .../1_page-builder-with-blade/4_creating-the-page-module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2_guides/1_page-builder-with-blade/4_creating-the-page-module.md b/docs/content/2_guides/1_page-builder-with-blade/4_creating-the-page-module.md index 22f5b8cde..e8616efde 100644 --- a/docs/content/2_guides/1_page-builder-with-blade/4_creating-the-page-module.md +++ b/docs/content/2_guides/1_page-builder-with-blade/4_creating-the-page-module.md @@ -1,6 +1,6 @@ # Creating the page module -Now that we area ready with the initial setup of Laravel and Twill we can start building our CMS. +Now that we are ready with the initial setup of Laravel and Twill we can start building our CMS. In Twill we use Modules. A module is a single "content type" and exists out of a few files: From 7bdccac1bdcb954fb79e4caa8ec24a5a9e2975df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:56:50 +0000 Subject: [PATCH 12/14] Bump @babel/traverse from 7.20.12 to 7.23.2 Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.20.12 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 252 +++++++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 124 deletions(-) diff --git a/package-lock.json b/package-lock.json index 81d0fbe97..e363dc73d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,12 +113,13 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" @@ -182,13 +183,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.7.tgz", - "integrity": "sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.20.7", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" }, "engines": { @@ -309,9 +311,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" @@ -330,25 +332,25 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", - "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.18.10", - "@babel/types": "^7.19.0" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -478,30 +480,30 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -546,13 +548,13 @@ } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -560,9 +562,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.7.tgz", - "integrity": "sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "bin": { "parser": "bin/babel-parser.js" }, @@ -1737,33 +1739,33 @@ } }, "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.20.12", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz", - "integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.20.7", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.19.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1772,13 +1774,13 @@ } }, "node_modules/@babel/types": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.7.tgz", - "integrity": "sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -14151,12 +14153,13 @@ } }, "@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" } }, "@babel/compat-data": { @@ -14200,13 +14203,14 @@ } }, "@babel/generator": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.7.tgz", - "integrity": "sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "requires": { - "@babel/types": "^7.20.7", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" }, "dependencies": { @@ -14296,9 +14300,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true }, "@babel/helper-explode-assignable-expression": { @@ -14311,22 +14315,22 @@ } }, "@babel/helper-function-name": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", - "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "requires": { - "@babel/template": "^7.18.10", - "@babel/types": "^7.19.0" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" } }, "@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-member-expression-to-functions": { @@ -14423,24 +14427,24 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true }, "@babel/helper-validator-option": { @@ -14473,20 +14477,20 @@ } }, "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.7.tgz", - "integrity": "sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg==" + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==" }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { "version": "7.18.6", @@ -15268,42 +15272,42 @@ } }, "@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" } }, "@babel/traverse": { - "version": "7.20.12", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz", - "integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.20.7", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.19.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.7.tgz", - "integrity": "sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" } }, From f10733d4b05b51ee5774d93980173f3dff5f85f1 Mon Sep 17 00:00:00 2001 From: Roy de Vos Burchart Date: Fri, 3 Nov 2023 14:20:10 +0100 Subject: [PATCH 13/14] Fixes to reduce excessive number of queries --- src/Models/AppSetting.php | 13 +++++++++++++ src/Services/Settings/SettingsGroup.php | 11 +++++------ src/TwillAppSettings.php | 2 +- tests/integration/Settings/SettingsFacadeTest.php | 4 ++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Models/AppSetting.php b/src/Models/AppSetting.php index 91e8f324d..bb8a4c6d7 100644 --- a/src/Models/AppSetting.php +++ b/src/Models/AppSetting.php @@ -26,6 +26,19 @@ class AppSetting extends Model private bool $didRegisterSettingsBlocks = false; + public static function booted() + { + self::saving(function (self $model) { + /* + * Here we remove the 'blocks' relation so that any developer hooking + * into the saved event on the AppSetting can still fetch the settings + * with the new values. The next time the setting facade is called to + * retrieve a setting, the blocks relation is hydrated again. + */ + $model->unsetRelation('blocks'); + }); + } + /** * @return array|array */ diff --git a/src/Services/Settings/SettingsGroup.php b/src/Services/Settings/SettingsGroup.php index 63701a016..2707995b4 100644 --- a/src/Services/Settings/SettingsGroup.php +++ b/src/Services/Settings/SettingsGroup.php @@ -18,6 +18,8 @@ class SettingsGroup private ?Closure $availableWhen = null; + private AppSetting $appSetting; + public static function make(): self { return new self(); @@ -70,12 +72,9 @@ public function hasSection(string $sectionName): bool public function getSettingsModel(): AppSetting { - $settingsModel = AppSetting::where(['name' => $this->getName()])->first(); - if (!$settingsModel) { - $settingsModel = AppSetting::create(['name' => $this->getName()]); - } - - return $settingsModel; + return $this->appSetting ??= AppSetting::firstOrCreate([ + 'name' => $this->getName(), + ]); } /** diff --git a/src/TwillAppSettings.php b/src/TwillAppSettings.php index 32de3b73f..17efa6bef 100644 --- a/src/TwillAppSettings.php +++ b/src/TwillAppSettings.php @@ -105,7 +105,7 @@ public function getGroupDataForSectionAndName(string $group, string $section): B { $groupObject = $this->getGroupForGroupAndSectionName($group, $section); - return $groupObject->getSettingsModel()->blocks() + return $groupObject->getSettingsModel()->blocks ->where('editor_name', $section) ->where('parent_id', null) ->firstOrFail(); diff --git a/tests/integration/Settings/SettingsFacadeTest.php b/tests/integration/Settings/SettingsFacadeTest.php index 2e4ffb640..d677d1e7d 100644 --- a/tests/integration/Settings/SettingsFacadeTest.php +++ b/tests/integration/Settings/SettingsFacadeTest.php @@ -5,6 +5,7 @@ use A17\Twill\Exceptions\Settings\SettingsGroupDoesNotExistException; use A17\Twill\Exceptions\Settings\SettingsSectionDoesNotExistException; use A17\Twill\Facades\TwillAppSettings; +use A17\Twill\Models\AppSetting; use A17\Twill\Services\Settings\SettingsGroup; use A17\Twill\Tests\Integration\TestCase; @@ -66,6 +67,9 @@ public function setUp(): void ] ) ->assertStatus(200); + + /** @see AppSetting::booted() */ + $model->unsetRelation('blocks'); } public function testTranslatedSettingsGetter(): void From 0df914c494dfe83a5b59085668569e2d8c374514 Mon Sep 17 00:00:00 2001 From: Pablo Barrios Date: Thu, 31 Aug 2023 11:36:57 -0300 Subject: [PATCH 14/14] Update migration herlper for translations to default active field to false to comply with some versions of PostgreSQL --- src/Helpers/migrations_helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/migrations_helpers.php b/src/Helpers/migrations_helpers.php index edc39c9ab..3801b7561 100644 --- a/src/Helpers/migrations_helpers.php +++ b/src/Helpers/migrations_helpers.php @@ -55,7 +55,7 @@ function createDefaultTranslationsTableFields($table, $tableNameSingular, $table $table->softDeletes(); $table->timestamps(); $table->string('locale', 7)->index(); - $table->boolean('active'); + $table->boolean('active')->default(false); $table->foreign("{$tableNameSingular}_id", "fk_{$tableNameSingular}_translations_{$tableNameSingular}_id")->references('id')->on($tableNamePlural)->onDelete('CASCADE'); $table->unique(["{$tableNameSingular}_id", 'locale'], "{$tableNameSingular}_id_locale_unique");