Local helpers with Laravel for speed and sanity

Why it's worth adding some local only UI options

About a year ago spatie released a small package called https://github.com/spatie/laravel-login-link - a library that lets you quickly login via an auto login button on the login page when you're working locally.

Now I'm used to using custom CLI commands, conjuring up models, and seeding states for testing and development purposes. But this package got me thinking โ€“ why not expose more UI features just for use during local development?

Last few months I've been working on an application that has a core 'approvals' process - Managers have to give a thumbs-up or thumbs-down to requests by other users, triggering various effects based on decisions and user states and so on.

My feature tests can check if the functionally works as desired, but when working on the UI or user flow it is impractical to manually make each action work.

Instead, I added this snippet to my approvals screen:


Then the livewire component did the work with functions like 'make basic approval', 'make full approval' so I can generate the various situations on the fly.

Sure I could do art make:approval 5 in a terminal but hitting the button a few times on the page I'm already looking at is pretty much the same and much smoother in a discussion or demonstration.

Plus you can get fancy when it's in the UI - I've added a 'run events' option below each user card that only appears on local. Now I can force notifications to dispatch for any specific user, rather than in response to user actions which again makes showing the results of actions much faster than manually doing it or having to provide arguments to a terminal command.

Less advanced magic

A more basic option is just auto-filling a form. Typically I'd just mash a keyboard with some dummy data as it's always good to test the real flow. But working on a long multi-step form recently with multiple required fields and validation rules for phone numbers, email addresses and even VAT numbers, that was quickly a frustrating experience!)

So I added a magic 'autofill' button. Whips up a model factory and fills out any empty required model properties with valid-looking data.

It's like having a personal assistant for your form-filling needs - you can demo the forms interesting dropdowns or conditional fields, then just autofill the rest to pass the validation and show what happens next! Plus no more awkward typos when someone's watching! ๐Ÿ‘

So if you've never thought of adding UI actions to your site for local only - try it out! It adds a lot of smoothness to design and demo work, and lets people test only what they need very quickly.