vortechron/roles-permissions-manager

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

dev-master 2020-02-01 08:35 UTC

This package is auto-updated.

Last update: 2021-10-29 02:59:21 UTC


README

All code shown here is just an example. Tightly coupled with Bootstrap 4.

Role Manager Markup/Form

<form action="{{ $routeAction }}" method="post">
    <!-- Include roles manager markup -->
    @include('rpmanager::roles.template')

    <button type="submit" class="btn btn-primary">Save</button>

    @if ($role->id != 1)
    <button type="submit" formaction="@route('admin.roles.delete', $role)" class="btn btn-danger">Delete</button>
    @endif
</form>

Role Manager Index List

<a name="" id="" class="btn btn-secondary -mt-2" href="@route('admin.users.index')" role="button"> <i class="fa fa-arrow-left"></i> Back To List</a>
@include('rpmanager::roles.index', [
    'routeCreate' => route('admin.roles.create'),
    'routeEdit' => function ($role) {
        return route('admin.roles.edit', $role);
    }
])

Role Manager Controller Action

use Vortechron\RPManager\Models\Role;

class RoleManager extends Controller
{
    public function index()
    {
        Role::indexAction();

        return view('admin.role.index');
    }

    public function create()
    {
        Role::createAction();

        return view('admin.role.template', ['routeAction' => route('admin.roles.store')]);
    }

    public function store(Request $request)
    {
        Role::storeAction($request);
        
        return redirect()->route('admin.roles.index');
    }

    public function edit(Role $role)
    {
        Role::editAction($role);

        return view('admin.role.template', ['routeAction' => route('admin.roles.update', $role)]);
    }

    public function update(Request $request, Role $role)
    {
        Role::updateAction($role, $request);
        
        return redirect()->route('admin.roles.index');
    }

    public function destroy(Role $role)
    {
        Role::destroyAction($role);

        return redirect()->route('admin.roles.index');
    }
}

Roles Dropdown

<form action="@route('admin.users.update', $user)" method="post" class="mt-4">
    @csrf
    @include('rpmanager::components.roles_dropdown')

    <button type="submit" class="btn btn-primary">Save</button>
</form>

Roles Button Link

@can('manage roles')
@include('rpmanager::components.roles_button', [
    'route' => route('admin.roles.index'), 
    'class' => '-mt-2']
)
@endcan

Roles Route Helper

Route::group(['middleware' => ['permission:manage roles']], function () {
    rpmanager_routes(RoleManager::class);
});