Tim MacDonalds head shot

Tim MacDonald

Developing engaging and performant web applications with a focus on TDD. Specialising in PHP / Laravel projects. ❤️ building for the web.

Actively contributing to the PHP & Laravel communities with PRs, blog posts, and talks.

0418 492 380 • Sydney, Australia
New phone, who dis?

Query scopes, meet action scopes

Action scopes are...well...just query scopes really, but instead of filtering they take an action. It's just a random name I've given them to differentiate them from regular filtering based query scopes in my projects.

The case of the Laravel TestCase

Deep diving the Laravel TestCase and pushing it to the limit, and yea...that's the title I went with 🕵️‍♂️

Dedicated query builders for Eloquent models

As my current project grew, so did my models. In a hunt for thinner models, I realised it was possible to extract model scopes to a dedicated query builder class. I'll show you how to do this, and a few things to keep in mind if you implement this refactor.

Tips to speed up your PHPUnit tests

Guest post Having a fast test suite can be just as important as having a fast application. Here are some ways to make your test suite run faster.

Global application settings

Guest post In applications it is often useful to have a way to store some global settings. This post outlines my approach using a Spatie package to manage the values instead of Eloquent.

Giving collections a voice

Laravel collections have become an essential part of my codebases and I couldn't imagine working without them. I have found giving collections the voice of the problem domain makes for a much nicer API when compared to the generic collection methods.

My feature test suite setup

I do love a good feature test suite. I especially like them to be fast and, most importantly, trustworthy! As my approach has matured, and become stable, I thought I'd share how I go about setting things up.

Loading Eloquent relationship counts

There are several ways to load relationship counts on eloquent models. I'm going to explore the options and introduce you to a new one.

Versatile response objects in Laravel

I've found that introducing dedicated response objects that can handle multiple response formats is a really nice pattern to cleanup my controllers

Laravel Cashier: a helping hand

If you are creating a Laravel app with subscriptions via Stripe - Laravel Cashier might just be the helping hand you were looking for.

Foreign key validation rule

A foreign key validation rule for the Laravel Validator that helps wrap up the 'exists' rule with a bit of syntactic sugar. Probably not fantastic to work with in the traditional fashion, but using the rule builder package...it looks gooooood!

Writing a zero downtime deployment script

Having never written a shell script before, I thought I'd try and level up my dev skills by writing a simple deployment script for my website and my clients websites. The outcome: FlipIt™