As we approach the end of the year, I reflect back over what has happened this year and what next near will mean to me in regard to my life and mental health.

A Quick Summary of 2018

I’d rather not go in to some of the specifics so I’ll keep this as short as possible. 2018 didn’t start great for me and my family. I had a chest infection for the first 2 months and had to visit the doctors and go to hospital for x-rays. I’d never had a chest infection for that long so got quite worried. Luckily after a round of…

Having lived with depression and anxiety; a delightful duo, since I was around 12–13 years old it’s taken me a long time to get it under control. I will go over 5 things I did to help improve my mental health.

Bare in mind that everyone is different so somethings will work for you and not others and vice versa.


Sleep can be an illusive bastard. The powers that be say you need around 7–8 hours sleep to be well rested, but its not as easy as that. The key to waking up and not feeling tired still is to…

I recently began refactoring a bunch of code on a project and found myself putting the same methods on my Eloquent models for a relation to an Account class. FYI I prefer to have getters and setters rather than accessing properties magically.

So lets say we have a Post model that looks something like this:


use Illuminate\Database\Eloquent\Model;/** * Class Post * * @package App */ class Post extends Model { /** * @return string */ public function getTitle() { return $this->getAttribute('title'); } /** * @param string $title * @return $this */ public function setTitle(string $title) {…

I’m relatively new to using Laravel 5. Up until recently I managed a few applications that were Laravel 3 and 4.2, sadly we never had the time to migrate them.

When I started a new project I chose Laravel 5 (5.5 was the latest version as of starting this article, but has been updated for 5.6) and one of the best features was the ability to use multiple auth guards. This is great for applications that have 2 sets of users (e.g. customers, staff) and so needed their own login pages etc. …

I’ve been playing around with Laravel 5 for some time now and with it started using Laravel Mix. For anyone that doesn’t know its frontend build tool that wraps Webpack.

Like with Symfony Encore you can use these build tools in and out of the framework. This article will show you how to set it up.

Setup package.json

First we need to create our package.json. Run the following command to create a skeleton package.json file:

npm init -y

This will create something like:

"name": "laravel-mix-so",
"version": "1.0.0",
"description": "",
"main": "index.js", …

This Article was written around Laravel 5.6 and may not work with Laravel 6, 7 or 8

User Roles allow us to control access to a page or feature within an application.

I recently implemented User Roles into a project to control access in the staff section of a website for different user groups; admin, management, support, accounts mangers for example.

This approach was inspired by how its done in Symfony. It is one way you can do it, but it depends on how it needs to fit into your project. …

For people that can’t migrate away from Laravel 4.2 they still want to be able to use the latest version of PHP, if not for the features but for the speed benefits.


Mcrypt was removed in PHP 7.2 and can be installed using pecl. Laravel has a hardcoded check for the mcrypt extension, plus the Encrypter uses mcrypt constants.

The Encrypter (and many of Laravel’s components) aren’t interfaced, so you can’t just drop in a replacement. I ported the Laravel 5 Encrypter into a package that supports PHP 5.6 and 7.1. See: …

From Laravel 5.6 you could configure multiple log handlers, which is great. But there was one thing I noticed you can do with Monolog that wasn’t in Laravel’s logging documentation. And thats handler bubbling.

What is Log Handler Bubbling?

Handler bubbling allows you to control if the logger should continue going through the remaining handlers and checking if it can log to them, based on the log level.

How to setup Log Handler Bubbling

Say you want to split your logging out so all debug & info levels go to an audit.log and notice and above (so emergency, alert, critical, error, warning) would go to laravel.log.

So we need to add…

Validation in Laravel is covered a great deal in the docs, but is more focused on using them in Controllers, but theres nothing stopping you from using them in other places, Console Commands for example. In this article we’re going to create a console command for create a staff user and use the Laravel Validator to validate our input from the command.

Building Our Console Command

We’re going to write a console command for create a staff user. To give us a base command to edit we’ll use the make:command command:

php artisan make:command CreateStaffCommand

I always suffix my commands with Command but you…

I recently ran into a problem where I needed to bulk update a table based on values in another column. I didn’t want to query for all the things, make the changes in PHP and save each one, but I also didn’t want to write raw MySql.

Enter Raw Expressions. They’re document but not fully (see, particularly for doing update queries, which I’ll focus on in this article.

Using Raw Expressions

What are Raw Expressions?

Raw Expressions allow you to tell the query builder that you want to use what you entered and not get processed or manipulate before running the query against the database. In…

Tom Ellis

PHP and JavaScript hacker. Symfony and Laravel tinkerer. Creator of TomahawkPHP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store