Validation in Laravel Artisan commands

One of the things I like most about using Laravel is that most everything I’ve needed to do so far is pretty intuitive.  If I try to code up something the way I think it’s supposed to work, usually it does.

I’ve been working on adding some new Artisan commands to my equipment database to handle some of the back-end administrative tasks that I’d normally have to fire up a browser for.

Naturally I want to validate the input.  Laravel’s got some really nice validation rules that would be nice to use in my new artisan commands.  The documentation covers doing validation on incoming HTTP requests, but isn’t clear on whether the Validator can be used more generically.

Looking at the documentation for manually creating validators, a Validator instance takes two arrays: an array with the data to be validated, and an array containing the validation rules.

It seemed like I could use the Validator facade pretty much anywhere as long as I had arrays of data and validation rules.  In my artisan commands, I added a use statement for the Validator facade,

use Illuminate\Support\Facades\Validator;

and the rest mostly followed the manual validator creation docs.

$validator = Validator::make($model->toArray(), [
  // validation rules
]);

if ($validator->fails()) {
  // show validation errors and exit
}
else {
  // do stuff with validated data
}

Much happiness ensued when I tested things out and saw that the validations were working just like I thought they should.

Dipping my toes into org-mode

I’ve taken one of the older but still very capable laptops in my collection and put it to use as my “school” computer.  The goal is to have something I can lug around and use for research, number crunching, and my research notebook.  Then I don’t have to worry about trying to keep all that stuff in sync if I were to use my work and home desktop computers.

My handwriting can get pretty messy, and even I have a hard time reading my own handwriting sometimes.  I decided I wanted to do some kind of electronic lab notebook to keep my research notes, data, bibliography, and whatnot. 

I’ve been making an effort to spend more time in Emacs, and I have a few developer friends who rave about org-mode, so it seemed like a promising choice.

A quick Google search returned a few blog posts by people who are already using org-mode for research lab notes and writing papers and other research related tasks.  Plenty of prior work out there to learn from as I develop my own workflow.

Back on the PhD wagon

Learned earlier this week that my application to be readmitted to the Clemson-MUSC Bioengineering PhD program was approved, so I’ll be a student again starting with the Spring 2019 semester.

Fortunately, I won’t have to take anymore courses. Just need to figure out the research project(s), do the research, and then write everything up.

Easy peasy, right?

The semester starts January 9, so I get to be a student for my birthday.

“It seemed like a good idea at the time…”

– Me, 2009.  Me again, 2018
PhD Comics: Raiders of the Lost Dissertation  by Jorge Cham
PhD Comics: Raiders of the Lost Dissertation

Aging doggos

The puppies are getting older.  Nala will be 14 soon, and Simba will be 13 next year.  Pretty respectable ages for Labradors.

Boop the snoot
Boop the snoot

We don’t go on too many long walks now.  It’s more like I’m pulling them along rather than them pulling me down the street these days.  We go for short walks, or just play in the back yard.

Both dogs have slowed down in activity level over the past few years, but Simba’s starting to show more signs of old age than Nala is.  He’s showing signs of some osteoarthritis and has a bit of muscle atrophy in his hind quarters as a result.  He still runs around in the yard a bit but not as much as he used to, and he’s a little slower to get up these days.

Car ride!

They’re both still happy and content dogs, and I think they’ll be around for a few more birthdays.

Two and a half days at Disney World

Got to spend two and a half days wandering around parts of Disney World over the weekend.

Drove down to the Orlando area Saturday, stopping at IKEA in Jacksonville on the way to check out cabinets that we’re planning on putting in the laundry room at some point.  Of all the IKEAs we’ve been to, the one in  Jacksonville is a bit of an oddball, since it’s only a single level.

Stopped at Skycraft Parts & Surplus in Orlando to browse.  Really wish there was a store like that here in Charleston.  I’d probably end up spending a lot of time there.

After checking in to the hotel and getting unpacked, we headed off to Disney Springs to pick up my Epcot ticket and trade in Connie’s old 4-day Park Hopper pass with one day left from back when they didn’t expire for a new ticket.  Spent most of the evening wandering around Disney Springs and had a good time. 

Tasty tip: Stop at Cooke’s of Dublin and get the Hog in a Box.

The next day (Sunday) we went to Disney’s Fort Wilderness Resort.  We had tickets for the Hoop-Dee-Doo Musical Revue later in the afternoon so they let us in to park early.  We spent our time before the show resort hopping to check out and wander around some of the nearby resorts.  Took a boat to the Wilderness Lodge, and then to the Contemporary Resort.  From there we hopped on the monorail to the Polynesian Resort where we had lunch, and then the Grand Floridian Resort (very fancy place).  Finally, we got back on the monorail to go to the Magic Kingdom where we walked around the entrance a bit (didn’t go in) and then caught the boat back to Fort Wilderness to meet up with friends.

The Hoop-Dee-Doo Musical Revue show is an entertaining hour and a half or so of music, song, and dance accompanied by an all-you-can-eat dinner of fried chicken buckets, pails of ribs, bowls of baked beans, corn, and mashed potatoes, and topped off with strawberry shortcake.

We all quite enjoyed the show and the food.

The next day, Monday, was Epcot Day!  Epcot is our favourite Disney park.

Spaceship Earth at Epcot
Spaceship Earth at Epcot

Epcot Day started off bright and early with us arriving at the parking lot gate at 7:30 AM, right when the parking lot opens.  The parking lot Cast Member asked us how we were doing, and Connie responded with an enthusiastic “We’re awesome! We’re at Epcot!”  I guess Connie’s enthusiasm was contagious, because she waved us on by and we didn’t have to pay the $25 for parking.

After parking close enough that we could walk to the entrance, we waited for the security lines to open, then hopped on the monorail to the Transportation and Ticket Center and back.  The ride offers a nice view of parts of Disney World and on the way back makes a loop through Epcot’s Future World.

About 10 or 15 minutes before the rope drops, the gathered crowd is entertained by the JAMMitors, a percussion trio playing on trash can lids and pails.  Then, at 9AM the rope drops and the crowd rushes into the park.

Any way you do things, spending the day at Epcot is tiring.  We took it easy, weren’t rushing anywhere, took breaks, enjoyed rides, and were still exhausted by the end of the day.

The Epcot International Food & Wine Festival was happening while we were there, so we got to sample a few dishes while we wandered around.

Pro tip: If you’re buying stuff at Epcot, you can have them delivered to Package Pickup (located at The Gift Stop by the park entrance) and pick up your goods on the way out.  That way you don’t need to lug things around while you’re exploring the park.  The cut-off time for getting purchases sent to Package Pickup is 6PM but if you’re going to do it, have your last purchase sent to Package Pickup well before that.  If you’re staying at one of the Disney resorts, you can have your purchases sent to your resort which makes things even easier.

Wrapping up the evening was the IllumiNations: Reflections of Earth show.  Last month there was an announcement that the IllumiNations show was going to be retired in 2019 and replaced with something else.  It was important enough to Connie that we see the show together that we cancelled the cruise we had planned for May 2019 to make the trip to Epcot instead.  The show was a fantastic spectacle of music, fireworks, lasers, video, water, and fire.  Really big fire.  It’s a pretty awesome show and definitely worth waiting around for.

Spaceship Earth at night
Spaceship Earth at night