Skip to content

Commit 85b6bca

Browse files
authored
Merge pull request #40 from lwwcas/37-laravel-12-compatibility
Enhance Compatibility & Expand Features
2 parents fcd3230 + da89817 commit 85b6bca

File tree

10 files changed

+162
-17
lines changed

10 files changed

+162
-17
lines changed

.DS_Store

0 Bytes
Binary file not shown.

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
"Lucas Duarte"
3030
],
3131
"require": {
32-
"php": "^8.0|^8.1|^8.2",
33-
"laravel/framework": "^10.0|^11.0|dev-master",
32+
"php": "^8.2|^8.3",
33+
"laravel/framework": "^10.48|^11.31|^12.0",
3434
"astrotomic/laravel-translatable": "^11.8",
35-
"spatie/laravel-package-tools": "^1.16.0"
35+
"spatie/laravel-package-tools": "1.92.*"
3636
},
3737
"require-dev": {
3838
"doctrine/dbal": "^3.0",
39-
"laravel/legacy-factories": "^1.0.4",
40-
"mockery/mockery": "^1.4",
41-
"nunomaduro/termwind": "^2.1.0",
42-
"orchestra/testbench": "^9.4",
43-
"pestphp/pest": "^3.0",
44-
"pestphp/pest-plugin-laravel": "^3.0"
39+
"laravel/legacy-factories": "^1.4",
40+
"mockery/mockery": "^1.6",
41+
"nunomaduro/termwind": "^2.3.0",
42+
"orchestra/testbench": "^9.12",
43+
"pestphp/pest": "^3.7",
44+
"pestphp/pest-plugin-laravel": "^3.1"
4545
},
4646
"autoload": {
4747
"psr-4": {
@@ -78,9 +78,9 @@
7878
},
7979
"compatibility": {
8080
"laravel": {
81-
"current": "10.x, 11.x",
82-
"planned": ["12.x", "13.x"],
83-
"untested": ["12.x", "13.x"]
81+
"current": "10.x, 11.x, 12.x",
82+
"planned": ["13.x"],
83+
"untested": ["13.x"]
8484
}
8585
},
8686
"language-management": {

docs/introduction/version-constraints.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ The following table outlines the compatibility of the **Laravel Countries** pack
2424

2525
| Package Version | Laravel | Status |
2626
|-----------------|----------|--------------|
27-
| 4.11.x.x | 11 | ✅
2827
| 4.11.x.x | 10 | ✅
28+
| 4.11.x.x | 11 | ✅
29+
| 4.12.x.x | 10 | ✅
30+
| 4.12.x.x | 11 | ✅
31+
| 4.12.x.x | 12 | ✅
2932

3033
## Requirements
3134

3235
The **Laravel Countries** package has the following system and package requirements to ensure proper functionality. Below is a breakdown of the required versions for both runtime and development environments.
3336

3437
### Runtime Requirements (Production)
3538

36-
- **PHP**: The package supports PHP versions **^8.0**, **^8.1**, and **^8.2**, ensuring compatibility with modern PHP versions.
39+
- **PHP**: The package supports PHP versions **^8.2**, and **^8.3**, ensuring compatibility with modern PHP versions.
3740

38-
- **Laravel Framework**: Compatible with Laravel versions **^9.0**, **^10.0**, and **^11.0**. This ensures that the package can be used with the most up-to-date releases of the Laravel framework.
41+
- **Laravel Framework**: Compatible with Laravel versions **^10.x**, **^11.x**, and **^12.x**. This ensures that the package can be used with the most up-to-date releases of the Laravel framework.
3942

4043
- **Astrotomic Laravel Translatable**: Requires version **^11.8** of the **Astrotomic Laravel Translatable** package for multilingual support in the application.
4144

42-
- **Spatie Laravel Package Tools**: Requires version **^1.16.0** of **Spatie's Laravel Package Tools** to assist in the package setup and management.
45+
- **Spatie Laravel Package Tools**: Requires version **^1.92.x** of **Spatie's Laravel Package Tools** to assist in the package setup and management.
4346

4447
### Development Requirements
4548

src/Models/Country.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,39 @@ class Country extends CountryModel
137137
'is_visible' => true,
138138
];
139139

140+
/**
141+
* The attributes that should be cast.
142+
*
143+
* This section is particularly important due to limitations introduced in Laravel 10.
144+
* Laravel 10 requires specific handling of attributes to ensure proper type casting
145+
* and avoid issues such as "Array to string conversion."
146+
*
147+
* @var array
148+
*/
149+
protected $casts = [
150+
'languages' => 'array',
151+
'tld' => 'array',
152+
'alternative_tld' => 'array',
153+
'borders' => 'array',
154+
'timezones' => 'array',
155+
'currency' => 'array',
156+
157+
'flag_emoji' => 'array',
158+
'flag_colors' => 'array',
159+
'flag_colors_web' => 'array',
160+
'flag_colors_contrast' => 'array',
161+
'flag_colors_hex' => 'array',
162+
'flag_colors_rgb' => 'array',
163+
'flag_colors_cmyk' => 'array',
164+
'flag_colors_hsl' => 'array',
165+
'flag_colors_hsv' => 'array',
166+
'flag_colors_pantone' => 'array',
167+
168+
'independence_day' => 'date:Y-m-d',
169+
170+
'is_visible' => 'boolean',
171+
];
172+
140173
/**
141174
* Get the attributes that should be cast.
142175
*

src/Models/CountryCoordinates.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ class CountryCoordinates extends CountryModel
3939
'gps',
4040
];
4141

42+
/**
43+
* The attributes that should be cast.
44+
*
45+
* This section is particularly important due to limitations introduced in Laravel 10.
46+
* Laravel 10 requires specific handling of attributes to ensure proper type casting
47+
* and avoid issues such as "Array to string conversion."
48+
*
49+
* @var array
50+
*/
51+
protected $casts = [
52+
'gps' => 'array',
53+
];
54+
4255
/**
4356
* Get the attributes that should be cast.
4457
*

src/Models/CountryExtras.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ class CountryExtras extends CountryModel
3939
'international_organizations',
4040
];
4141

42+
/**
43+
* The attributes that should be cast.
44+
*
45+
* This section is particularly important due to limitations introduced in Laravel 10.
46+
* Laravel 10 requires specific handling of attributes to ensure proper type casting
47+
* and avoid issues such as "Array to string conversion."
48+
*
49+
* @var array
50+
*/
51+
protected $casts = [
52+
'popular_technologies' => 'array',
53+
'international_organizations' => 'array',
54+
'religions' => 'array',
55+
'internet' => 'array',
56+
];
57+
4258
/**
4359
* Get the attributes that should be cast.
4460
*

src/Models/CountryGeographical.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ class CountryGeographical extends CountryModel
3737
'geometry',
3838
];
3939

40+
/**
41+
* The attributes that should be cast.
42+
*
43+
* This section is particularly important due to limitations introduced in Laravel 10.
44+
* Laravel 10 requires specific handling of attributes to ensure proper type casting
45+
* and avoid issues such as "Array to string conversion."
46+
*
47+
* @var array
48+
*/
49+
protected $casts = [
50+
'properties' => 'array',
51+
'geometry' => 'array',
52+
];
53+
4054
/**
4155
* Get the attributes that should be cast.
4256
*

src/Models/CountryRegion.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ class CountryRegion extends CountryModel
7373
'is_visible' => true,
7474
];
7575

76+
/**
77+
* The attributes that should be cast.
78+
*
79+
* This section is particularly important due to limitations introduced in Laravel 10.
80+
* Laravel 10 requires specific handling of attributes to ensure proper type casting
81+
* and avoid issues such as "Array to string conversion."
82+
*
83+
* @var array
84+
*/
85+
protected $casts = [
86+
'is_visible' => 'boolean',
87+
];
88+
7689
/**
7790
* Get the attributes that should be cast.
7891
*

src/Providers/WCountriesServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class WCountriesServiceProvider extends PackageServiceProvider
1414
{
1515
public function configurePackage(Package $package): void
1616
{
17+
1718
$package
19+
->setBasePath(__DIR__)
1820
->name('lwwcas-countries')
1921
->hasConfigFile('w-countries')
2022
->hasMigrations([

src/Trait/WithBasePackageTools.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,49 @@ trait WithBasePackageTools
3232
*
3333
* @var string
3434
*/
35-
protected string $withEnd = 'You do not find the happy life. You make it.';
35+
protected string|null $withEnd = null;
36+
37+
38+
/**
39+
* Array of motivational phrases.
40+
*
41+
* @var string[]
42+
*/
43+
protected array $withRandomEnd = [
44+
'Believe in your power to make a difference.',
45+
'Every step forward is a step closer to your dreams.',
46+
'Challenges are opportunities in disguise.',
47+
'Your journey is yours to create.',
48+
'Great things take time, so keep going.',
49+
'The effort you put in today builds your tomorrow.',
50+
'Dreams become reality with action.',
51+
'You are stronger than you think.',
52+
'Every achievement starts with the decision to try.',
53+
'Your potential is limitless.',
54+
'Progress, not perfection, is the goal.',
55+
'Shine your light, even when it’s hard.',
56+
'Courage grows with every challenge you face.',
57+
'You hold the key to your success.',
58+
'Embrace the process, and the results will follow.',
59+
'Inspiration is found within.',
60+
'Celebrate the small victories—they lead to big ones.',
61+
'Keep pushing, even when it gets tough.',
62+
'Success is built one step at a time.',
63+
'Believe in the magic of your ideas.',
64+
'Hard work always pays off.',
65+
'Be the change you wish to see.',
66+
'Take pride in how far you’ve come.',
67+
'Setbacks are just setups for comebacks.',
68+
'You’re creating something amazing.',
69+
'Stay motivated and focused on your goals.',
70+
'Learn, grow, and keep moving forward.',
71+
'You’re capable of incredible things.',
72+
'Progress fuels passion—never give up.',
73+
'Trust the process and trust yourself.',
74+
'Keep dreaming big and working hard.',
75+
'Your creativity is a gift to the world.',
76+
'Keep building, and watch your dreams soar.'
77+
];
3678

3779
/**
3880
* Ask the user if they want to star the repository on GitHub.
@@ -112,6 +154,15 @@ public function startWarnings(): self
112154
*/
113155
public function withEnd(): self
114156
{
157+
if ($this->withEnd != null) {
158+
$this->info($this->withEnd);
159+
return $this;
160+
}
161+
162+
if (count($this->withRandomEnd) >= 1) {
163+
$this->withEnd = $this->withRandomEnd[array_rand($this->withRandomEnd)];
164+
}
165+
115166
$this->info($this->withEnd);
116167
return $this;
117168
}

0 commit comments

Comments
 (0)