Personal Blog

I specialize in composing articles about web development and programming, with a focus on the Laravel framework. Additionally, I also write about any other relevant topics that come to mind. Utilize the search function to easily sort through my posts.

2023

How to Add Translatable Enum Options in Laravel
Mar 16
This article explores a solution for displaying enum values in a translatable format in Laravel. Enums in Laravel are useful in defining a fixed set of values, but they don't provide a built-in way to display those values in different languages. I'll show you how to create translatable string values for enums and retrieve them easily. I'll also demonstrate how to simplify this process using an interface and a trait. With this approach, you can easily display enum values in any language supported by your Laravel app.
Adding a Custom Open Graph Image to Posts
Mar 06
This article shows you how to use a package to create custom Open Graph images for your Laravel-backed blog posts. By following our guide, you can enhance your website's visual appeal and shareability on social media. This is ideal for bloggers, developers, and website owners looking to increase their online presence and visibility.
Laravel: Customizing Route Binding Logic
Feb 03
In Laravel, customizing route model binding allows you to add custom logic to the process of retrieving a model based on its ID. This article demonstrates how to use a custom parameter and the bind method to guarantee that visitors cannot access an unpublished post. Clear code examples are provided to help implement this solution.

2022

Style Your Command Outputs The Laravel Way
Aug 12
Yesterday I was going through a command written by one of my colleague to help us seed permissions in an easier way. I was going to add it to our office Laravel skeleton (Laravel with extra functionality to make our life easier). Just I was about to add it, I thought why not use same styling used by Laravel to style the command output. So I dug into Laravel’s code.
Eloquent: One To One Relationships
Apr 24
One to one is a very simple relationship but often not used. So time to time you may need to refer to documentation or google it to understand the relationship better. So here is my effort to make your life a little bit easier.

2021

Consider an intermediate level refactor
Oct 26
Your file structure is growing. It is not big enough to go DDD yet, neither small enough to follow default Laravel structure. What will you do?
How to implement model states using spaties laravel model state package
Feb 21
Sometimes handling the status of a given record is a pain. You may need to fire events, check if the model can change to the desired status or if the user is authorized to make the change and lot more. In this post, I will be covering a spatie package to help solve this issue.
All Rights Reserved. 2024 © Hussain Afeef