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
> In Symfony we use the term “entities”, while the following documentation is mostly for Laravel “models”.
242
+
231
243
Note that in this example, we declared an association using Doctrine only between Employee and Company using a ManyToOne. There is no inverse association hence the use of `toProperty` in the URI Variables definition.
232
244
233
245
The following declares a few subresources: - `/companies/{companyId}/employees/{id}` - get an employee belonging to a company - `/companies/{companyId}/employees` - get the company employee's
@@ -253,7 +265,8 @@ use Doctrine\ORM\Mapping as ORM;
253
265
uriVariables: [
254
266
'companyId' => new Link(fromClass: Company::class, toProperty: 'company'),
255
267
'id' => new Link(fromClass: Employee::class),
256
-
],
268
+
],In Laravel
269
+
257
270
operations: [ new Get() ]
258
271
)]
259
272
#[ApiResource(
@@ -310,7 +323,7 @@ class Company
310
323
}
311
324
```
312
325
313
-
We did not define any Doctrine annotation here and if we want things to work properly with GraphQL, we need to map the `employees` field as a Link to the class `Employee` using the property `company`.
326
+
We did not define any Doctrine or Eloquent annotation here and if we want things to work properly with GraphQL, we need to map the `employees` field as a Link to the class `Employee` using the property `company`.
314
327
315
328
As a general rule, if the property we want to create a link from is in the `fromClass`, use `fromProperty`, if not, use `toProperty`.
316
329
@@ -335,12 +348,16 @@ class Company {
335
348
336
349
## Security
337
350
351
+
> [!WARNING]
352
+
> This is not yet available with Laravel, you're welcome to contribute [on Github](github.com/api-platform/core)
353
+
338
354
In order to use Symfony's built-in security system on subresources the security option of the `Link` attribute can be used.
339
355
340
356
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.
341
357
342
358
Alternatively you can also use the `securityObjectName` to set a custom name.
343
359
360
+
344
361
```php
345
362
<?php
346
363
#[ApiResource(
@@ -360,6 +377,7 @@ class Company {
360
377
361
378
This is currently an experimental feature disabled by default. To enable it please set `enable_link_security` to true:
0 commit comments