Mohamed Said's Journal

Web Developer, cyclist, and freediver.

Posts in: Code

Posted on August, 25 2018

Testing Artisan Commands in Laravel 5.7+

Laravel 5.7 comes with a pretty neat way for testing console commands. Let's see what our tests might look like....

1 min Read Read Full Post
Posted on September, 21 2017

Better 404 responses using Laravel 5.5+

Laravel 5.5.10 is shipped with two useful router methods that'll help us present better 404 pages for our users......

2 mins Read Read Full Post
Posted on August, 9 2017

Persisting Redis data on disk

Redis data lives in memory, that makes it is very fast to write to and read from, but in case of server crashes you lose all that's in the memory, for some applications it's ok to lose these data in case of crash, but for other apps it's important to......

2 mins Read Read Full Post
Posted on May, 16 2017

Using Laravel Mailables and Notifications as Event Listeners

Most of the time we send alerts to our app users when a specific event happens, for example we send an invoice on a new purchase or a welcome email on user signup, and to do this we need to listen to that event like so:class EventServiceProvider extends......

1 min Read Read Full Post
Posted on May, 5 2017

Conditionally pushing event listeners to queue

Here's the situation, you're building an online store that should handle thousands of orders every day, one of the cool things about this store is that customers who make purchases above 10K should receive a gift coupon, let's see how we can implement such thing in laravel:On every new purchase......

1 min Read Read Full Post
Posted on July, 9 2016

Laravel/MySQL JSON documents faster lookup using generated columns

laravel 5.3 is shipped with built-in support for updating and querying JSON type database fields, the support currently fully covers MySQL 5.7 JSON type fields updates and lookups, this allows us to have the following......

1 min Read Read Full Post
Posted on April, 25 2016

Conditionally adding instructions to laravel's query builder

How to conditionally push extra instructions to the query builder using the same fluent syntax that you love....

1 min Read Read Full Post
Posted on April, 9 2016

Building and testing Artisan Commands

While building the Laravel Langman package I was facing some difficulties trying to figure out how to test a console command that interacts with the user via questions, most of the tutorials and blog posts I found online were just calling the command and passing arguments/options using the......

7 mins Read Read Full Post
Posted on March, 11 2016

MySQL JSON data type decoded

In this post we are going to explore the new MySQL 5.7 JSON Data Type. While diving into the topic we are going to use Laravel's fluent query builder....

2 mins Read Read Full Post