In this lesson, we will discuss UUID and ULID and how to use them in Laravel.
UUID stands for Universally Unique Identifier, and ULID stands for Universally Unique Lexicographically sortable Identifier. These are not Laravel or PHP terms, their application is broader. It's a long sequence of digits and letters to encode a more extended identifier instead of an ID field.
Now, why would you need that?
UUID
The most typical example is when you want to show a user's profile but hide the ID from the URL. For that, you may want to use a UUID.
How to use UUIDs within Laravel? First, we must create a UUID DB column.
database/migrations/xxx_add_uuid_to_users_table.php:
Schema::table('users', function (Blueprint $table) { $table->uuid();});
In my opinion, you should add your UUID in addition to the primary ID, not instead of ID. It would help if...