Skip to content

Commit 3ebee3b

Browse files
committed
Merge branch 'release/3.3.0'
2 parents 6a0281d + 66c313a commit 3ebee3b

File tree

145 files changed

+492
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+492
-167
lines changed

.github/workflows/tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [8.1, 8.2]
17+
php: [8.1, 8.2, 8.3]
1818
laravel: [10]
1919

2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Setup PHP
2525
uses: shivammathur/setup-php@v2
@@ -34,7 +34,7 @@ jobs:
3434
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update
3535

3636
- name: Install dependencies
37-
uses: nick-fields/retry@v2
37+
uses: nick-fields/retry@v3
3838
with:
3939
timeout_minutes: 5
4040
max_attempts: 5

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. This projec
55

66
## Unreleased
77

8+
## [3.2.0] - 2024-02-14
9+
10+
### Added
11+
12+
- [#265](https://github.com/laravel-json-api/laravel/issues/265) Allow registration of middleware per action on both
13+
resource routes and relationship routes.
14+
815
## [3.2.0] - 2023-11-08
916

1017
### Added

src/Console/Concerns/ResolvesStub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/GeneratorCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeAuthorizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeFilter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeRequests.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeSchema.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/MakeSortField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Console/StubPublish.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Exceptions/HttpNotAcceptableException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Exceptions/HttpUnsupportedMediaTypeException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Facades/JsonApiRoute.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/AttachRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/Destroy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/DetachRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/FetchMany.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/FetchOne.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/FetchRelated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/FetchRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/Store.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/Update.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/Actions/UpdateRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Controllers/JsonApiController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Middleware/BootJsonApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/AnonymousCollectionQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/AnonymousQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/FormRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/RequestResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/ResourceQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Http/Requests/ResourceRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/LaravelJsonApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Routing/ActionProxy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Routing/ActionRegistrar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

src/Routing/PendingRelationshipRegistration.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
namespace LaravelJsonApi\Laravel\Routing;
2121

2222
use Illuminate\Routing\RouteCollection;
23+
use Illuminate\Support\Arr;
2324

2425
class PendingRelationshipRegistration
2526
{
@@ -155,12 +156,30 @@ public function name(string $method, string $name): self
155156
/**
156157
* Add middleware to the resource routes.
157158
*
158-
* @param string ...$middleware
159+
* @param mixed ...$middleware
159160
* @return $this
160161
*/
161-
public function middleware(string ...$middleware): self
162+
public function middleware(...$middleware): self
162163
{
163-
$this->options['middleware'] = $middleware;
164+
if (count($middleware) === 1) {
165+
$middleware = Arr::wrap($middleware[0]);
166+
}
167+
168+
if (array_is_list($middleware)) {
169+
$this->options['middleware'] = $middleware;
170+
return $this;
171+
}
172+
173+
$this->options['middleware'] = Arr::wrap($middleware['*'] ?? null);
174+
175+
foreach ($this->map as $alias => $action) {
176+
if (isset($middleware[$alias])) {
177+
$middleware[$action] = $middleware[$alias];
178+
unset($middleware[$alias]);
179+
}
180+
}
181+
182+
$this->options['action_middleware'] = $middleware;
164183

165184
return $this;
166185
}

0 commit comments

Comments
 (0)