Skip to content

Commit 990e2c1

Browse files
authored
Merge pull request #404 from Astrotomic/pr-395
Pr 395
2 parents 00433e7 + e2e364a commit 990e2c1

File tree

17 files changed

+232
-177
lines changed

17 files changed

+232
-177
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
/.gitattributes export-ignore
66
/.gitignore export-ignore
77
/.gitbook.yaml export-ignore
8-
/.php_cs export-ignore
98
/.styleci.yml export-ignore
109
/.phpunit.xml.dist export-ignore
10+
/pint.json export-ignore

.github/workflows/phpunit.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,32 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: ['8.1', '8.2', '8.3']
17-
laravel: ['10.*', '11.*']
16+
php: [8.0, 8.1, 8.2, 8.3]
17+
laravel: [8.*, 9.*, 10.*, 11.*]
1818
dependency-version: [prefer-stable]
1919
os: [ubuntu-latest]
20+
include:
21+
- laravel: '8.*'
22+
phpunit: '9.*'
23+
- laravel: '9.*'
24+
phpunit: '9.*'
25+
- laravel: '10.*'
26+
phpunit: '10.*'
27+
- laravel: '11.*'
28+
phpunit: '10.*'
2029
exclude:
21-
- laravel: 11.*
22-
php: 8.1
30+
- php: '8.0'
31+
laravel: '10.*'
32+
- php: '8.0'
33+
laravel: '11.*'
34+
- php: '8.2'
35+
laravel: '8.*'
36+
- php: '8.3'
37+
laravel: '8.*'
38+
- php: '8.3'
39+
laravel: '9.*'
40+
- php: '8.1'
41+
laravel: '11.*'
2342

2443
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
2544

@@ -38,6 +57,7 @@ jobs:
3857
- name: Install dependencies
3958
run: |
4059
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
60+
composer require "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update
4161
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
4262
4363
- name: Execute tests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/vendor/
22
/composer.lock
33
/coverage/
4-
/.phpunit.result.cache
4+
/.phpunit.cache
55
/build/
66
/coverage.clover

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ If you discover any security related issues, please check [SECURITY](https://git
9898

9999
| Package | Laravel | PHP |
100100
| :------------------ | :---------------------------- | :-------- |
101-
| **v11.13 - v11.13** | `10.* / 11.*` | `^8.1` |
101+
| **v11.13 - v11.13** | `8.* / 9.* / 10.*` / `11.*` | `^8.0` |
102102
| **v11.12 - v11.12** | `8.* / 9.* / 10.*` | `^8.0` |
103103
| **v11.10 - v11.11** | `8.* / 9.*` | `^8.0` |
104104
| **v11.6 - v11.9** | `5.8.* / 6.* / 7.* / 8.*` | `>=7.2` |

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
"docs": "https://docs.astrotomic.info/laravel-translatable"
3131
},
3232
"require": {
33-
"php": "^8.1",
34-
"illuminate/contracts": "^10.0 || ^11.0",
35-
"illuminate/database": "^10.0 || ^11.0",
36-
"illuminate/support": "^10.0 || ^11.0"
33+
"php": "^8.0",
34+
"illuminate/contracts": "^8.0 || ^9.0 || ^10.0 || ^11.0",
35+
"illuminate/database": "^8.0 || ^9.0 || ^10.0 || ^11.0",
36+
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0"
3737
},
3838
"require-dev": {
3939
"laravel/legacy-factories": "^1.0.4",
40-
"laravel/pint": "^1.15",
40+
"laravel/pint": "^1.0",
4141
"mockery/mockery": "^1.3.3",
42-
"orchestra/testbench": "^8.0 || ^9.0",
43-
"phpunit/phpunit": "^10.5"
42+
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0",
43+
"phpunit/phpunit": "^10.0"
4444
},
4545
"minimum-stability": "dev",
4646
"prefer-stable": true,

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Latest Version](http://img.shields.io/packagist/v/astrotomic/laravel-translatable.svg?label=Release&style=for-the-badge)](https://packagist.org/packages/astrotomic/laravel-translatable) [![MIT License](https://img.shields.io/github/license/Astrotomic/laravel-translatable.svg?label=License&color=blue&style=for-the-badge)](https://github.com/Astrotomic/laravel-translatable/blob/master/LICENSE) [![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge)](https://plant.treeware.earth/Astrotomic/laravel-translatable)
44

5-
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/laravel-translatable/run-tests?style=flat-square&logoColor=white&logo=github&label=Tests)](https://github.com/Astrotomic/laravel-translatable/actions?query=workflow%3Arun-tests) [![StyleCI](https://styleci.io/repos/192333549/shield)](https://styleci.io/repos/192333549) [![Codecov Coverage](https://img.shields.io/codecov/c/github/Astrotomic/laravel-translatable?logo=codecov&logoColor=white&label=Codecov&style=flat-square)](https://codecov.io/gh/Astrotomic/laravel-translatable) [![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/laravel-translatable.svg?label=Downloads&style=flat-square)](https://packagist.org/packages/astrotomic/laravel-translatable)
5+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/laravel-translatable/phpunit?style=flat-square&logoColor=white&logo=github&label=PHPunit)](https://github.com/Astrotomic/laravel-translatable/actions?query=workflow%3Aphpunit) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/laravel-translatable/pint?style=flat-square&logoColor=white&logo=github&label=Pint)](https://github.com/Astrotomic/laravel-translatable/actions?query=workflow%3Apint) [![Codecov Coverage](https://img.shields.io/codecov/c/github/Astrotomic/laravel-translatable?logo=codecov&logoColor=white&label=Codecov&style=flat-square)](https://codecov.io/gh/Astrotomic/laravel-translatable) [![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/laravel-translatable.svg?label=Downloads&style=flat-square)](https://packagist.org/packages/astrotomic/laravel-translatable)
66

77
![Laravel Translatable](.gitbook/assets/socialcard.png)
88

@@ -75,6 +75,7 @@ echo $post->translate('fr')->title; // Mon premier post
7575

7676
| Package | Laravel | PHP |
7777
| :------------------ | :---------------------------- | :-------- |
78+
| **v11.13 - v11.13** | `8.* / 9.* / 10.*` / `11.*` | `^8.0` |
7879
| **v11.12 - v11.12** | `8.* / 9.* / 10.*` | `^8.0` |
7980
| **v11.10 - v11.11** | `8.* / 9.*` | `^8.0` |
8081
| **v11.6 - v11.9** | `5.8.* / 6.* / 7.* / 8.*` | `>=7.2` |

pint.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"rules": {
3+
"ordered_class_elements": {
4+
"order": [
5+
"use_trait",
6+
"constant_public",
7+
"constant_protected",
8+
"constant_private",
9+
"property_public",
10+
"property_protected",
11+
"property_private",
12+
"construct",
13+
"method_public_static",
14+
"method_public",
15+
"method_protected_static",
16+
"method_protected",
17+
"method_private_static",
18+
"method_private",
19+
"destruct",
20+
"magic"
21+
]
22+
},
23+
"yoda_style": {
24+
"equal": false,
25+
"identical": false,
26+
"less_and_greater": null
27+
}
28+
}
29+
}

