Oussama
oussamamater.bsky.social
Oussama
@oussamamater.bsky.social
I write code.
Laravel Tip 💡: Wrap a Pipeline in a DB Transaction Elegantly

If you are using Laravel pipelines and wrapping the whole thing in a DB transaction, since Laravel v12.22 you can simplify your code by just calling "withinTransaction()" on the pipeline 🚀

#laravel
October 22, 2025 at 6:46 PM
Laravel Tip 💡: Handle Pluralization Elegantly

Did you know that besides localization, Laravel also handles pluralization out of the box? When you have messages in different plural forms, you can define them all at once and use ranges to choose the right format 🚀

#laravel
September 15, 2025 at 7:31 PM
Laravel Tip 💡: Detect User Language

Laravel uses Symfony's HttpFoundation component, which comes with some nice goodies. If you are working with localization and need to detect the user's preferred language, you can just call "getPreferredLanguage" 🚀

#laravel
September 14, 2025 at 6:57 PM
Laravel Tip 💡: Better If Statements in Blade

If you are working with Blade, you will almost certainly use an if statement, and chances are, there is already a shortcut directive for what you need 🚀

#laravel
September 13, 2025 at 7:08 PM
Laravel Tip 💡: The New "whereAttachedTo" Method

We have all used "whereHas", and sometimes you need to constrain it to match specific models. Since Laravel v12.13, you can use "whereAttachedTo" for exactly that 🚀

#laravel
September 7, 2025 at 7:16 PM
Laravel Tip 💡: Boot Traits with Attributes

Bootable traits are great, but their naming convention can be painful. Since Laravel v12.22, you can fully customize method names using PHP attributes 🚀

#laravel
September 3, 2025 at 8:30 PM
Laravel Tip 💡: The "use" Blade Directive

We have all probably used an enum in Blade at some point. While you can drop in raw PHP, Laravel v10 and upward have the "use" directive for exactly this 🚀

#laravel
August 31, 2025 at 7:28 PM
Laravel Tip 💡: Generate Realistic Test Sentences

Since Laravel uses FakerPHP under the hood, you can use "realText" to generate more realistic sentences for your tests instead of predictable dummy

#laravel
August 28, 2025 at 8:02 PM
Laravel dropped a new package "Laravel Boost". It makes AI suck less by giving it a bunch of tools to better understand your app, and it's great. But I think we can give it an extra boost.

blog.oussama-mater.tech/laravel-boost/
#laravel #ai
Boosting Laravel Boost
In the era of AI, LLMs are undeniably part of our workflow. Let's make them suck less with Laravel Boost.
blog.oussama-mater.tech
August 23, 2025 at 7:48 PM
Laravel Tip 💡: Date Checks with Carbon

I know you've had to check if a date has expired or is in the future at least once. Since Laravel uses Carbon under the hood, you've got access to a ton of helpers to handle all that elegantly 🚀

#laravel
July 28, 2025 at 6:43 PM
Laravel Tip 💡: Select Sub-Arrays

There will be times when you need to extract a sub-array from the main one, whether it's from a JSON response, your models, or whatever. While you could use map for that, Laravel ships with a much more elegant helper, "select", just for this 🚀

#laravel
July 21, 2025 at 8:03 PM
Laravel Tip 💡: Clamp Numbers

Have you ever needed to keep a number within a specific range, like a rating or a computed value? While you can hack your way through with min and max, Laravel ships with an elegant helper "clamp" to do exactly that 🚀

#laravel
July 15, 2025 at 8:47 PM
Laravel Tip 💡: Global Middleware for Jobs

Did you know you can apply global job middleware? It can be really useful for custom logging and monitoring, like instantly notifying Slack or Discord about slower-than-usual jobs 🚀

#laravel
July 12, 2025 at 8:45 PM
Laravel Tip 💡: Encrypt Your Jobs

If you are working with sensitive jobs, you can instruct Laravel to encrypt the payload by using the "ShouldBeEncrypted" interface. How cool is this? 🚀

#laravel
July 9, 2025 at 9:36 PM
Laravel Tip 💡: The "forelse" Blade Directive

When looping over a collection, you have probably checked its count first to handle the empty state. But the "forelse" Blade directive has existed forever, and it does exactly that, elegantly 🚀

#laravel
July 6, 2025 at 7:27 PM
Laravel Tip 💡: Record API Responses as Fixtures

If you are testing your API integrations (which you should) you are probably using the "fake()" method. To quickly prepare a stub for testing, you can use the "sink()" method to save the response into a fixture 🚀

#laravel
June 29, 2025 at 8:47 PM
Laravel Tip 💡: Display Remaining Attempts for a Rate-Limited Job

If you have a rate-limited job that can be dispatched via a UI, you can greatly improve the UX by displaying how many attempts are remaining for the day 🚀

#laravel
June 26, 2025 at 8:08 PM
Laravel Tip💡: Fail Jobs on Specific Exceptions

Ever needed to fail a job for specific exceptions and had to use a try-catch with "fail()"? Since Laravel v12.19, you can do it more elegantly with the new "InvalidContentFormatException" middleware 🚀

#laravel
June 21, 2025 at 7:03 PM
Laravel Tip 💡: Real-Time Download Progress

If you ever need to download a file in your Laravel app, consider using Guzzle's progress option. It gives you real-time updates on the download, which you can broadcast to your UI, display in the console, or handle however you like 🚀

#laravel
June 10, 2025 at 7:57 PM
Laravel Tip 💡: Confirm to Proceed

Need to confirm before running a command? Laravel ships with the "ConfirmableTrait" for that exactly. Just call "confirmToProceed()" for confirmation, and skip the prompt anytime with the "--force" option 🚀

#laravel
June 3, 2025 at 7:52 PM
Laravel Tip 💡: Use Contextual Attributes

You've probably had to initialize attributes with config values before. Laravel v11 makes it easier with contextual attributes. You can inject values directly, use constructor property promotion, and skip the boilerplate. It's just

#laravel
June 1, 2025 at 7:37 PM
Laravel Tip 💡: HTTP Response Status Helpers

When making API requests, you often need to check the response status code. While you can do this manually, Laravel provides wrappers for almost all status codes, which you can use for elegant and readable checks 🚀

#laravel
May 26, 2025 at 8:22 PM
Making Laravel Horizon suck less with an MCP server — delete failed jobs, figure out what went wrong, see job stats, and more. Basically, all the things Horizon is missing 🤖
May 14, 2025 at 7:09 PM
PHP Tip 💡: Better Custom Exceptions

Do you use custom exceptions in your codebase and end up with multiple empty classes? You can group all related exceptions into a single class and use static methods to create english-like code that immediately tells you what went wrong 🚀

#php
May 13, 2025 at 7:32 PM
Laravel Tip 💡: Wrap Configs in Classes

Laravel configs often get reused across the codebase, which can become painful to manage. Instead, group related configs in a class for cleaner, easier maintenance 🚀

#laravel
May 10, 2025 at 8:25 PM