diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e3259107..83e57687 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,10 +15,12 @@ jobs: fail-fast: true matrix: php: [8.0, 8.1] - laravel: [8.*, 9.*] + laravel: [8.*, 9.*, 10.*] dependency-version: [prefer-stable] os: [ubuntu-latest] include: + - laravel: 10.* + testbench: 8.* - laravel: 9.* testbench: 7.* - laravel: 8.* diff --git a/README.md b/README.md index 188ef219..2cc097a9 100644 --- a/README.md +++ b/README.md @@ -88,16 +88,16 @@ If you discover any security related issues, please check [SECURITY](https://git ## Credits -- [Tom Witkowski](https://github.com/Gummibeer) *current maintainer* -- [Dimitrios Savvopoulos](https://github.com/dimsav) *original author* -- [David Llop](https://github.com/Lloople) *refactoring testsuite* -- [Caneco](https://github.com/caneco) *artwork* +- [Tom Witkowski](https://github.com/Gummibeer) _current maintainer_ +- [Dimitrios Savvopoulos](https://github.com/dimsav) _original author_ +- [David Llop](https://github.com/Lloople) _refactoring testsuite_ +- [Caneco](https://github.com/caneco) _artwork_ - [All Contributors](../../contributors) ## Versions | Package | Laravel | PHP | -|:--------------------|:------------------------------|:----------| +| :------------------ | :---------------------------- | :-------- | | **v11.10 - v11.10** | `8.* / 9.*` | `^8.0` | | **v11.6 - v11.9** | `5.8.* / 6.* / 7.* / 8.*` | `>=7.2` | | **v11.4 - v11.5** | `5.6.* / 5.7.* / 5.8.* / 6.*` | `>=7.1.3` | diff --git a/composer.json b/composer.json index fe24acb9..14c4bd86 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ }, "require": { "php": "^8.0", - "illuminate/contracts": "^8.0 || ^9.0", - "illuminate/database": "^8.0 || ^9.0", - "illuminate/support": "^8.0 || ^9.0" + "illuminate/contracts": "^8.0 || ^9.0|^10.0", + "illuminate/database": "^8.0 || ^9.0|^10.0", + "illuminate/support": "^8.0 || ^9.0|^10.0" }, "require-dev": { "laravel/legacy-factories": "^1.0.4", "mockery/mockery": "^1.3.3", - "orchestra/testbench": "^6.0 || ^7.0", + "orchestra/testbench": "^6.0 || ^7.0|^8.0", "phpunit/phpunit": "^9.0" }, "minimum-stability": "dev", diff --git a/docs/package/fallback-locale.md b/docs/package/fallback-locale.md index b7bf4086..1cafb3ee 100644 --- a/docs/package/fallback-locale.md +++ b/docs/package/fallback-locale.md @@ -25,7 +25,7 @@ If you do not want to define the default fallback locale but just get the first 'de' => [ 'DE', 'AT', - 'CH', + 'CH', ], ] // ... @@ -93,15 +93,15 @@ protected function isEmptyTranslatableAttribute(string $key, $value): bool Since version v5.3 it is possible to use country based locales. For example, you can have the following locales: -* English: `en` -* Spanish: `es` -* Mexican Spanish: `es-MX` -* Colombian Spanish: `es-CO` +- English: `en` +- Spanish: `es` +- Mexican Spanish: `es-MX` +- Colombian Spanish: `es-CO` To configuration for these locales looks like this: ```php - 'locales' => [ + 'locales' => [ 'en', 'es' => [ 'MX', @@ -119,4 +119,3 @@ We can also configure the "glue" between the language and country. If for instan What applies for the fallback of the locales using the `en-MX` format? Let's say our fallback locale is `en`. Now, when we try to fetch from the database the translation for the locale `es-MX`but it doesn't exist, we won't get as fallback the translation for `en`. Translatable will use as a fallback `es` \(the first part of `es-MX`\) and only if nothing is found, the translation for `en` is returned. - diff --git a/docs/package/interface.md b/docs/package/interface.md index bbaf2e9d..668cc728 100644 --- a/docs/package/interface.md +++ b/docs/package/interface.md @@ -11,11 +11,8 @@ interface TranslatableProtected { // detect if a given translation attribute value is empty or not protected function isEmptyTranslatableAttribute(string $key, $value): bool; - + // save all attached translations protected function saveTranslations(): bool; } ``` - - - diff --git a/docs/package/locales-helper.md b/docs/package/locales-helper.md index cd4ce0b3..0a95624e 100644 --- a/docs/package/locales-helper.md +++ b/docs/package/locales-helper.md @@ -78,4 +78,3 @@ Checks if the given locale is a country specific locale. ### getLanguageFromCountryBasedLocale\(string $locale\) Returns the language locale from given country based locale. - diff --git a/docs/package/methods.md b/docs/package/methods.md index f7c9e804..a7c4543b 100644 --- a/docs/package/methods.md +++ b/docs/package/methods.md @@ -2,10 +2,10 @@ ## Preconditions -* the `locale` is set to `de` -* the `fallback_locale` is set to `en` -* our main model instance is `$post = Post::first()` -* translations are available for `en`, `de` and `fr` +- the `locale` is set to `de` +- the `fallback_locale` is set to `en` +- our main model instance is `$post = Post::first()` +- translations are available for `en`, `de` and `fr` ## Get an instance of the translation model @@ -124,4 +124,3 @@ disables autoload and returns parent attributes ### static defaultAutoloadTranslations\(\) does not change the default behavior logic - diff --git a/docs/package/scopes.md b/docs/package/scopes.md index b442849f..8177b127 100644 --- a/docs/package/scopes.md +++ b/docs/package/scopes.md @@ -86,4 +86,3 @@ Sorts the model by a given translation column value ```php Post::orderByTranslation('title')->get() ``` - diff --git a/docs/package/validation-rule-factory.md b/docs/package/validation-rule-factory.md index 2927cffb..6cc434dd 100644 --- a/docs/package/validation-rule-factory.md +++ b/docs/package/validation-rule-factory.md @@ -32,6 +32,7 @@ This will return an array which adjusted the placeholder in key and string value To adjust the default `format` , `prefix` or `suffix` used by the factory you can change them in the package configuration file. {% code title="config/translatable.php" %} + ```php 'rule_factory' => [ 'format' => \Astrotomic\Translatable\Validation\RuleFactory::FORMAT_ARRAY, @@ -39,15 +40,16 @@ To adjust the default `format` , `prefix` or `suffix` used by the factory you ca 'suffix' => '%', ] ``` + {% endcode %} As `format` we support the two possible variants the `fill()` method supports. -#### RuleFactory::FORMAT\_ARRAY +#### RuleFactory::FORMAT_ARRAY This will create the dot-notation to support locale sub-arrays. `en.content`. -#### RuleFactory::FORMAT\_KEY +#### RuleFactory::FORMAT_KEY This will create the colon separated style. `content:en` @@ -71,4 +73,3 @@ This will use the colon style, use `{` and `}` as delimiter and use only `de` an {% hint style="info" %} You can only use defined locales. Every locale that's not in `Locales::all()`will throw an `InvalidArgumentException`. {% endhint %} - diff --git a/docs/usage/attributes.md b/docs/usage/attributes.md index c88f7a30..04ab324c 100644 --- a/docs/usage/attributes.md +++ b/docs/usage/attributes.md @@ -12,4 +12,3 @@ echo $post->{'title:de'}; // Mein erster Beitrag $post->title = 'My first edited post'; echo $post->title; // My first edited post ``` - diff --git a/docs/usage/forms.md b/docs/usage/forms.md index d31f6dae..24a69b57 100644 --- a/docs/usage/forms.md +++ b/docs/usage/forms.md @@ -55,4 +55,3 @@ $post->title = 'My first post'; // Will update the English translatable model ```php $post->fill(['title' => 'My first post']); // Will update the English translatable model ``` - diff --git a/docs/usage/pivot-model.md b/docs/usage/pivot-model.md index b44c422f..7cba0e38 100644 --- a/docs/usage/pivot-model.md +++ b/docs/usage/pivot-model.md @@ -5,6 +5,7 @@ The package trait could also be used on [pivot models](https://laravel.com/docs/ Because the trait introduces a new relation your base model needs a primary key - we will use an auto-increment `id` column. If you want to use an UUID string column or another key you have to set/adjust more things \(tell the model and trait which is your primary key, adjust migration ...\) but even this is possible. {% code title="RoleUser.php" %} + ```php use Illuminate\Database\Eloquent\Relations\Pivot; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; @@ -17,21 +18,21 @@ class RoleUser extends Pivot implements TranslatableContract public $incrementing = true; } ``` + {% endcode %} {% code title="create\_role\_user\_table.php" %} + ```php Schema::create('role_user', function(Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->integer('role_id')->unsigned(); - + $table->unique(['user_id', 'role_id']); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); }); ``` -{% endcode %} - - +{% endcode %}