Matthew Portrait

Hey, I'm Matthew Erwin

I'm a Laravel/PHP developer working in Lincoln, UK.

Why not check out some of the projects and packages I've worked on.
I'm also starting to blog more about PHP/Laravel development, so watch this space!

Recent Posts

May 8, 2021

Auto generating argument typehints for PhpStorm in Laravel projects

In a Laravel project you can generate PHPDocs and PhpStorm Meta using the barryvdh/laravel-ide-helper package. We can add additional typehints for custom functions by writing a command to generate a new PhpStorm Meta file. This command will generate a...


January 30, 2021

Single component events in Laravel Livewire

When rendering multiple instances of the same Livewire component on a page you may want to emit an event to a specific child component, not all components of the same type. Take for example this page: If we fire the productUpdated...


January 23, 2021

Eager loading complex functions with Laravel custom collections

In Laravel, we can eager load relationships to prevent n+1 queries being performed when fetching multiple records from the database. An example taken from the Laravel docs. This works great for a relatively simple relationship however we can also...


November 9, 2020

Testing Laravel routes have middleware

In some applications you might require every route to be protected by authentication. We can use tests to make sure that all of your routes are using the correct middleware and are not accessible without the correct auth or permission. You may have...


October 8, 2020

Protecting LiveWire components when using multiple auth drivers

Laravel Livewire provides a dead easy way to add dynamic components to your site without the need to write any JavaScript. Although Livewire does support authentication out of the box, if you have multiple auth guards, you can run into issues or risk...