I'm trying to give my modal a custom id (no auto increment). So I've overwrite the boot
method of my modal. The creating event is used like this:
public static function boot()
{
static::creating(function ($modal) {
$modal->id = myID;
return true;
});
}
Now when I try to revert the id after saving an entry the id of the new entry is alwas null.
$modal = new Modal;
$modal->myValue = $myValue;
$modal->save();
dd($modal->id) // This will returns always null
The strange thing is that the record is successful written to the database with the right id.
What is wrong with my code?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire