I hate answering my question, so maybe you can help me find what is fixed.
I have some eloquent models that belong together, and I installed them through an association like this. Everything is fine.
This process, unfortunately, makes $ device unstable. Below you can see that individual values are available, but any form of jsonification destroys the server without errors.
$device = $truck->device;
if(is_null($device) || empty($device)) {
$device = new Devices;
}
$device->truck()->associate($truck);
$device->fleet()->associate($fleet);
$device->serial = $device_input['serial'];
$device->save();
$truck->device()->associate($device);
$truck->save();
error_log( $device->id );
error_log( $truck->device->id );
error_log( $device->toJson() );
error_log( $truck->toArray() );
error_log( $truck->device->toJson() );
error_log( $truck->device->toArray() );
error_log( json_encode($device) );
error_log( json_encode($truck->device) );
source
share