Skip to content

Commit 8dd72e7

Browse files
committed
docs: add warnings about Laravel non-availability
1 parent 8cc2864 commit 8dd72e7

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

core/subresources.md

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ If you're using the Doctrine or the Eloquent implementation, queries are automat
1818

1919
### Answer to a Question
2020

21+
> [!WARNING]
22+
> This is not yet available with Laravel, you're welcome to contribute [on Github](github.com/api-platform/core)
23+
24+
---
25+
2126
> [!NOTE]
2227
> In Symfony we use the term “entities”, while the following documentation is mostly for Laravel “models”.
2328
@@ -237,6 +242,11 @@ resources:
237242

238243
### Company Employee's
239244

245+
> [!WARNING]
246+
> This is not yet available with Laravel, you're welcome to contribute [on Github](github.com/api-platform/core)
247+
248+
---
249+
240250
> [!NOTE]
241251
> In Symfony we use the term “entities”, while the following documentation is mostly for Laravel “models”.
242252
@@ -265,8 +275,7 @@ use Doctrine\ORM\Mapping as ORM;
265275
uriVariables: [
266276
'companyId' => new Link(fromClass: Company::class, toProperty: 'company'),
267277
'id' => new Link(fromClass: Employee::class),
268-
],In Laravel
269-
278+
],
270279
operations: [ new Get() ]
271280
)]
272281
#[ApiResource(
@@ -348,9 +357,10 @@ class Company {
348357

349358
## Security
350359

351-
In order to use Symfony's or the Laravel built-in security system on subresources the security option of the `Link` attribute can be used.
360+
> [!WARNING]
361+
> This is not yet available with Laravel, you're welcome to contribute [on Github](github.com/api-platform/core)
352362
353-
### Symfony example for security
363+
In order to use Symfony's built-in security system on subresources the security option of the `Link` attribute can be used.
354364

355365
To restrict the access to a subresource based on the parent object simply use the Symfony expression language as you would do normally, with the exception that the name defined in `toProperty` or `fromProperty` is used to access the object.
356366

@@ -374,44 +384,11 @@ class Company {
374384
}
375385
```
376386

377-
### Laravel example for security
378-
379-
With Laravel, we can use the following code:
380-
381-
```php
382-
<?php
383-
#[ApiResource(
384-
uriTemplate: '/employees/{employeeId}/company',
385-
uriVariables: [
386-
'employeeId' => new Link(fromClass: Employee::class, toProperty: 'company', security: Gate::allows('some_voter', $company)),
387-
],
388-
operations: [
389-
new Get()
390-
]
391-
)]
392-
393-
class Company {
394-
// ...
395-
}
396-
```
397-
398387
This is currently an experimental feature disabled by default. To enable it please set `enable_link_security` to true:
399388

400-
### Symfony configuration to disable link security
401389

402390
```yaml
403391
# api/config/packages/api_platform.yaml
404392
api_platform:
405393
enable_link_security: true
406394
```
407-
408-
### Laravel configuration to disable link security
409-
410-
```php
411-
<?php
412-
// config/api-platform.php
413-
return [
414-
// ....
415-
'enable_link_security' => true,
416-
];
417-
```

0 commit comments

Comments
 (0)