ylliX - Online Advertising Network
Vertex AI - Antrophic and Mistral models: Why does it require Imegen access?

laravel json api polimorphic relationship


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



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *