I've been fighting an issue for the past week that I can't find a resolution to.
I have a queued job that has an object (not a model) as constructor argument. The object has property that is a model with a coordinates attribute. The coordinates are a custom Point cast using the MatanYadaev/laravel-eloquent-spatial package.
something like:
class Report
{
$account = null;
public function __construct(Model $account) {
$this->account = $account
}
}
$account = Account::first();
MakeReport::dispatch(new Report($account));
The coordinates attribute is properly casted on the Account model
use \MatanYadaev\EloquentSpatial\Objects\Point
Account extends Model {
protected $casts = [
'coordinates' => Point::class
];
}
The problem is that the coordinates are not being serialized by laravel and I get the error:
Illuminate\Queue\InvalidPayloadException Unable to JSON encode payload. Error code: 5
Any ideas? I'm starting to lose my mind on this.
PHP 8.1.10
Laravel 9.28.0