Oussama's Avatar

Oussama

@oussamamater.bsky.social

I write code.

27 Followers  |  14 Following  |  77 Posts  |  Joined: 28.11.2024  |  1.7837

Latest posts by oussamamater.bsky.social on Bluesky

Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Post image

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
Video thumbnail

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
Post image

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
Post image

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
Post image

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
Post image

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

@oussamamater is following 14 prominent accounts