LLoadout is your loadout for Laravel. It helps you with tips , code examples and packages to make you a better Laravel developer.
With LLoadout Inforce you will kickstart your Laravel development when using Laravel Jetstream and Spatie permissions.
LLoadout inforce will add a ui for managing users, roles, permission and menus. It will also provide you with an ui to link users to roles and assign permissions to roles.
you can manage roles and assign permissions to the roles
you can manage users and assign them a role. You can also assign permissions on user level.
you can manage menus
Laravel Jetstream is a requirement for this package, if you haven't allready install it i refer to the docs of Jetstream to install it.
https://jetstream.laravel.com/2.x/installation.html#livewire
If you hadn't already installed Laravel Permissions , install it first, therefor I refer to the docs of Spatie
https://spatie.be/docs/laravel-permission/v5/installation-laravel
Attention : don't forget to read the prerequisites : https://spatie.be/docs/laravel-permission/v5/prerequisites
composer require lloadout/inforce
LLoadout inforce uses some default menus and permissions, these can be created via the provided migrations and seeder.
php artisan vendor:publish --tag=LLoadoutInforce-migrations
php artisan vendor:publish --tag=LLoadoutInforce-seeders
php artisan migrate
php artisan db:seed --class=InforceSeeder
php artisan vendor:publish --tag=LLoadoutInforce-views
php artisan vendor:publish --tag=LLoadoutInforce-langs
It provides a ui for navigation management and navigation permissions.
Therefore you have to add this tag after the Navigation Links section navigation-menu.blade.php. Default on line 19
<livewire:navigation/>
or
@if(Auth::user()->hasRole('superuser')) // or your optional roles
<livewire:user-management-menus/>
<livewire:developer-menus/>
@endif
And add mobile menu default on line 214
@if(Auth::user()->hasRole('superuser')) // or your optional roles
<livewire:user-management-menus-mobile/>
<livewire:developer-menus-mobile/>
@endif
LLoadout inforce will default create a user with username of [email protected]
and the password password
Assume you want to add fields to the user view and want to save the field to the database. Than you can use the published view and extend the LLoadout user component. Herefore you have to create your own route to your own created component.
This is the route
Route::get('/user/detail/{user?}', \App\Http\Livewire\MyUser::class)->whereNumber('id')->name('users.edit');
This can be your component
<?php
namespace App\Http\Livewire;
use LLoadoutInforce\Http\Livewire\Traits\HandlesPermissions;
use LLoadoutInforce\Http\Livewire\Traits\ShowPerks;
class MyUser extends \LLoadoutInforce\Http\Livewire\User
{
protected function rules()
{
return [
'user.name' => 'required|string',
'user.email' => ['required', 'email', 'not_in:' . $this->user->id],
'user.password' => 'required|confirmed',
'user.password_confirmation' => 'required',
'user.extrafield' => 'required'
];
}
}
Via the permissions menu you can create your permissions, they are stored in the database. Via the user or role menu it is possible to assign a permission to a role or a user.
It is also possible to create menu's and corresponding permissions for the menu's. Giving users or roles access to the menu's via the roles and users management.