Skip to content

Commit aa37bfa

Browse files
authored
Merge pull request #16 from laravelcm/add-support-laravel-11
feat: Add support for Laravel 11
2 parents 0f7f240 + 91e889c commit aa37bfa

19 files changed

+143
-105
lines changed

.github/dependabot.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: 2
2+
23
updates:
3-
- package-ecosystem: composer
4-
directory: "/"
5-
schedule:
6-
interval: daily
7-
time: "03:00"
8-
open-pull-requests-limit: 10
9-
target-branch: develop
4+
- package-ecosystem: composer
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
time: "03:00"
9+
open-pull-requests-limit: 10
10+
target-branch: main

.github/workflows/phpstan.yml

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
name: PHPStan
22

3-
on:
4-
push:
5-
pull_request:
3+
on: [push, pull_request]
64

75
jobs:
86
phpstan:
97
runs-on: ubuntu-latest
108
strategy:
11-
fail-fast: false
9+
fail-fast: true
1210
matrix:
1311
php: [8.1, 8.2]
14-
laravel: [9.*, 10.*]
15-
dependency-version: [prefer-stable]
12+
laravel: [9.*, 10.*, 11.*]
13+
dependency-version: [prefer-lowest, prefer-stable]
14+
include:
15+
- laravel: 11.*
16+
testbench: 9.*
17+
- laravel: 10.*
18+
testbench: 8.*
19+
- laravel: 9.*
20+
testbench: 7.*
21+
exclude:
22+
- laravel: 11.*
23+
php: 8.1
1624
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
25+
1726
steps:
18-
- uses: actions/checkout@v3
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
1930
- name: Cache dependencies
2031
uses: actions/cache@v2
2132
with:
2233
path: ~/.composer/cache/files
2334
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
35+
2436
- name: Setup PHP
2537
uses: shivammathur/setup-php@v2
2638
with:
2739
php-version: ${{ matrix.php }}
2840
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
2941
coverage: none
42+
3043
- name: Install dependencies
3144
run: composer install --prefer-dist --no-interaction
45+
3246
- name: Run PHPStan
3347
run: composer stan

.github/workflows/tests.yml

+23-4
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,40 @@ on: [push, pull_request]
55
jobs:
66
tests:
77
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [8.1, 8.2, 8.3]
12+
laravel: [9.*, 10.*, 11.*]
13+
dependency-version: [prefer-lowest, prefer-stable]
14+
include:
15+
- laravel: 11.*
16+
testbench: 9.*
17+
- laravel: 10.*
18+
testbench: 8.*
19+
- laravel: 9.*
20+
testbench: 7.*
21+
exclude:
22+
- laravel: 11.*
23+
php: 8.1
24+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
825

926
steps:
1027
- name: Checkout code
11-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
1229

1330
- name: Setup PHP
1431
uses: shivammathur/setup-php@v2
1532
with:
16-
php-version: 8.2
33+
php-version: ${{ matrix.php }}
1734
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
1835
tools: composer:v2
1936
coverage: none
2037

