Merge pull request #8294 from kinglozzer/manymanythrough-docs

Update many-many-through docs (closes #8290)
This commit is contained in:
Robbie Averill 2018-07-27 20:56:02 +12:00 committed by GitHub
commit 8d1af25e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,
]; ];
} }
``` ```