Camron Cade

Artisan web development, mostly using Laravel.

Blade shortcut for echoing variables that may not be set

Laravel is one of those frameworks that has hidden tricks that are a delight to stumble across. This is one of them. In your blade templates, you've probably done something like this: {{ $day->common_sense }} This is all fine and dandy, but what if the day doesn't exist? What if the day doesn't...

Read More

Things to note when using Dompdf

While using Dompdf for a project I came across two small things that are worth noting. Dompdf is a PHP package that converts html/css markup into a PDF. It's not super stable and can be gimmicky at times, but it works. 1. Image widths After struggling to get Dompdf to respond to CSS,...

Read More

The list() function [PHP]

The list() function was one of those functions that I didn't learn about in any PHP course, but has stumbled across while looking at others code. It's not really a function, but is a language construct but can be very handy. Basically, it unpacks arrays and assigns the keys individual variables. Here's an example...

Read More

Understanding Class Aggregation and Composition

If you spend anytime reading up on design patterns (I recommend this book), you'll come across terms like class association, aggregation, and composition. I recently stumbled into these and realized I didn't quite understand what they meant, nor what they might look like in the real world. Below is my understanding of the terms...

Read More

DB instance without using facades in Laravel's Lumen

The point of Lumen is that it is light and fast, and so by default helpful tools like Eloquent and Facades are disabled. I like to try and keep it light when I am using Lumen, so I opt to not turn them on. If you, like me, are used to using the facade...

Read More

.active classes in menus with Blade templates

In many of my projects, I have a layout blade file that each page extends. As part of the layout, there is a menu bar that has has a different style for a link if you are currently on that page. If you are using bootstrap or foundation, if you apply the css class...

Read More