Tuesday, April 11, 2017

InvalidPayloadException in Laravel 5.4

I have Eloquent model with field location which is represented in mysql as POINT type.

When I try to use this model in events, if location is NULL then everything is fine, but if location is not NULL (e.g. 'POINT(1,2)'), then laravel throws exception

InvalidPayloadException in Queue.php line 89:
5

Actually 5 is JSON_ERROR_UTF8 source

To represent location in json I use this function

public function getLocationAttribute($value) {
    if($value === null) return null;
    return unpack('Lpadding/corder/Lgtype/dlatitude/dlongitude', $value);
}

But how can I force laravel to use something like this during serialization of my object to use it in event?



via Jackson J

Advertisement