UUIDs (Universally Unique Identifier) are 128 bits values, used to uniquely identify the table records. A typical example looks like: The point of this article is not to address the advantages or disadvantages of using UUIDs, but to see how to implement them in a Laravel app and update any foreign key based on a UUID column. For the purpose of this article, we are going to be using Laravel 7.x, but this can work on any other version of Laravel (Tested on 5.8 and 6.x).
Your imports and Use statements should look like: Next let’s transform our users migration to use UUID instead of auto-increments.
If you are using a UUID primary key as a foreign key in another table, you need to change the column type to uuid, where the foreign key is defined.