Upgrading Laravel Homestead
Upgrading Laravel Homestead on my system requires a few additional steps not outlined in the official documentation. Instead of recreating them from memory each time I wanted to collect the items here.
For When Things Get Gnarly in Eloquent
Jonathan Reinink has written some excellent content around Eloquent and this article is one that I reference frequently. Jonathan walks us through handling sticky situations when we need to get a single record back from a relationship without causing N+1 issues.
Changing CLI PHP Versions on Laravel Homestead
A quick and easy way to change the working CLI PHP version in Laravel Homestead.
Troubleshooting NFS Shared Folders in Homestead
Every now and then I will attempt to start Laravel Homestead on my mac and will get an error indicating a problem with mounting the NFS shared folders.After entering the password into the command line the console will output:
Importing a PG Dump from the Command Line
Similar to the time formats I wrote about here, I can not seem to remember the syntax for importing a PostgreSQL dump file into a database from the command line!...
Common PHP/Carbon Date Formats
For some reason I can never seem to remember the specific syntax for formatting dates either in PHP or Carbon! So instead of continually referencing the php docs I thought I'd start compiling a list of formats I frequently use:...
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...
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 1 of 2 (11 total entries)