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
22.10.2025 18:46 β π 5 π 1 π¬ 0 π 0
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
15.09.2025 19:31 β π 1 π 0 π¬ 0 π 0
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
14.09.2025 18:56 β π 3 π 0 π¬ 0 π 0
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
13.09.2025 19:07 β π 3 π 0 π¬ 0 π 0
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
07.09.2025 19:16 β π 2 π 0 π¬ 0 π 0
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
03.09.2025 20:30 β π 2 π 0 π¬ 0 π 0
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
31.08.2025 19:28 β π 0 π 0 π¬ 0 π 0
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
28.08.2025 20:02 β π 2 π 0 π¬ 0 π 0
Boosting Laravel Boost
In the era of AI, LLMs are undeniably part of our workflow. Let's make them suck less with Laravel Boost.
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
23.08.2025 19:48 β π 4 π 0 π¬ 0 π 0
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
28.07.2025 18:43 β π 3 π 0 π¬ 0 π 0
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
21.07.2025 20:03 β π 1 π 0 π¬ 0 π 0
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
15.07.2025 20:47 β π 2 π 0 π¬ 0 π 0
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
12.07.2025 20:45 β π 0 π 0 π¬ 0 π 0
Allows GIF. I upload GIF. Shows Static π
09.07.2025 22:02 β π 0 π 0 π¬ 0 π 0
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
09.07.2025 21:36 β π 2 π 0 π¬ 1 π 0
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
06.07.2025 19:27 β π 3 π 0 π¬ 0 π 1
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
29.06.2025 20:47 β π 2 π 0 π¬ 0 π 0
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
26.06.2025 20:08 β π 3 π 0 π¬ 0 π 0
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
21.06.2025 19:03 β π 5 π 1 π¬ 0 π 0
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
10.06.2025 19:57 β π 3 π 1 π¬ 0 π 0
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
03.06.2025 19:52 β π 2 π 0 π¬ 0 π 0
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
01.06.2025 19:37 β π 3 π 1 π¬ 0 π 0
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
26.05.2025 20:22 β π 4 π 0 π¬ 0 π 0
Yeah, I'm basically using the JobRepository from Horizon β it's what the API uses under the hood. I built a couple of tools around it and added the missing features I wanted in Horizon, and that's it.
For the MCP server itself, I used the innoge/laravel-mcp package.
It can be really useful tbh ππ½
16.05.2025 18:48 β π 1 π 0 π¬ 0 π 0
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 π€
14.05.2025 19:09 β π 2 π 0 π¬ 1 π 0
You can find all the code here
github.com/OussamaMater...
13.05.2025 19:32 β π 0 π 0 π¬ 0 π 0
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
13.05.2025 19:32 β π 1 π 0 π¬ 1 π 0
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
10.05.2025 20:25 β π 2 π 0 π¬ 0 π 0
Laravel Tip π‘: Reusable Pipelines
Pipelines allow you to split a large task into smaller, more manageable ones. Sometimes, you may want to use the same pipeline in different places, and it turns out Laravel allows you to define reusable pipelines out of the box π
#laravel
04.05.2025 19:33 β π 5 π 0 π¬ 0 π 0
Laravel Tip π‘: Restore Trashed Models
Have you ever needed to restore trashed models? While you could do this manually, Laravel ships with a restore method for exactly this π
#laravel
27.04.2025 19:10 β π 1 π 0 π¬ 0 π 0