jeudi 15 novembre 2018

Laravel Collection of Collections JsonResponse returns a 500 "Malformed UTF-8 characters, possibly incorrectly encoded"

I can't seem to turn this Collection of Collections into json. return response->json($data);, json_encode($data); and $data->toJson(); all hit a 500 "Malformed UTF-8 characters, possibly incorrectly encoded". The $data looks like this:

Collection {#785 ▼
  #items: array:6 [▼
    0 => Bid {#770 ▼
      #connection: "database"
      #table: "parcel_bids"
      +incrementing: false
      #events: array:1 [▶]
      #fillable: array:2 [▶]
      #primaryKey: "id"
      #keyType: "int"
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▼
        "id" => "1234"
        "address_id" => "2345"
        "person_id" => "3456"
        "state" => "estimation"
        "created_at" => "2018-04-09 08:07:59"
        "updated_at" => "2018-04-09 08:17:19"
        "deleted_at" => null
      ]
      #original: array:7 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #observables: []
      #relations: array:3 [▶]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
      #forceDeleting: false
    }
    1 => Bid {#771 ▶}
    2 => Bid {#772 ▶}
    3 => Bid {#773 ▶}
    4 => Bid {#774 ▶}
    5 => Bid {#775 ▶}
  ]
}

Some with an attribute that is also a collection, but even before adding that it hits that 500. Anyone run into this before. Laravel 5.4.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire