Following up on my last night's question, I had a good night of sleep and "discovered" that this happens due to automatic casting / type conversion or whatever.
To summerize:
uuid
as primary keytrigger
on insert from mySQL$model_object->fresh();
fresh()
Model
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Address extends Model {
protected $table = 'Addresses';
protected $fillable = ['uuid', 'zipCode', 'houseNumber'];
protected $primaryKey = 'uuid';
//public $incrementing = false;
}
Controller (where it screws up)
public function store(Request $request) {
$input = $request->all();
$address = Address::create($input);
var_dump($address); exit;
$address = $address->fresh();
var_dump($address); exit;
var_dump($address->uuid); exit;//result (wow): int(0)
}
In order for this to work I had to manually override the casting type of the primary key in my model.
protected $casts = [
'id' => 'string'
];