Jesse Schutt
← All writing

Tagged

Laravel

Ionic 5 + VueJS + Laravel + JWT


Recently I've been dabbling in building an iOS application for JobStruct, a business management tool for concrete contractors. Since I'm familiar with Vue we decided to use Ionic framework which allows an app to be written in javascript and then run as an application on ios and Android using web views. The two-part article series from Naveen Bommidi regarding authorization with JWT has been a good starting point.

Visit Part 1 & Part 2.

Renaming a Column with a Foreign Key in Laravel

This database originally used "customer_id" as the column name for the owner of each row, however the actual model being referenced was a "User". Here's how I changed the name of the column (which happened to have a foreign key on it) via Laravel migration:

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.

Dynamic Relationships in Laravel using Subqueries

Eager Loading Polymorphic Relations

Derek MacDonald wrote a nice post about eager loading polymorphic relationships. This has been a difficult item to solve so it's nice to see a documented approach that works for many scenarios. Thanks Derek!

Eager Loading Polymorphic Relations

Building a Laravel / MQTT App on Laravel Forge

Using a simple node script you can subscribe to an MQTT broker and forward messages to a Laravel application. Take a look at this article to see how we connected inexpensive temperature sensors to a web app for logging and reporting issues.

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…

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! Fortunately the…

Mocking Fluent Laravel Facade Chains

blueprint: post 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…

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!

Read the entire article on the Zaengle blog

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 BelongsTo() relationship field.

It’s fairly simple to sort the opposite direction, meaning, to sort all the related models that belong to a parent model.

Read the entire article on the Zaengle blog

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!

Read the entire article on the Zaengle blog