src/Translatable/Traits/Relationship.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ public function translation(): HasOne
7373
});
7474
}
7575

76+
public function translations(): HasMany
77+
{
78+
return $this->hasMany($this->getTranslationModelName(), $this->getTranslationRelationKey());
79+
}
80+
7681
protected function localeOrFallback()
7782
{
7883
return $this->useFallback() && ! $this->translations()->where($this->getLocaleKey(), $this->locale())->exists()
7984
? $this->getFallbackLocale()
8085
: $this->locale();
8186
}
82-
83-
public function translations(): HasMany
84-
{
85-
return $this->hasMany($this->getTranslationModelName(), $this->getTranslationRelationKey());
86-
}
8787
}

tests/Eloquent/Person.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
class Person extends Eloquent implements TranslatableContract
1010
{
11-
protected $table = 'people';
12-
1311
use Translatable;
1412

1513
/**
@@ -42,6 +40,8 @@ class Person extends Eloquent implements TranslatableContract
4240
*/
4341
public $localeKey;
4442

43+
protected $table = 'people';
44+
4545
/**
4646
* Mutate name attribute into upper-case.
4747
*

tests/Eloquent/Vegetable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class Vegetable extends Eloquent implements TranslatableContract
1010
{
1111
use Translatable;
1212

13-
protected $primaryKey = 'identity';
14-
1513
public $translationForeignKey = 'vegetable_identity';
1614

1715
public $translatedAttributes = ['name'];
1816

19-
protected $fillable = ['quantity'];
20-
2117
public $localeKey;
2218

2319
public $translationModel;
20+
21+
protected $primaryKey = 'identity';
22+
23+
protected $fillable = ['quantity'];
2424
}

0 commit comments

Comments
 (0)