Generating and Enforcing UUIDs in Laravel for Immutable Model IDs
Ensure models always have a UUID set.
Ever wonder how some classes do not require a full namespace to be called in a blade view? i.e.
{{ Auth::id() }}
Instead of:
{{ \Illuminate\Support\Facades\Auth::id() }}
Laravel has a configuration file config/app.php
that maps class namespaces to an alias i.e.
// ...
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
// ...
],
Ensure models always have a UUID set.
Discover efficient techniques for updating multiple rows with unique values in Laravel. Explore step-by-step instructions and practical examples to streamline your database operations.
How to setup a Laravel Markdown editor and convert the markdown to HTML easy.