Search results for #practicalLaravelDocs
Accomplished one of my long-term missions. I tweeted the tips with hashtag #practicalLaravelDocs daily for ~4 months, now finished going through ALL docs. All ~100 tips here: x.com/hashtag/practi… Will move to different formats now. Like, retweeting my old best tweets :)
Laravel tip. Need to validate custom attribute names in error messages? Override the `attributes()` method in Form Requests to replace field names with user-friendly labels in validation messages. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
Laravel tip. Need to validate multiple validation rule sets where only one needs to pass? Use `Rule::anyOf()` to create flexible validation that accepts different valid formats for the same field. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
Laravel tip. Need to validate distinct values in array input but ignore case differences? Use the `distinct` rule with `ignore_case` parameter to prevent duplicate values regardless of capitalization. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
Laravel tip. Want to check if a field exists in another array field's values? Use `in_array` validation to ensure a value exists within another field's array data. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
It is fast to import data with lots of row using insert and not looping with create. Create runs single insert queries multiple times and insert runs a single query with all the rows. BUT insert does insert timestamps and doesn’t hash passwords automatically #practicalLaravelDocs
Laravel tip. Need to validate array keys exist in your input? Use `required_array_keys` to ensure specific keys are present in array data, perfect for API endpoints expecting exact structure. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
Laravel tip. Need to validate only when a field is present but allow it to be optional? Use the `sometimes` rule! It only validates when the field exists in the request data. Link to the docs: laravel.com/docs/12.x/vali… #practicalLaravelDocs
Recently I found a cool way to write routes Not to repeat the controller name every line in Laravel It is fast to write and simple to look First photo is old way Second a new way #Laravel #practicalLaravelDocs
Laravel tip. Need conditional task execution based on environment, time, or custom logic? Use `when()`, `between()`, `environments()`, and other constraint methods to run tasks only when conditions are met. Link to the docs: laravel.com/docs/12.x/sche… #practicalLaravelDocs
Laravel tip. Need tasks to run faster than every minute? Laravel scheduler supports sub-minute intervals down to every second! Link to the docs: laravel.com/docs/12.x/sche… #practicalLaravelDocs
Laravel tip. Combine route name prefixes with route groups for consistent naming! Use `Route::name()` to automatically prefix all route names in a group. Also, did you know about nested prefixes? Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Customize your application's route loading with `withRouting()` in `bootstrap/app.php`! Create custom route files, change API prefixes, or take complete control over route registration. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Want to include soft-deleted models in route model binding? Use `withTrashed()` to allow access to deleted records through routes. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Working with PHP Enums? Route parameters can automatically validate and inject Enum values! Laravel returns 404 for invalid enum values, keeping your controllers clean. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Need different behavior for different subdomains? Use subdomain routing to handle multi-tenant apps, API versions, or region-specific content. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Need to protect sensitive routes like making repositories public or deleting accounts? Add `password.confirm` middleware to ANY route. Users will need to re-enter their password before proceeding. Link to docs: laravel.com/docs/12.x/auth… #practicalLaravelDocs
Laravel tip. Handle 404s gracefully with fallback routes! Instead of showing generic error pages, create custom fallback routes that execute when no other route matches. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
Laravel tip. Need to validate route parameters format? Use `where()` constraints with regex patterns or helper methods to ensure clean URLs and prevent invalid data from reaching your controllers. Link to the docs: laravel.com/docs/12.x/rout… #practicalLaravelDocs
It's still mind-blowing to me. For months, I've been posting Laravel tips with #practicalLaravelDocs which are LITERALLY from the docs. Just re-shaped with better examples. And they are *by far* the most Liked tweets on my feed. People prefer my tweets over reading docs :)
It's still mind-blowing to me. For months, I've been posting Laravel tips with #practicalLaravelDocs which are LITERALLY from the docs. Just re-shaped with better examples. And they are *by far* the most Liked tweets on my feed. People prefer my tweets over reading docs :)