michaeldyrynda / laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models
MIT License
442 stars 46 forks source link

Uuid can be re-set after creation. #86

Closed defenestrator closed 4 years ago

defenestrator commented 4 years ago

I am using both this and efficient-uuid packages, and did this test in tinker. This could cause some pretty nasty issues with distributing data across different persistence systems, for instance.

Screen Shot 2020-04-01 at 15 28 22

Would a PR with something like the below be adequate? I can throw some tests on it, as well.

// Just a little extra protection against `dah l33t h4x` and dumb accidents.
        static::saving(function ($model) {
            $model->id = $model->getOriginal('uuid');
        });

Thanks, and cheers!

michaeldyrynda commented 4 years ago

I don't want this package to be responsible for preventing you from overriding a UUID if it's set. That's something you can control within your own application.