Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.2, 8.1, 8.0]
laravel: [12.*, 11.*, 10.*, 9.*, 8.*]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [13.*, 12.*, 11.*, 10.*, 9.*, 8.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 13.*
testbench: 11.*
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
Expand All @@ -25,6 +27,22 @@ jobs:
- laravel: 8.*
testbench: ^6.23
exclude:
- laravel: 12.*
php: 8.3
- laravel: 11.*
php: 8.3
- laravel: 10.*
php: 8.3
- laravel: 9.*
php: 8.3
- laravel: 8.*
php: 8.3
- laravel: 13.*
php: 8.2
- laravel: 13.*
php: 8.1
- laravel: 13.*
php: 8.0
- laravel: 12.*
php: 8.1
- laravel: 12.*
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"require": {
"akaunting/laravel-money": "^1.2|^2.1|^3.0|^4.0|^5.1|^6.0",
"ext-pdo_sqlite": "*",
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"php": "^8.0"
},
"require-dev": {
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^9.4|^10.0|^11.0",
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0|^11.0",
"phpunit/phpunit": "^9.4|^10.0|^11.0|^12.0",
"symplify/monorepo-builder": "^9.4.21"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions monorepo-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
],
],
'require-dev' => [
'orchestra/testbench' => '^6.23|^7.0|^8.0|^9.0|^10.0',
'phpunit/phpunit' => '^9.4|^10.0|^11.0',
'orchestra/testbench' => '^6.23|^7.0|^8.0|^9.0|^10.0|^11.0',
'phpunit/phpunit' => '^9.4|^10.0|^11.0|^12.0',
'symplify/monorepo-builder' => '^9.4.21',
],
'minimum-stability' => 'dev',
Expand Down
2 changes: 1 addition & 1 deletion packages/airlines-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/airlines": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/airlines/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/airports-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/airports": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/airports/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/continents-de/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/continents": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/continents-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/continents": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/continents-pl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/continents": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/continents/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries-de/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/countries": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/countries": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries-es/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/countries": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries-fr/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/countries": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries-pl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/countries": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/countries/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/currencies-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/currencies": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/currencies/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": {
"php": "^8.0",
"akaunting/laravel-money": "^1.2|^2.1|^3.0|^4.0|^5.1|^6.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gb-counties-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/gb-counties": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gb-counties/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/model/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"require": {
"php": "^8.0",
"ext-pdo_sqlite": "*",
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 14 additions & 3 deletions packages/model/src/Model.php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the problem that caused these changes and how they work to solve the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in Laravel 13: Creating a new model instance while that model is still booting is now disallowed and throws a LogicException.

So instead I resolve the table name through reflection if possible or just by using the Laravel model/table name convention.
In addition the data insert is done through a query builder connection instead of the Model insert.

I know it's ideal, but this way it works for all the Laravel versions supported. Otherwise we would have to release this only for L13+ and work on a more elegant solution.

Your call.

Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ public static function cache(array $locales = [])

public static function migrate(?string $locale = null): void
{
$tableName = (new static())->getTable();
$tableName = static::getTableName();

static::resolveConnection()->getSchemaBuilder()->create($tableName, function (Blueprint $table): void {
foreach (static::$schema as $name => $type) {
$table->{$type}($name)->nullable();
}
});

$data = collect(Repository::fetchData(static::class));
$data = collect(Repository::fetchData(static::class, $locale));

$schema = collect(str_getcsv($data->first()));

Expand All @@ -150,10 +150,21 @@ public static function migrate(?string $locale = null): void
continue;
}

static::insert($dataToInsert);
static::resolveConnection()->table($tableName)->insert($dataToInsert);
}
}

protected static function getTableName(): string
{
$defaultProperties = (new ReflectionClass(static::class))->getDefaultProperties();

if (isset($defaultProperties['table']) && is_string($defaultProperties['table']) && $defaultProperties['table'] !== '') {
return $defaultProperties['table'];
}

return Str::snake(Str::pluralStudly(class_basename(static::class)));
}

public static function resolveConnection($connection = null): SQLiteConnection
{
return static::$sqliteConnections[static::class];
Expand Down
2 changes: 1 addition & 1 deletion packages/regions-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/regions": "self.version",
"squirephp/repository": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/regions/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions packages/rule/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
],
"require": {
"php": "^8.0",
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/database": "^8.40|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion packages/timezones-en/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/repository": "self.version",
"squirephp/timezones": "self.version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/timezones/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
Expand Down
9 changes: 3 additions & 6 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

class ModelTest extends TestCase
{
/** @test */
public function can_query_models(): void
public function test_can_query_models(): void
{
Repository::registerSource(Models\Foo::class, App::getLocale(), __DIR__ . '/data/foo-en.csv');

Expand Down Expand Up @@ -46,8 +45,7 @@ protected function testModel(string $model): void
}
}

/** @test */
public function can_translate_models(): void
public function test_can_translate_models(): void
{
Repository::registerSource(Models\Foo::class, 'en', __DIR__ . '/data/foo-en.csv');
Repository::registerSource(Models\Foo::class, 'es', __DIR__ . '/data/foo-es.csv');
Expand All @@ -61,8 +59,7 @@ public function can_translate_models(): void
$this->assertEquals('es', Models\Foo::first()->lang);
}

/** @test */
public function can_format_usd(): void
public function test_can_format_usd(): void
{
$this->assertSame('$5.00', Currency::find('usd')->format(500));
$this->assertSame('$500.00', Currency::find('usd')->format(500, true));
Expand Down
3 changes: 1 addition & 2 deletions tests/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

class RuleTest extends TestCase
{
/** @test */
public function can_be_validated(): void
public function test_can_be_validated(): void
{
Repository::registerSource(Models\Foo::class, App::getLocale(), __DIR__ . '/data/foo-en.csv');

Expand Down
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@

class TestCase extends \Orchestra\Testbench\TestCase
{
/**
* Compatibility shim for Testbench/Laravel testing internals.
*
* Some matrix combinations (e.g., Laravel 11) access this static property.
* Declaring it here keeps older and newer versions compatible.
*
* @var mixed
*/
public static $latestResponse;

protected function getPackageProviders($app): array
{
return [
Expand Down
Loading
Loading