cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

Belongs to foreign key empty #435

Closed yoelpc4 closed 5 years ago

yoelpc4 commented 5 years ago

Hi @lindyhopchris , I've encountered a problem while creating a comments resource which has belongs to commentator (users resource) and belongs to post (posts resource) with this package information "cloudcreativity/laravel-json-api": "^1.4"

I received 500 "Internal Server Error" because user_id and post_id are not filled while creating comment record in database.

Before submitting this issue I've tried your debugging tips from similar issue #359 , but nothing seems wrong in my codes.

Here's some gists to helping you understanding my problem.

JSON API v1 Configuration https://gist.github.com/yoelpc4/68e861288ca8da1e9ad28f68b69ce1e7

API routes https://gist.github.com/yoelpc4/a6f9a727a6f2418c513002572d65212b

Comment Migration https://gist.github.com/yoelpc4/57bf6b77624305d889d74646df0a1cc4

Comment Model https://gist.github.com/yoelpc4/399d50fd711ac005b001d5ffc6729dd9

Users Adapter https://gist.github.com/yoelpc4/34e2d676286a81623c7ca40f6542fd82

Posts Adapter https://gist.github.com/yoelpc4/5bb744fc085d6deb7e7d42331489ab69

Comments Adapter https://gist.github.com/yoelpc4/759e113b278dc5b11ec569de8d59b1a5

Comments Validators https://gist.github.com/yoelpc4/ea1b225aab7a2a9c7d8b96d747bed943

Request URL https://zenith.test/api/v1/comments?include=commentator,post.author

Request Method POST

Request payload

{
 "data": {
    "attributes": {
       "body": "Lorem ipsum dolor sit amet"
    },
    "relationships": {
       "commentator": {
          "data": {
             "type": "users", 
             "id": "1"
          }
       }, 
       "post": {
          "data": {
             "type": "posts", 
             "id": "1"
          }
       }
    },
    "type": "comments"
  }
}

Debugging result from create method AbstractResourceAdapter.php ln. 89 $document parameter

array:1 [
  "data" => array:3 [
    "type" => "comments"
    "relationships" => array:2 [
      "commentator" => array:1 [
        "data" => array:2 [
          "type" => "users"
          "id" => "1"
        ]
      ]
      "post" => array:1 [
        "data" => array:2 [
          "type" => "posts"
          "id" => "1"
        ]
      ]
    ]
    "attributes" => array:1 [
      "body" => "Lorem ipsum dolor sit amet"
    ]
  ]
]

$parameters parameter

CloudCreativity\LaravelJsonApi\Encoder\Parameters\EncodingParameters {#389
  -includePaths: array:2 [
    0 => "commentator"
    1 => "post.author"
  ]
  -fieldSets: null
  -sortParameters: null
  -pagingParameters: null
  -filteringParameters: null
  -unrecognizedParams: null
}

Debugging result from fillAndPersist method AbstractResourceAdapter ln.306 $record parameter

App\Comment {#404
  #fillable: array:3 [
    0 => "user_id"
    1 => "post_id"
    2 => "body"
  ]
  #connection: null
  #table: "comments"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [
    0 => "*"
  ]
}

$resource parameter

CloudCreativity\LaravelJsonApi\Document\ResourceObject {#391
  -type: "comments"
  -id: null
  -attributes: array:1 [
    "body" => "Lorem ipsum dolor sit amet"
  ]
  -relationships: array:2 [
    "commentator" => array:1 [
      "data" => array:2 [
        "type" => "users"
        "id" => "1"
      ]
    ]
    "post" => array:1 [
      "data" => array:2 [
        "type" => "posts"
        "id" => "1"
      ]
    ]
  ]
  -meta: []
  -links: []
  -fieldValues: Illuminate\Support\Collection {#411
    #items: array:5 [
      "body" => "Lorem ipsum dolor sit amet"
      "commentator" => array:2 [
        "type" => "users"
        "id" => "1"
      ]
      "id" => null
      "post" => array:2 [
        "type" => "posts"
        "id" => "1"
      ]
      "type" => "comments"
    ]
  }
  -fieldNames: Illuminate\Support\Collection {#403
    #items: array:5 [
      "body" => "body"
      "commentator" => "commentator"
      "id" => "id"
      "post" => "post"
      "type" => "type"
    ]
  }
}

$record after beforePersist invocation

App\Comment {#404
  #fillable: array:3 [
    0 => "user_id"
    1 => "post_id"
    2 => "body"
  ]
  #connection: null
  #table: "comments"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: array:1 [
    "body" => "Lorem ipsum dolor sit amet"
  ]
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [
    0 => "*"
  ]
}

So I believe this is the end of debugging result, because whenever I dumping $async after persist invocation, there's no more output and this is the query exception.

