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

Proposal: Use the `casts` array to figure out which columns are UUIDs #99

Closed JoeCianflone closed 3 years ago

JoeCianflone commented 3 years ago

Hi, I really like this package, thanks for making it! I was trying to solve an issue with a different package I was using and I ended up playing around with the idea of just dynamically figuring out which columns were using the UUID by just looping over the $this->casts array. I have this code in my own local models and it works fine. This code in particular isn't ready to be merged, but before I clean it up I wanted to see if you'd be interested in this approach or if there's something I'm not considering that would make this a bad approach!

michaeldyrynda commented 3 years ago

This change only really works if you're using the laravel-efficient-uuid package as well as this one.

If you're not using the efficient UUID casts, then it won't have the desired affect here (it's broken all the tests), and it doesn't make sense to cast the UUIDs themselves, seeing as they're just strings.