You don't always need to put Pennant in the database
Pennant defaults to the database driver, and most tutorials follow that lead. That’s fine for long-lived flags, but it adds a row and a query for every feature resolution.
Page 3 of 77 - keep going...
Pennant defaults to the database driver, and most tutorials follow that lead. That’s fine for long-lived flags, but it adds a row and a query for every feature resolution.
Laravel’s default behavior on a failed FormRequest validation is to throw a ValidationException, which the framework’s exception handler converts into a redirect to the previous URL with the input flashed to the session and errors attached.
That works perfectly when a person submits the form as the redirect lands them back on that page with the errors.
It breaks down when the form submits itself, for example a bookmark to a GET form with validation, or submitting something into a target="_blank" (like PDF generation).
When you think of a CTO, what do you see?
Someone gray-haired, steering the ship like the last 20 years? A young, hot-shot that solves every single technical problem and then plays video games to relax?
It really doesn’t matter. I don’t actually picture or “see” anyone.
I can tell if a real CTO is in the room by just opening up my ears.
Laravel gives you two ways to define translations, PHP array files with short keys, or JSON files where the key is the default string itself. Array files are nice when you want stable, namespaced keys you reference everywhere. JSON files are nice when you don’t want to invent a key for every string and you’d rather just write the English (or default) version inline.
I picked JSON on a recent project, and then I hit a moment that gave me pause. I needed pluralization.
Most Eloquent factory states I’ve created are pretty simple like ->published() or ->cancelled().
They flip a flag or override a field to a fixed value making the call site of the factory easier to understand and requiring less ceremony.
Awesome.
But, a state can also accept arguments, and that opens up some useful patterns like deriving values from another model passed in by the caller.
In tests, it’s common to have a service that takes an Eloquent model as an argument, and therefore you want to mock that service to confirm it was called with the right model instance.
It’s already hard enough for me to start my exercise in the morning. Any friction in the way can make me stop it - or at least not track it.
Since I started using Strava to track my walks, I checked its iOS widgets. I figured I should be able to just click a widget to start an activity.
Sadly that’s not the case. They’re only progress widgets. So, after doing some research, I created my own iOS shortcut. Here’s how.
A common pattern when testing Laravel validation looks like this:
Tests that read or write files can be really annoying. I’ll admit it, in the past I’ve skipped a few. I just hate having to think about seeding the files, cleaning them up after, and don’t get me started on the pollution left over when a test crashes before it can tear down.
Here’s a Livewire checkout component that looks completely fine: