Dead simple permissions for Laravel

Photo by Rob King on Unsplash

Update the user table migration

create_users_table.php migration
User.php

Define the available permissions

auth.php
$permissions = config('auth.permissions');
Creating a new user with permissions

Using Laravel policies

php ./artisan make:policy ArticlePolicy
ArticlePolicy.php

Create a service class

PermissionService.php
PermissionService.php
PermissionService.php
PermissionSerivce.php

Create a facade

Permissions.php
AppServiceProvider.php
Permissions::give($user, ['articles.create']);
$user->save();
PermissionService.php
ArticlePolicy.php

And JavaScript…

return Inertia::render('Pages/Articles/Create', [
'user' => Auth::user(),
]);
Component.vue

The Package

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store