A New Desk Top
When we first moved the office to the cabin we chose to put the desk facing the window with the worst view. The logic was that I'd want to save the best views for windows that wouldn't be blocked by a desk and computer screen.This worked fine until I...
Big Joinery & Precise Measurements
If the first day was all about setup, the next few days were all about making shavings fly! The timbers had been cut to rough length the day before, so we wasted no time laying out our joinery. ...
Mocking Fluent Laravel Facade Chains
Laravel offers a few different ways to test facades but the documentation doesn't cover testing individual calls within a fluent chain. As is normally the case with Laravel, testing in this fashion is totally doable... I wrote about the process over...
What a Surprise!
On June 17th, 2018, my wife and kids surprised me with one of the most extravagant gifts I've ever received. We were camping in Duluth, MN, where I was running a race on the Saturday of father's day weekend. After the race was done we stuck around...
The Southwest Corner
Now that we are getting closer to spring, and the sun is higher in the sky, I've had to relocate my desk to the southwest corner of the cabin to try and avoid screen glare. Previously it was located on the southeast window. I'm very pleased with the...
Using WhereHas in Laravel Polymorphic Relations
Techniques like these are important to document because we bump into them frequently, but not frequently enough to have it memorized!
It seems like once every project I find myself googling "Laravel Polymorphic WhereHas", combing through one result after another, frustratedly repeating "How do I do this???".
While there isn't a first-party supported solution, I wanted to document what has been working for me, so I don't have to continue searching StackOverflow!
Programming for your Future Self
If you are anything like me, you may find yourself hacking on a variety of different applications during a given week. Occasionally I get the luxury of working on a single app, which gives my brain the freedom to immerse itself into the details of the program. However, inevitably at some point I have to set the project aside and fire up a different one… perhaps one that was written months, or even years ago.
Several thoughts have repeatedly surfaced as I re-familiarize myself with an old project. Instead of having to collect them each time, I thought I’d write them down here, to serve as a reminder.
Sorting Parent Eloquent Models by a Child Relationship
Recently I had a situation in a Laravel app where I needed to sort a collection of parent models by a particular value in a
It’s fairly simple to sort the opposite direction, meaning, to sort all the related models that belong to a parent model.
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.
In today’s article, I will attempt to rework the Simplifying Conditional Expressions (pp. 237-270) section into a handful of PHP-based examples.
Replace Conditional with Polymorphism
Polymorphism is an extremely helpful technique to master. Take a look at this article to see it implemented in a Laravel application:
If you've ever done any research into refactoring, or programming in general, you've most likely heard the term "polymorphism". When I first came across it, I have to admit, I was intimidated.
Now that I've become more familiar with the concept, I can assure you, the word itself is more complicated than the underlying principle!
Page 3 of 4 (33 total entries)