Simplifying Conditional Expressions

As I’ve been reading through Refactoring by Martin Fowler, I’ve found it helpful to rewrite some of the examples from the book in PHP in order to cement the concepts into my mind. While Martin’s examples are primarily in Java, I’ve found an overwhelming majority of the concepts apply to PHP, which is where I spend most of my programming time.

Continue Reading
Written By Jesse Schutt
Posted on

Sorting Parent Eloquent Models by a Child Relationship

Ever needed to sort a parent Eloquent model by one of its child relationships? Here's how I do it!

Continue Reading
Written By Jesse Schutt
Posted on

Testing 101: Escape Testing Paralysis!

Learning to write good tests is critical to being a programmer. We write tests to make sure the work is solid and doing what it's supposed to, while exerting as little effort as possible (we're not lazy; we're effective...). When I understood that, I determined that I was going to get great at testing. So naturally I started internet research: "Dear Google, show me 'best code testing practices.'"

Continue Reading
Written By Jesse Schutt
Posted on

Using WhereHas in Laravel Polymorphic Relations

Have you ever needed to use a query constraint on a Laravel polymorphic relationship? Here's a method that has worked well for me!

Continue Reading
Written By Jesse Schutt
Posted on