2138
- name: Install Composer dependencies
22-
run: composer install --prefer-dist --no-interaction
39+
run: |
40+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
41+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
2342
2443
- name: Execute tests
25-
run: composer pest
44+
run: vendor/bin/pest
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v5
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ $plan = Plan::find(1);
118118
$plan->features;
119119
120120
// Get all plan subscriptions
121-
$plan->planSubscriptions;
121+
$plan->subscriptions;
122122
123123
// Check if the plan is free
124124
$plan->isFree();
@@ -130,7 +130,7 @@ $plan->hasTrial();
130130
$plan->hasGrace();
131131
```
132132
133-
Both `$plan->features` and `$plan->planSubscriptions` are collections, driven from relationships, and thus you can query these relations as any normal Eloquent relationship. E.g. `$plan->features()->where('name', 'listing_title_bold')->first()`.
133+
Both `$plan->features` and `$plan->subscriptions` are collections, driven from relationships, and thus you can query these relations as any normal Eloquent relationship. E.g. `$plan->features()->where('name', 'listing_title_bold')->first()`.
134134
135135
### Get Feature Value
136136
@@ -181,7 +181,7 @@ $subscription = Subscription::find(1);
181181
$subscription->changePlan($plan);
182182
```
183183
184-
If both plans (current and new plan) have the same billing frequency (e.g., `invoice_period` and `invoice_interval`) the subscription will retain the same billing dates. If the plans don't have the same billing frequency, the subscription will have the new plan billing frequency, starting on the day of the change and _the subscription usage data will be cleared_. Also if the new plan has a trial period and it's a new subscription, the trial period will be applied.
184+
If both plans (current and new plan) have the same billing frequency (e.g., `invoice_period` and `invoice_interval`) the subscription will retain the same billing dates. If the plans don't have the same billing frequency, the subscription will have the new plan billing frequency, starting on the day of the change and _the subscription usage data will be cleared_. Also, if the new plan has a trial period, and it's a new subscription, the trial period will be applied.
185185
186186
### Feature Options
187187

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
],
3333
"require": {
3434
"php": "^8.1",
35-
"illuminate/console": "^9.0|^10.0",
36-
"illuminate/container": "^9.0|^10.0",
37-
"illuminate/database": "^9.0|^10.0",
38-
"illuminate/support": "^9.0|^10.0",
35+
"illuminate/console": "^9.52|^10.0|^11.0",
36+
"illuminate/container": "^9.52|^10.0|^11.0",
37+
"illuminate/database": "^9.52|^10.0|^11.0",
38+
"illuminate/support": "^9.52|^10.0|^11.0",
3939
"spatie/eloquent-sortable": "^4.0.0",
4040
"spatie/laravel-package-tools": "^1.16",
4141
"spatie/laravel-sluggable": "^3.4.2",
4242
"spatie/laravel-translatable": "^6.5.0"
4343
},
4444
"require-dev": {
4545
"laravel/pint": "^1.13",
46-
"nunomaduro/larastan": "^2.0",
47-
"orchestra/testbench": "^7.0|^8.0",
46+
"larastan/larastan": "^2.0",
47+
"orchestra/testbench": "^7.0|^8.0|^9.0",
4848
"pestphp/pest": "^2.18"
4949
},
5050
"autoload": {

database/migrations/create_plan_features_table.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
declare(strict_types=1);
44

5-
use Illuminate\Database\Schema\Blueprint;
65
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
8-
use Laravelcm\Subscriptions\Models\Plan;
98

109
return new class () extends Migration {
1110
public function up(): void
1211
{
1312
Schema::create(config('laravel-subscriptions.tables.features'), function (Blueprint $table): void {
1413
$table->id();
1514

16-
$table->foreignIdFor(Plan::class);
15+
$table->foreignIdFor(config('laravel-subscriptions.models.plan'));
1716
$table->json('name');
1817
$table->string('slug')->unique();
1918
$table->json('description')->nullable();

database/migrations/create_plan_subscription_usage_table.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22

33
declare(strict_types=1);
44

5-
use Illuminate\Database\Schema\Blueprint;
65
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
8-
use Laravelcm\Subscriptions\Models\Feature;
9-
use Laravelcm\Subscriptions\Models\Subscription;
108

119
return new class () extends Migration {
1210
public function up(): void
1311
{
1412
Schema::create(config('laravel-subscriptions.tables.subscription_usage'), function (Blueprint $table): void {
1513
$table->id();
1614

17-
$table->foreignIdFor(Subscription::class);
18-
$table->foreignIdFor(Feature::class);
15+
$table->foreignIdFor(config('laravel-subscriptions.models.subscription'));
16+
$table->foreignIdFor(config('laravel-subscriptions.models.feature'));
1917
$table->unsignedSmallInteger('used');
2018
$table->string('timezone')->nullable();
2119

database/migrations/create_plan_subscriptions_table.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
declare(strict_types=1);
44

5-
use Illuminate\Database\Schema\Blueprint;
65
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
8-
use Laravelcm\Subscriptions\Models\Plan;
98

109
return new class () extends Migration {
1110
public function up(): void
@@ -14,7 +13,7 @@ public function up(): void
1413
$table->id();
1514

1615
$table->morphs('subscriber');
17-
$table->foreignIdFor(Plan::class);
16+
$table->foreignIdFor(config('laravel-subscriptions.models.plan'));
1817
$table->json('name');
1918
$table->string('slug')->unique();
2019
$table->json('description')->nullable();

database/migrations/create_plans_table.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use Illuminate\Database\Schema\Blueprint;
65
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
88
use Laravelcm\Subscriptions\Interval;
99

@@ -37,7 +37,6 @@ public function up(): void
3737
});
3838
}
3939

40-
4140
public function down(): void
4241
{
4342
Schema::dropIfExists(config('laravel-subscriptions.tables.plans'));

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- ./vendor/nunomaduro/larastan/extension.neon
2+
- ./vendor/larastan/larastan/extension.neon
33

44
parameters:
55

src/Models/Plan.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected static function boot(): void
138138
{
139139
parent::boot();
140140

141-
static::deleted(function (Plan $plan): void {
141+
static::deleted(function ($plan): void {
142142
$plan->features()->delete();
143143
$plan->subscriptions()->delete();
144144
});

0 commit comments

Comments
 (0)