tonystore/livewire-permission-manager

Package that provides a graphical interface to manage roles and permissions.

Installs: 696

Dependents: 0

Suggesters: 0

Security: 0

Stars: 19

Watchers: 2

Forks: 4

Open Issues: 0

Language:Blade

Type:package

v0.3.0 2024-02-11 05:27 UTC

This package is auto-updated.

Last update: 2024-11-11 07:25:22 UTC


README

Latest Stable Version Total Downloads License PHP Version Require

Package that provides a graphical interface to manage roles and permissions.

REQUIREMENTS

Version Compatibility Livewire

INSTALLATION VIA COMPOSER

Step 1: Composer

Run this command line in console.

composer require tonystore/livewire-permission-manager

Step 2: Publish Assets

Publish Config File

php artisan vendor:publish --provider="Tonystore\LivewirePermission\LivewirePermissionProvider" --tag=config-permission

Publish Views

Publish the views only if any modifications to the interfaces are required.

php artisan vendor:publish --provider="Tonystore\LivewirePermission\LivewirePermissionProvider" --tag=views-permission

Publish Migrations

Publishes migrations, only if a new column is created for the detail of a role or permission.

php artisan vendor:publish --provider="Tonystore\LivewirePermission\LivewirePermissionProvider" --tag=migrations-permission

Publish Lang

Publish the translations in case you wish to modify any of them.

php artisan vendor:publish --provider="Tonystore\LivewirePermission\LivewirePermissionProvider" --tag=langs-permission

Usage

By default, Tailwind is used to create the role and permissions management interface, but you can also choose the Bootstrap theme.

<?php
return [
	/*
	 * Supported Theme: 'tailwind, bootstrap',
	 */
	'theme'  =>  'tailwind',
];

Configure templates

You have 2 alternatives to use with this package, using the blade directives or using the laravel components.

<?php
return [
	'blade-template'  => [
		'type'  =>  'components', //Supported Type: 'components, directives'
		'component'  =>  'AppLayout', //type: components
		'directives'  => [ //type: directives
			'extends'  =>  'layouts.app',
			'section-content'  =>  'content',
		],
	],
];

Includes the component that contains the scripts and styles needed for the graphic interface.

<head>
    ....
       <x-permissions::styles />
    ....
</head>
 <body> 
    ...
    @livewireScripts
    
    <script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>
    //INSERT COMPONENT
       <x-permissions::scripts />
  
 </body>

To remove a role, SweetAlert is used, so you must have it in your design, and it must be before the script component. Note that you must import it after the Livewire scripts.

Select a Modal design

You will be able to select among the types of manners that the package will have, at the moment only a list type model is available, which is configured here:

<?php
return [
	'modals'  => [
		'role'  =>  'list'
	],
];

Customized page

Here you define the array of numbers for the paging options.

<?php
   'paginate' => [
        'perPages' => [
            10, 25, 50, 100, 200
        ]
    ]

Change tables name

Here you assign the names of the tables to be able to run the migration. By default it uses the tables listed in the Laravel Permission package.

<?php
return [
	'tables'  => [
		'roles'  =>  config('permission.table_names.roles', 'roles'),
		'permissions'  =>  config('permission.table_names.permissions', 'permissions'),
	],
];

Exclude roles

Here you define the roles you want to exclude from Livewire queries for display and modification. By default you will have an empty array.

<?php
return [
	'roles'  => [
		'excludes'  => []
	]
];

Column name

Here you define the name of the new column that will be created in the roles and permissions table defined, with this you can add a description to each role or permission created, by default the name of the column is description. By default the name.

<?php
return [
	'column_name'  => [
		'add_column' => false,
		'description'  =>  null,
	],
];

If you mark as true the option to add the description column, you must have previously generated that column in the respective database table.

Route

Set your own prefix and midlewares and name for the role management path and permissions. By default you will have the following:

<?php
return [
	'route'  => [
		'middleware'  => [
			'web',
			'auth'
		],
		'prefix'  =>  'admin',
		'name'  =>  'permission.index',
		'url'  =>  '/roles/manager'
	],
];

Now, once everything is configured, you will be able to access the path to manage your roles.

http://localhost/admin/roles/manager