Encrypting and Decrypting Strings in Laravel
The Crypt facade, AES-256-CBC under the hood, and why encrypted values are not the right tool for anything you need to search or index in the database.
GUIDES
The Crypt facade, AES-256-CBC under the hood, and why encrypted values are not the right tool for anything you need to search or index in the database.
View::share() makes a variable available to every view without passing it explicitly from each controller — the right tool for genuinely global data like site settings or unread notification counts.
Hash::check() never decrypts the stored hash to compare it — bcrypt is one-way by design, so verification works by re-hashing the input and comparing the two hashes instead.
Laravel already looks for resources/views/errors/404.blade.php automatically — no route or controller registration needed, just the right file in the right place.
requiredIf, requiredUnless, sometimes, and a full closure-based rule all handle a field that should only be validated under a specific condition.
A plain PHP class for app-specific logic that doesn't belong in a model or controller — with a class alias so it's callable without a full namespace, and when a facade is worth the extra step instead.
Blade automatically injects a $loop variable inside every @foreach with index, first/last flags, and iteration count built in — no manual counter variable needed.
The dot-notation syntax for validating each item in an array field, and the * wildcard for a variable-length list — like a form that lets someone add multiple items dynamically.
Building auth manually rather than scaffolding it gives full control over the form and flow — the AJAX version follows the same controller logic, returning JSON instead of a redirect.
response(), the Response facade, and the difference between returning a string, a view, JSON, or a full Response object from a controller.
The basic unique rule works fine for creating a new record — updating an existing one, or accounting for soft-deleted rows, both need the fluent Rule::unique() builder instead.
The mimes, max, and dimensions validation rules for file uploads, and why validating the file extension alone is not a real security check.