Matt McCaffrey    About    Archive

Laravel Permissions in Vue Components

I use Spatie’s excellent laravel-permission package in a Laravel 5.7 application to create permissions, assign them to roles, and assign roles to users. I frequently want to check whether an authenticated user has a specific permission. The package includes Blade directives such as @hasrole and @can that can be used in views, but there isn’t a standard for checking a user’s permission within a Vue component. Passing props to each component can become tiresome and inconsistent. What if there was a better way?

The below, inspired by an older post from Sergi Tur Badenas, describes a pattern that can be used in Vue components that are used by a Laravel application to check whether an authenticated user has a specified permission. It should be easy to adjust accordingly for different ACL packages.

Read more

Secure Tunnels to Laravel Homestead Using ngrok

Have you ever wanted to expose a local server behind a NAT or firewall to the internet? This can be useful when developing webhooks that require a public address. It can also be useful if you want to demo or get feedback on in-progress work that is on your local development environment without a deployment. I recently used ngrok to allow a product manager to try in-progress work that was hosted on my local Laravel Homestead environment. After getting past one gotcha that wasn’t immediately obvious to me, it worked perfectly.

Read more

My BBS Software From 1993

The buzz around Mastodon’s federated social network has made me nostalgic about bulletin board systems in the early nineties. It was an era that is unknown to most people. It was social networking before the phrase existed, and before giant corporations owned the social networks. Bulletin Board Systems had message boards, private messages, file sharing, and many of the social features that we are accustomed to in modern web and mobile applications.

Read more