mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added FQCN for Image and File in use statements
Sorry, first pull request. I added the Image and File use statements as requested. And surrounded the has_many example with the class name so it makes more sense.
This commit is contained in:
parent
8b36a2ceae
commit
84ae5ba321
@ -42,10 +42,17 @@ and provides a short syntax for accessing the related object.
|
|||||||
To create a has_one/has_many relationship to core classes (File, Image, etc), reference the Classname::class, like below.
|
To create a has_one/has_many relationship to core classes (File, Image, etc), reference the Classname::class, like below.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Assets\Image;
|
||||||
|
use SilverStripe\Assets\File;
|
||||||
|
|
||||||
|
class Team extends DataObject
|
||||||
|
{
|
||||||
private static $has_many = [
|
private static $has_many = [
|
||||||
'Teamphoto' => Image::class,
|
'Teamphoto' => Image::class,
|
||||||
'Lineup' => File::class
|
'Lineup' => File::class
|
||||||
];
|
];
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
At the database level, the `has_one` creates a `TeamID` field on `Player`. A `has_many` field does not impose any database changes. It merely injects a new method into the class to access the related records (in this case, `Players()`)
|
At the database level, the `has_one` creates a `TeamID` field on `Player`. A `has_many` field does not impose any database changes. It merely injects a new method into the class to access the related records (in this case, `Players()`)
|
||||||
|
Loading…
Reference in New Issue
Block a user