Skip to content

Commit bef6013

Browse files
committed
Merge branch 'main' into feature/missing-setting-default-value
2 parents c2a0820 + 5652f8e commit bef6013

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- name: Dependabot metadata
1515
id: metadata
16-
uses: dependabot/fetch-metadata@v2.2.0
16+
uses: dependabot/fetch-metadata@v2.3.0
1717
with:
1818
github-token: "${{ secrets.GITHUB_TOKEN }}"
1919

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ All notable changes to `laravel-settings` will be documented in this file
66

77
- Make `spatie/data-transfer-object` dependency optional. (#160)
88

9+
## 3.4.1 - 2025-01-31
10+
11+
### What's Changed
12+
13+
* chore(deps): bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/spatie/laravel-settings/pull/309
14+
* Change out of date stubs in README by @GrandadEvans in https://github.com/spatie/laravel-settings/pull/310
15+
* Support Illuminate\Support\Carbon as cast by @Propaganistas in https://github.com/spatie/laravel-settings/pull/311
16+
* chore: fix typo by @danjohnson95 in https://github.com/spatie/laravel-settings/pull/306
17+
18+
### New Contributors
19+
20+
* @GrandadEvans made their first contribution in https://github.com/spatie/laravel-settings/pull/310
21+
* @Propaganistas made their first contribution in https://github.com/spatie/laravel-settings/pull/311
22+
* @danjohnson95 made their first contribution in https://github.com/spatie/laravel-settings/pull/306
23+
24+
**Full Changelog**: https://github.com/spatie/laravel-settings/compare/3.4.0...3.4.1
25+
926
## 3.4.0 - 2024-09-20
1027

1128
### What's Changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1" />](https://supportukrainenow.org)
3-
41
# Store strongly typed application settings
52

63
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-settings.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-settings)
@@ -97,7 +94,7 @@ return [
9794

9895
/*
9996
* Each settings class used in your application must be registered, you can
100-
* add them (manually) here.
97+
* put them (manually) here.
10198
*/
10299
'settings' => [
103100

@@ -109,7 +106,7 @@ return [
109106
'setting_class_path' => app_path('Settings'),
110107

111108
/*
112-
* In these directories settings migrations will be stored and ran when migrating. A settings
109+
* In these directories settings migrations will be stored and ran when migrating. A settings
113110
* migration created via the make:settings-migration command will be stored in the first path or
114111
* a custom defined path when running the command.
115112
*/
@@ -118,7 +115,7 @@ return [
118115
],
119116

120117
/*
121-
* When no repository is set for a settings class, the following repository
118+
* When no repository was set for a settings class the following repository
122119
* will be used for loading and saving settings.
123120
*/
124121
'default_repository' => 'database',
@@ -157,11 +154,12 @@ return [
157154
'enabled' => env('SETTINGS_CACHE_ENABLED', false),
158155
'store' => null,
159156
'prefix' => null,
157+
'ttl' => null,
160158
],
161159

162160
/*
163161
* These global casts will be automatically used whenever a property within
164-
* your settings class isn't the default PHP type.
162+
* your settings class isn't a default PHP type.
165163
*/
166164
'global_casts' => [
167165
DateTimeInterface::class => Spatie\LaravelSettings\SettingsCasts\DateTimeInterfaceCast::class,
@@ -240,7 +238,7 @@ This command will create a new file in `database/settings` where you can add the
240238
```php
241239
use Spatie\LaravelSettings\Migrations\SettingsMigration;
242240

243-
class CreateGeneralSettings extends SettingsMigration
241+
return new class extends SettingsMigration
244242
{
245243
public function up(): void
246244
{

src/Exceptions/MissingSettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public static function create(string $settingsClass, array $missingProperties, s
1010
{
1111
$missing = implode(', ', $missingProperties);
1212

13-
return new self("Tried {$operation} settings '{$settingsClass}', and following properties were missing: {$missing}");
13+
return new self("Tried {$operation} settings '{$settingsClass}', and the following properties were missing: {$missing}");
1414
}
1515
}

src/SettingsCasts/DateTimeInterfaceCast.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use DateTimeImmutable;
99
use DateTimeInterface;
1010
use Exception;
11+
use Illuminate\Support\Carbon as IlluminateCarbon;
1112

1213
class DateTimeInterfaceCast implements SettingsCast
1314
{
@@ -32,6 +33,10 @@ public function get($payload): ?DateTimeInterface
3233
return new CarbonImmutable($payload);
3334
}
3435

36+
if ($this->type === IlluminateCarbon::class) {
37+
return new IlluminateCarbon($payload);
38+
}
39+
3540
if ($this->type === DateTimeImmutable::class) {
3641
return new DateTimeImmutable($payload);
3742
}

tests/SettingsTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use DateTimeZone;
1010
use ErrorException;
1111
use Illuminate\Database\Events\SchemaLoaded;
12+
use Illuminate\Support\Carbon as IlluminateCarbon;
1213
use Illuminate\Support\Collection;
1314
use Illuminate\Support\Facades\Cache;
1415
use Illuminate\Support\Facades\DB;
@@ -48,6 +49,7 @@
4849
it('will handle loading settings correctly', function () {
4950
$dateTime = new DateTimeImmutable('16-05-1994 12:00:00');
5051
$carbon = new Carbon('16-05-1994 12:00:00');
52+
$illuminateCarbon = new IlluminateCarbon('20-05-1994 12:00:00');
5153

5254
$this->migrator->inGroup('dummy', function (SettingsBlueprint $blueprint) use ($carbon, $dateTime): void {
5355
$blueprint->add('string', 'Ruben');
@@ -64,6 +66,7 @@
6466

6567
$blueprint->add('date_time', $dateTime->format(DATE_ATOM));
6668
$blueprint->add('carbon', $carbon->toAtomString());
69+
$blueprint->add('illuminate_carbon', $illuminateCarbon->toAtomString());
6770
$blueprint->add('nullable_date_time_zone', null);
6871
});
6972

@@ -82,7 +85,8 @@
8285
DummyData::from(['name' => 'Adriaan']),
8386
])
8487
->date_time->toEqual($dateTime)
85-
->carbon->toEqual($carbon);
88+
->carbon->toEqual($carbon)
89+
->illuminate_carbon->toEqual($illuminateCarbon);
8690
});
8791

8892
it('will fail loading when settings are missing', function () {
@@ -98,6 +102,7 @@
98102
it('can save settings', function () {
99103
$dateTime = new DateTimeImmutable('16-05-1994 12:00:00');
100104
$carbon = new Carbon('16-05-1994 12:00:00');
105+
$illuminateCarbon = new IlluminateCarbon('20-05-1994 12:00:00');
101106
$dateTimeZone = new DateTimeZone('europe/brussels');
102107

103108
$this->migrator->inGroup('dummy', function (SettingsBlueprint $blueprint) use ($dateTimeZone, $carbon, $dateTime): void {
@@ -118,6 +123,7 @@
118123
]);
119124
$blueprint->add('date_time', $dateTime->format(DATE_ATOM));
120125
$blueprint->add('carbon', $carbon->toAtomString());
126+
$blueprint->add('illuminate_carbon', $illuminateCarbon->toAtomString());
121127
$blueprint->add('nullable_date_time_zone', $dateTimeZone->getName());
122128
});
123129

@@ -159,6 +165,7 @@
159165
expect($settings)
160166
->date_time->toEqual($dateTime)
161167
->carbon->toEqual($carbon)
168+
->illuminate_carbon->toEqual($illuminateCarbon)
162169
->nullable_date_time_zone->toBeNull();
163170
});
164171

@@ -174,6 +181,7 @@
174181
'dto' => DummyData::from(['name' => 'Rias']),
175182
'date_time' => new DateTimeImmutable(),
176183
'carbon' => Carbon::now(),
184+
'illuminate_carbon' => IlluminateCarbon::now(),
177185
]);
178186

179187
$settings->save();

0 commit comments

Comments
 (0)