Update many-many-through docs (closes #8290)

This commit is contained in:
Loz Calver 2018-07-27 09:30:13 +01:00
parent 36834075df
commit ef335a8a30

View File

@ -324,7 +324,7 @@ class Team extends DataObject
{ {
private static $many_many = [ private static $many_many = [
"Supporters" => [ "Supporters" => [
'through' => 'TeamSupporter', 'through' => TeamSupporter::class,
'from' => 'Team', 'from' => 'Team',
'to' => 'Supporter', 'to' => 'Supporter',
] ]
@ -332,8 +332,10 @@ class Team extends DataObject
} }
class Supporter extends DataObject class Supporter extends DataObject
{ {
// Prior to 4.2.0, this also needs to include the reverse relation name via dot-notation
// i.e. 'Supports' => Team::class . '.Supporters'
private static $belongs_many_many = [ private static $belongs_many_many = [
"Supports" => "Team", 'Supports' => Team::class,
]; ];
} }
class TeamSupporter extends DataObject class TeamSupporter extends DataObject
@ -343,8 +345,8 @@ class TeamSupporter extends DataObject
]; ];
private static $has_one = [ private static $has_one = [
'Team' => 'Team', 'Team' => Team::class,
'Supporter' => 'Supporter', 'Supporter' => Supporter::class,
]; ];
} }
``` ```