Illuminate\Database\QueryException {#416
  #sql: "insert into "comments" ("body", "updated_at", "created_at") values (?, ?, ?)"
  #bindings: array:3 [
    0 => "Lorem ipsum dolor sit amet"
    1 => "2019-10-05 15:29:29"
    2 => "2019-10-05 15:29:29"
  ]
  #message: "SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: comments.user_id (SQL: insert into "comments" ("body", "updated_at", "created_at") values (Lorem ipsum dolor sit amet, 2019-10-05 15:29:29, 2019-10-05 15:29:29))"
  #code: "23000"
  #file: "./vendor/laravel/framework/src/Illuminate/Database/Connection.php"
  #line: 665
  -previous: Doctrine\DBAL\Driver\PDOException {#412
    -errorCode: 19
    -sqlState: "23000"
    #message: "SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: comments.user_id"
    #code: "23000"
    #file: "./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php"
    #line: 119
    -previous: PDOException {#406
      #message: "SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: comments.user_id"
      #code: "23000"
      #file: "./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php"
      #line: 117
      +errorInfo: array:3 [
        0 => "23000"
        1 => 19
        2 => "NOT NULL constraint failed: comments.user_id"
      ]
      trace: {
        ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:459 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:658 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:625 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:460 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:412 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2658 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1317 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:846 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:811 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:674 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Eloquent/AbstractAdapter.php:437 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:318 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:95 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Store/Store.php:87 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:437 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:130 { …}
        ./vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:578 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:131 { …}
        CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->create() {}
        ./vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:219 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:176 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:680 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/NegotiateContent.php:102 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/BootJsonApi.php:78 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:59 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./app/Http/Middleware/Authenticate.php:16 {
          › 
          ›     return $next($request);
          › }
          arguments: {
            Illuminate\Http\Request {#52 …}
     }
        }
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:682 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:657 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:623 { …}
        ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:612 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/fideloper/proxy/src/TrustProxies.php:57 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
        ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151 { …}
        ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116 { …}
        ./public/index.php:55 { …}
        /Users/yoelpc4/.composer/vendor/laravel/valet/server.php:158 { …}
      }
    }
    +errorInfo: array:3 [
      0 => "23000"
      1 => 19
      2 => "NOT NULL constraint failed: comments.user_id"
    ]
    trace: {
      ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:119 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:459 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:658 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:625 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:460 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:412 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2658 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1317 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:846 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:811 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:674 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Eloquent/AbstractAdapter.php:437 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:318 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:95 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Store/Store.php:87 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:437 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:130 { …}
      ./vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:578 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:131 { …}
      CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->create() {}
      ./vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:219 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:176 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:680 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/NegotiateContent.php:102 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/BootJsonApi.php:78 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:59 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./app/Http/Middleware/Authenticate.php:16 {
        › 
        ›     return $next($request);
        › }
        arguments: {
          Illuminate\Http\Request {#52 …}
        }
      }
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:682 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:657 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:623 { …}
      ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:612 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/fideloper/proxy/src/TrustProxies.php:57 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
      ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151 { …}
      ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116 { …}
      ./public/index.php:55 { …}
      /Users/yoelpc4/.composer/vendor/laravel/valet/server.php:158 { …}
    }
  }
  +errorInfo: array:3 [
    0 => "23000"
    1 => 19
    2 => "NOT NULL constraint failed: comments.user_id"
  ]
   trace: {
    ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:665 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:625 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:460 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Connection.php:412 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2658 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1317 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:846 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:811 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:674 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Eloquent/AbstractAdapter.php:437 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:318 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php:95 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Store/Store.php:87 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:437 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:130 { …}
    ./vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:578 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php:131 { …}
    CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->create() {}
    ./vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:219 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Route.php:176 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:680 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/NegotiateContent.php:102 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/BootJsonApi.php:78 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:59 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./app/Http/Middleware/Authenticate.php:16 {
 › 
      ›     return $next($request);
      › }
      arguments: {
        Illuminate\Http\Request {#52 …}
      }
    }
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:682 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:657 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:623 { …}
    ./vendor/laravel/framework/src/Illuminate/Routing/Router.php:612 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/fideloper/proxy/src/TrustProxies.php:57 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171 { …}
    ./vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116 { …}
    ./public/index.php:55 { …}
    /Users/yoelpc4/.composer/vendor/laravel/valet/server.php:158 { …}
  }
}
yoelpc4 commented 5 years ago

Currently my solution is adding relation name in adapter's fillable array, is this the right solution?

lindyhopchris commented 5 years ago

Hi!

So I haven't look through this issue in detail, but yes you would need to add it to the fillable array. That's because it is typical for Eloquent models to not have their relationships as fillable, so you would need to specify them as fillable on your JSON API adapter to get round that.

Is it working when you add it to your fillable array? If so, can probably close this issue!