You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
or if you are using Laravel tag your provider with:
82
81
83
-
```php
84
-
<?php
82
+
With Laravel the services are automatically tagged.
85
83
86
-
namespace App\Providers;
84
+
### Declare a filter with Laravel
87
85
88
-
use ApiPlatform\State\Provider\ParameterProvider;
89
-
use ApiPlatform\Tests\Fixtures\TestBundle\Parameter\CustomGroupParameterProvider;
90
-
use Illuminate\Support\ServiceProvider;
86
+
Filters are classes implementing our `ApiPlatform\Laravel\Eloquent\Filter\FilterInterface`, use [our code](https://github.com/api-platform/core/tree/main/src/Laravel/Eloquent/Filter) as examples. Filters are automatically registered and tagged by our `ServiceProvider`.
A Parameter can also call a filter and works on filters that impact the data persistence layer (Doctrine ORM, ODM and Eloquent filters are supported). Let's assume, that we have an Order filter declared:
104
91
@@ -132,51 +119,6 @@ class Offer {
132
119
}
133
120
```
134
121
135
-
### Call a filter with Laravel
136
-
137
-
A Parameter can also call a filter and works on filters that impact the data persistence layer (Doctrine ORM, ODM and Eloquent filters are supported). Let's assume, that we have an Order filter declared:
138
-
139
-
```php
140
-
<?php
141
-
142
-
namespace App\Providers;
143
-
144
-
use ApiPlatform\Laravel\Eloquent\Filter\OrderFilter;
145
-
use ApiPlatform\Metadata\ApiFilter;
146
-
use Illuminate\Support\ServiceProvider;
147
-
148
-
class AppServiceProvider extends ServiceProvider
149
-
{
150
-
$public function register(): void
151
-
{
152
-
$this->app->singleton(OrderFilter::class, function ($app) {
153
-
return new OrderFilter(['id' => null, 'name' => null], 'order');
Copy file name to clipboardExpand all lines: core/identifiers.md
+6-25Lines changed: 6 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,9 @@ To help with your development experience, we introduced an identifier normalizat
5
5
6
6
## Custom Identifier Normalizer
7
7
8
+
> [!WARNING]
9
+
> This feature is not yet available with Laravel, if you need it please open a Feature Request issue!
10
+
8
11
> In the following chapter, we're assuming that `App\Uuid` is a project-owned class that manages a time-based UUID.
9
12
10
13
Let's say you have the following class, which is identified by a `UUID` type. In this example, `UUID` is not a simple string but an object with many attributes.
@@ -13,7 +16,7 @@ Let's say you have the following class, which is identified by a `UUID` type. In
13
16
14
17
```php
15
18
<?php
16
-
// api/src/ApiResource/Person.php with Symfony or app/ApiResource/Person.php with Laravel
19
+
// api/src/ApiResource/Person.php with Symfony
17
20
namespace App\ApiResource;
18
21
19
22
use ApiPlatform\Metadata\ApiProperty;
@@ -62,7 +65,7 @@ Let's create a `Provider` for the `Person` resource:
62
65
63
66
```php
64
67
<?php
65
-
// api/src/State/PersonProvider.php with Symfony or app/State/PersonProvider.php with Laravel
68
+
// api/src/State/PersonProvider.php with Symfony
66
69
67
70
namespace App\State;
68
71
@@ -91,7 +94,7 @@ This case is covered by an URI variable transformer:
91
94
92
95
```php
93
96
<?php
94
-
// api/src/Identifier/UuidUriVariableTransformer.php with Symfony or app/Identifier/UuidUriVariableTransformer.php with Laravel
97
+
// api/src/Identifier/UuidUriVariableTransformer.php with Symfony
95
98
namespace App\Identifier;
96
99
97
100
use ApiPlatform\Api\UriVariableTransformerInterface;
@@ -166,28 +169,6 @@ services:
166
169
167
170
Your `PersonProvider` will now work as expected!
168
171
169
-
### Tag the Service using Laravel
170
-
171
-
```php
172
-
<?php
173
-
174
-
namespace App\Providers;
175
-
176
-
use App\Identifier\UuidUriVariableTransformer;
177
-
use ApiPlatform\Metadata\UriVariableTransformerInterface;
0 commit comments