Just started using laravel-json-api this week. Currently I’m facing a problem trying to expose a MorthTo related route. Can anybody help me?
my api.php file contains this resource
$server->resource('documents', JsonApiController::class)
->relationships(function ($relations) {
$relations->hasOne('documentable');
});
my DocumentSchema contains this field:
MorphTo::make("documentable")->types("trees", "maintenance-requests")->withUriFieldName('documentavel'),
my Document model contains this relationship:
public function documentable(): MorphTo
{
return $this->morphTo();
}
when calling /api/v1/documents/{document_id}/documentavel I get this error
"detail": "No schema for JSON:API resource type documentables.",
if I call /api/v1/documentos/{document_id}?include=documentable it brings me the documentable tree model though
what am I doing wrong? I tried adding other fields representing this relationship, tried to examine the laravel-json-api internals but unfortunatly i’m stuck in this error for 3 days already