Skip to content
Open
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2408e64
graphql.md: add "MediaObject Normalization" chapter (#2109)
timble-one Sep 15, 2025
fd44e8f
Merge 4.1
soyuka Sep 16, 2025
7990e10
docs: fix small typo (#2205)
florentdrousset Sep 16, 2025
d423095
Update openapi.md (#2042)
rnbw-spctrm Sep 17, 2025
8410d87
Merge 4.1 (#2206)
vinceAmstoutz Sep 17, 2025
0f90473
4.2 branch
soyuka Sep 17, 2025
d840a9c
Update from 'attributes' to 'properties' (#2195)
kentrichards Sep 19, 2025
17d371c
docs(openapi): refacto override OpenAPI section (#2207)
maxhelias Sep 22, 2025
df2f502
docs(core/operations): update explanation about omitting GET item ope…
ttskch Oct 8, 2025
ed00f67
docs(core/extensions): add eloquent support (#2208)
ttskch Oct 8, 2025
263c804
Remove invalid tip about #[GetCollection] alias (#2215)
rvanlaak Oct 8, 2025
e39b731
docs: metadata mutators (#2228)
NathanPesneau Nov 25, 2025
6f09119
docs: add missing "docs_formats" configuration for Symfony (#2226)
creocoder Nov 25, 2025
e98c7fb
Fix invalid YAML in example in core/state-processors.md and state-pro…
xalopp Nov 25, 2025
e34dfd7
docs: update UUID recommendation to v7 for better database performanc…
OlivierBarbier Nov 25, 2025
97b274e
document property filter back (#2220)
soyuka Nov 25, 2025
a0e1317
Update releases information (#2232)
xammmue Dec 4, 2025
323e977
improve dto documentation (#2231)
soyuka Dec 4, 2025
6a249e8
Merge 4.1
soyuka Dec 4, 2025
ff2ccb4
update docs
soyuka Dec 4, 2025
ba8d387
fix #1749
soyuka Dec 5, 2025
9e67aec
document enums as resource
soyuka Dec 5, 2025
67485f7
fix #1856
soyuka Dec 5, 2025
d7c1d74
bootstrap
soyuka Dec 5, 2025
8aaa843
fix #2230
soyuka Dec 5, 2025
5dd857b
fix #2221
soyuka Dec 5, 2025
812d718
fix #2189
soyuka Dec 5, 2025
54ef2ac
doc(provider): show how to enable link security to be able to use Rea…
Cryde Dec 5, 2025
3011261
docs(filters): document enhanced QueryParameter syntax on old filters…
vinceAmstoutz Dec 5, 2025
2e12e24
default fixup
soyuka Dec 5, 2025
9bb4738
lint
soyuka Dec 5, 2025
c671247
restore max depth + prettier
soyuka Dec 5, 2025
a6375a4
max-length 100 prettier
soyuka Dec 5, 2025
d0a2717
max-length prettier
soyuka Dec 5, 2025
c619f82
max-length markdown
soyuka Dec 5, 2025
17aac72
lint
soyuka Dec 5, 2025
68dfcfe
Document Deprecation HTTP Header usage (#2233)
aaa2000 Dec 8, 2025
ffef094
doc(mutator): fix typo (#2234)
Jean-Beru Dec 19, 2025
4775684
fix(core/bootstrap): note formatting (#2235)
vinceAmstoutz Dec 19, 2025
e61eec1
fix api-platform/core/pull/5606
soyuka Jan 26, 2026
bb66780
fix: typo “through” (#2243)
alexisLefebvre Jan 27, 2026
f1c33c3
docs: mention symfony/object-mapper:^8.0 (#2238)
alexisLefebvre Jan 27, 2026
d724e5a
docs: clarify pagination_client_enabled configuration (#2237)
mdavid-dev Jan 27, 2026
fa2534e
docs: rewrite intro to DTO (#2244)
alexisLefebvre Jan 27, 2026
2d2a5dd
cs (#2246)
soyuka Jan 27, 2026
04bdd63
doc: refactor BlogPostProvider examples (#2239)
alexisLefebvre Jan 27, 2026
6efe91c
docs: fix links to Hoppscotch and remove duplicated line (#2245)
alexisLefebvre Jan 27, 2026
eb4a006
cs
soyuka Jan 27, 2026
0e3611e
feat: update php version on workflow
ginifizz Jan 29, 2026
badbbc1
docs: update vich example to use the Attribute namespace instead (#2250)
cngJo Feb 9, 2026
7cd27ed
feat: add global defaults.normalization_context.gen_id configuration …
Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(core/extensions): add eloquent support (#2208)
Co-authored-by: Vincent Amstoutz <vincent.amstoutz@outlook.com>
  • Loading branch information
ttskch and vinceAmstoutz authored Oct 8, 2025
commit ed00f676164c85236e95e9d878dd80b4b173e5aa
60 changes: 55 additions & 5 deletions core/extensions.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Extensions for Doctrine and Elasticsearch

> [!WARNING]
> This is not yet available with [Eloquent](https://laravel.com/docs/eloquent), you're welcome to contribute [on GitHub](https://github.com/api-platform/core)
# Extensions for Doctrine, Eloquent and Elasticsearch

API Platform provides a system to extend queries on items and collections.

Extensions are specific to Doctrine and Elasticsearch-PHP, and therefore, the Doctrine ORM / MongoDB ODM support or the Elasticsearch
Extensions are specific to Doctrine, Eloquent and Elasticsearch-PHP, and therefore, the Doctrine ORM / MongoDB ODM support, Eloquent support or the Elasticsearch
reading support must be enabled to use this feature. If you use custom providers it's up to you to implement your own
extension system or not.

Expand Down Expand Up @@ -160,6 +157,59 @@ The tags are `api_platform.doctrine_mongodb.odm.aggregation_extension.item` and
The custom extensions receive the [aggregation builder](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/current/reference/aggregation-builder.html),
used to execute [complex operations on data](https://docs.mongodb.com/manual/aggregation/).

## Custom Eloquent Extension

Custom extensions must implement `ApiPlatform\Laravel\Eloquent\Extension\QueryExtensionInterface` and be tagged with the interface name, so they will be executed both when querying for a collection of items and when querying for an item.

```php
<?php
// api/app/Eloquent/OfferExtension.php

namespace App\Eloquent;

use ApiPlatform\Laravel\Eloquent\Extension\QueryExtensionInterface;
use ApiPlatform\Metadata\Operation;
use App\Models\Offer;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;

final readonly class OfferExtension implements QueryExtensionInterface
{
public function apply(Builder $builder, array $uriVariables, Operation $operation, $context = []): Builder
{
if (!$builder->getModel() instanceof Offer) {
return $builder;
}

if (!$builder->getModel() instanceof Offer || !($user = Auth::user()) instanceof User || $user->is_admin) {
return $builder;
}

return $builder->where('user_id', $user->id);
}
}
```

```php
<?php
// api/app/Providers/AppServiceProvider.php

namespace App\Providers;

use ApiPlatform\Laravel\Eloquent\Extension\QueryExtensionInterface;
use App\Eloquent\OfferExtension;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->tag([OfferExtension::class], QueryExtensionInterface::class);
}
}
```

## Custom Elasticsearch Extension

Currently only extensions querying for a collection of items through a [search request](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html)
Expand Down
Loading