portrait photo Eoghan O'Brien web developer

Notes on software development using Laravel and other random thoughts.

All of my rambling tips, tricks and thoughts on writing web applications using Laravel, collected in chronological order.


Dynamic Laravel Eloquent model relationships

Laravel Eloquent models are not `Macroable` by default, if you want to add a relationship dynamically on a model in another module or package, you need to macro through the `Builder` instead of the `Model`.

Custom user providers to authenticate legacy passwords

We have a couple of legacy projects with user records containing passwords encrypted using SHA-1, when moving these projects over to Laravel, we want to attempt to authenticate using Eloquent first and SHA-1 next.

Defining Laravel Middleware from inside a composer package

I write everything inside of packages, install using composer and use Service Providers to hook things up. When you do things this way, you make it very easy to upgrade. However, you lose some of the magical, inherently solved problems.

My current setup (2018)

Jumping on the latest Laravel community bandwagon, I'm documenting the software and configurations I use currently to develop software at the end of 2018.

Define a custom collection for your Eloquent model

Many Laravel newbies don't know that you can customize the collection returned by a query, so they end up writing tons of after-query functions to wrangle their results. I know a better way.