Add relations and for LexicalEntry to JSON API
This commit is contained in:
parent
c6d43527e7
commit
e41971a69c
|
@ -51,6 +51,10 @@ class Schema extends SchemaProvider
|
||||||
'words' => [
|
'words' => [
|
||||||
self::SHOW_SELF => true,
|
self::SHOW_SELF => true,
|
||||||
self::SHOW_RELATED => true,
|
self::SHOW_RELATED => true,
|
||||||
|
self::SHOW_DATA => isset($includeRelationships['words']),
|
||||||
|
self::DATA => function () use ($resource) {
|
||||||
|
return $resource->words;
|
||||||
|
},
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,6 @@ class Adapter extends AbstractAdapter
|
||||||
*/
|
*/
|
||||||
protected function lexicalEntry()
|
protected function lexicalEntry()
|
||||||
{
|
{
|
||||||
return $this->hasOne();
|
return $this->belongsTo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ class Schema extends SchemaProvider
|
||||||
return (string) $resource->getRouteKey();
|
return (string) $resource->getRouteKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIncludePaths()
|
||||||
|
{
|
||||||
|
return ['lexical-entry'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \App\Word $resource
|
* @param \App\Word $resource
|
||||||
* the domain record being serialized.
|
* the domain record being serialized.
|
||||||
|
@ -53,6 +58,10 @@ class Schema extends SchemaProvider
|
||||||
'lexical-entry' => [
|
'lexical-entry' => [
|
||||||
self::SHOW_SELF => true,
|
self::SHOW_SELF => true,
|
||||||
self::SHOW_RELATED => true,
|
self::SHOW_RELATED => true,
|
||||||
|
self::SHOW_DATA => isset($includeRelationships['lexical-entry']),
|
||||||
|
self::DATA => function () use ($resource) {
|
||||||
|
return $resource->lexical_entry;
|
||||||
|
}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue