Skip to content

Commit 3eb417d

Browse files
committed
feat: Add support for Laravel 11
1 parent 0f7f240 commit 3eb417d

18 files changed

+122
-107
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 7 deletions
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

Lines changed: 21 additions & 7 deletions
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

Lines changed: 23 additions & 4 deletions
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]
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
Lines changed: 28 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 6 deletions
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.0|^10.0|^11.0",
36+
"illuminate/container": "^9.0|^10.0|^11.0",
37+
"illuminate/database": "^9.0|^10.0|^11.0",
38+
"illuminate/support": "^9.0|^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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +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\Plan;
98

10-
return new class () extends Migration {
9+
return new class() extends Migration
10+
{
1111
public function up(): void
1212
{
1313
Schema::create(config('laravel-subscriptions.tables.features'), function (Blueprint $table): void {
1414
$table->id();
1515

16-
$table->foreignIdFor(Plan::class);
16+
$table->foreignIdFor(config('laravel-subscriptions.models.plan'));
1717
$table->json('name');
1818
$table->string('slug')->unique();
1919
$table->json('description')->nullable();

database/migrations/create_plan_subscription_usage_table.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
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

11-
return new class () extends Migration {
9+
return new class() extends Migration
10+
{
1211
public function up(): void
1312
{
1413
Schema::create(config('laravel-subscriptions.tables.subscription_usage'), function (Blueprint $table): void {
1514
$table->id();
1615

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

database/migrations/create_plan_subscriptions_table.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
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

10-
return new class () extends Migration {
9+
return new class() extends Migration
10+
{
1111
public function up(): void
1212
{
1313
Schema::create(config('laravel-subscriptions.tables.subscriptions'), function (Blueprint $table): void {
1414
$table->id();
1515

1616
$table->morphs('subscriber');
17-
$table->foreignIdFor(Plan::class);
17+
$table->foreignIdFor(config('laravel-subscriptions.models.plan'));
1818
$table->json('name');
1919
$table->string('slug')->unique();
2020
$table->json('description')->nullable();

database/migrations/create_plans_table.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
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

10-
return new class () extends Migration {
10+
return new class() extends Migration
11+
{
1112
public function up(): void
1213
{
1314
Schema::create(config('laravel-subscriptions.tables.plans'), function (Blueprint $table): void {
@@ -37,7 +38,6 @@ public function up(): void
3738
});
3839
}
3940

40-
4141
public function down(): void
4242
{
4343
Schema::dropIfExists(config('laravel-subscriptions.tables.plans'));

0 commit comments

Comments
 (0)