Laravel Query Builder Distinct

This is a shoutout to Laravel’s Query Builder method distinct(). I feel sad and embarrassed that I didn’t know about it sooner. There are a lot of instances where I need to get a column’s unique values. And instead of using groupBy() and wasting a lot of resources. You can use distinct(), which will search … Read more

Fast Insert CSV Data to Laravel From S3

The Story (skip if ya just want the code) I’ve fussed with this problem for weeks. If you need to import massive amounts of csv data (100k to 10mil) to your Laravel site there’s a lot of broken information. Some of it is outdated, others are just bits and pieces. But here’s generally how the … Read more

Curl Error Using Guzzle using Laravel Valet and Passport

This is a niche issue with: Laravel, Valet, Passport, Guzzle, Curl, API If you’re using Laravel Passport and you’re doing something like this: use GuzzleHttp\Client; try { $client = new Client(); $client->post(‘site.test/oath/token’, [some params]); And you get an error “Laravel guzzle cURL error 6: Could not resolve host” while making an api post request. Check … Read more

Setting Up Virtual Hosts on a Mac

I ran into some trouble running through different tutorials to setup virtual hosts while setting up a local Laravel site. There doesn’t seem to be much consensus on the developers’ preferred local environment. So here’s how to setup virtual hosts on a mac with MAMP. From what I understand this let’s you use a “virtual” … Read more

PHP File Handling Cheat Sheet

Accessing Directory Read Directory Files into Array $dir = ‘example’; $files = scandir($dir, ‘w’) or die(‘Cannot read directory: ‘.$dir); //implicitly creates file foreach ($files as $file) { //do something with $file } Open and Close Directory $dir = ‘example’; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) … Read more

Contact Form 7 Ticketing Plugin

The CF7 Ticketing Plugin is an incomplete plugin made for a client that needs a ticketing system for building maintenance. It utilizes the Contact Form 7 plugin for form validation and stores the input as a custom post type that can be searched and organized. CF7-Support-Ticket Plugin The plugin includes a custom backend menu, “Tickets”, … Read more