Mohammad Emran ⚡️
phpfour.bsky.social
Mohammad Emran ⚡️
@phpfour.bsky.social
Laravel, PHP, and Web Development. Follow along to become a PRO software developer.

#FreePalestine 🇵🇸
Laravel Tip ⚡

Need to count the unique column values in an Eloquent model effortlessly? Here's a handy way to do that.

Note that you'll need to place this on a base model that your other models would extend.
January 27, 2025 at 5:37 PM
Laravel Tip ⚡️

Use Arr::get() or “data_get” helper methods to retrieve a value from a deeply nested array using the handy "dot" notation. The “data_get” method supports objects, too!

They accept a default value as well, which will be returned if the specified key doesn't exist.
January 21, 2025 at 4:57 PM
Are you using macOS with Homebrew? Here's a quality-of-life tip, run:

brew install quicklook-json --cask

And voilà — Quick Look now shows JSON files like a pro! 😎
January 10, 2025 at 2:00 PM
I've just streamlined my newsletter lineup, trimming it down to a top 10.

Today, I took the plunge and upgraded to the paid edition of @lennysan's newsletter—each issue is a masterclass!

Wanna gift yourself something for 2025? Join in with the link below

↓↓↓
January 7, 2025 at 5:15 PM
Laravel Tip ⚡️

Need to update a lot of models based on some complex conditions?

Combine these Eloquent methods for a 10-100X speed bump:

• select() → retrieve only IDs
• chunkById() → use batching to break large data
• toQuery() → perform update on the models
January 6, 2025 at 5:37 PM
5 Laravel courses that helped me:

💰 Get a raise
🌐 Land a high-paying Remote job
🥇 Become a Laravel Certified Developer
💪 Gave me the confidence to quit my job
⭐ Start building my own product

Let's dive in! 🧵 ↓
January 2, 2025 at 5:15 PM
I'd like to start a daily writing habit in 2025.

I found a great guide by @petersuhm to help me out (link below).

Who's with me? 👋
January 1, 2025 at 3:13 PM
Laravel Tip ⚡️

Supercharge your debugging with toRawSql() or ddRawSql() methods on an Eloquent query builder.

These methods output the raw SQL query with all the bindings substituted with real value – a true lifesaver when you need it the most 😉
December 30, 2024 at 2:00 PM
The 2025 Laravel Power Pack:

• Laravel Cloud*
• Laravel Nightwatch*
• Laravel Herd
• Laravel Horizon
• Laravel Debugbar
• Inertia 2 / Livewire
• Filament 4*
• Tinkerwell
• Ray by Spatie
• PhpStorm + Laravel Idea
• Laracast / Laravel Daily

What’s in your toolbox? 😎
December 23, 2024 at 2:00 PM
Laravel Tip ⚡

If you use custom table names often, you can access an Eloquent table name using this handy little helper function!

This is very handy if you use modules and would like to prefix table names with the module name (e.g., course__lessons, website__pages, etc.)
December 22, 2024 at 5:29 PM
Typically, I skip marketing books, but this one grabbed my attention.

I'm halfway through, must say it's refreshingly well-written, uniquely styled, and free of fluff.

A must-read for founders like myself, who dread marketing but need to up their game.

Link in comments ↓
December 20, 2024 at 5:03 PM
I liked this tutorial series on Laravel 11, Inertia, and React, which resonated with my taste. What I liked:

✅ Very straightforward, no fluffy introduction, etc.
✅ Doesn't use any starter kit; shows the full setup process.
✅ Gradually builds a CRUD application.

Link below ↓
December 18, 2024 at 4:56 PM
Laravel Tip ⚡

Stop writing complex queries in your controllers!

Use dedicated Query classes to handle aggregated data across multiple models with elegance.

Benefits:
✅ Single-purpose
✅ Clearly communicates the intent
✅ Easier to test complex queries in isolation
December 14, 2024 at 5:18 PM