Companies permission control re-factoring menu and user forms..
This commit is contained in:
parent
90965de2e5
commit
4f31721396
@ -16,6 +16,15 @@ class Companies extends Controller
|
||||
{
|
||||
use Uploads, Users;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission checks to all methods only remove index method for all companies list.
|
||||
$this->middleware('permission:create-common-companies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-companies')->only('show', 'edit', 'export');
|
||||
$this->middleware('permission:update-common-companies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-common-companies')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
@ -32,23 +32,25 @@
|
||||
</x-slot>
|
||||
</x-form.section>
|
||||
|
||||
@if (user()->can('read-common-companies') || user()->hasRole(['admin', 'manager']))
|
||||
<x-form.section>
|
||||
<x-slot name="head">
|
||||
<x-form.section.head title="{{ trans('general.assign') }}" description="{!! trans('auth.form_description.assign', ['url' => $roles_url]) !!}" />
|
||||
</x-slot>
|
||||
|
||||
<x-slot name="body">
|
||||
@can('read-common-companies')
|
||||
<x-form.group.select multiple remote name="companies" label="{{ trans_choice('general.companies', 2) }}" :options="$companies" remote_action="{{ route('companies.index') }}" form-group-class="sm:col-span-6" />
|
||||
@endcan
|
||||
|
||||
@if (module_is_enabled('roles'))
|
||||
@can('read-roles-roles')
|
||||
<x-form.group.select name="roles" label="{{ trans_choice('general.roles', 1) }}" :options="$roles" change="onChangeRole" />
|
||||
@endcan
|
||||
@else
|
||||
@role('admin|manager')
|
||||
<x-form.group.select name="roles" label="{{ trans_choice('general.roles', 1) }}" :options="$roles" change="onChangeRole" />
|
||||
@endrole
|
||||
@endif
|
||||
</x-slot>
|
||||
</x-form.section>
|
||||
@endif
|
||||
|
||||
<x-form.section>
|
||||
<x-slot name="head">
|
||||
|
@ -38,23 +38,25 @@
|
||||
</x-slot>
|
||||
</x-form.section>
|
||||
|
||||
@if (user()->can('read-common-companies') || user()->hasRole(['admin', 'manager']))
|
||||
<x-form.section>
|
||||
<x-slot name="head">
|
||||
<x-form.section.head title="{{ trans('general.assign') }}" description="{!! trans('auth.form_description.assign', ['url' => $roles_url]) !!}" />
|
||||
</x-slot>
|
||||
|
||||
<x-slot name="body">
|
||||
@can('read-common-companies')
|
||||
<x-form.group.select multiple remote name="companies" label="{{ trans_choice('general.companies', 2) }}" :options="$companies" selected-key="company_ids" :remote_action="route('companies.index')" form-group-class="sm:col-span-6" />
|
||||
@endcan
|
||||
|
||||
@if (module_is_enabled('roles'))
|
||||
@can('read-roles-roles')
|
||||
<x-form.group.select name="roles" label="{{ trans_choice('general.roles', 1) }}" :options="$roles" change="onChangeRole" selected-key="roles.id" />
|
||||
@endcan
|
||||
@else
|
||||
@role('admin|manager')
|
||||
<x-form.group.select name="roles" label="{{ trans_choice('general.roles', 1) }}" :options="$roles" change="onChangeRole" selected-key="roles.id" />
|
||||
@endrole
|
||||
@endif
|
||||
</x-slot>
|
||||
</x-form.section>
|
||||
@endif
|
||||
|
||||
<x-form.section>
|
||||
<x-slot name="head">
|
||||
|
@ -123,17 +123,14 @@
|
||||
</x-button.hover>
|
||||
</span>
|
||||
|
||||
@can('read-common-companies')
|
||||
<div class="absolute top-2 ltr:-right-1 rtl:-left-1">
|
||||
<svg class="h-5 w-5 text-gray-400" x-description="Heroicon name: solid/selector" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
</button>
|
||||
|
||||
@can('read-common-companies')
|
||||
<div id="dropdown-menu-company" class="absolute right-0 mt-3 pt-2 bg-white rounded-md shadow-xl z-20 hidden" style="left: auto; min-width: 10rem;">
|
||||
@foreach($companies as $com)
|
||||
<x-link href="{{ route('companies.switch', $com->id) }}" id="menu-company-{{ $com->id }}" class="h-9 leading-9 flex items-center text-sm px-2" override="class" role="menuitem" tabindex="-1">
|
||||
@ -144,7 +141,6 @@
|
||||
</x-link>
|
||||
@endforeach
|
||||
|
||||
@can('update-common-companies')
|
||||
<x-link href="{{ route('companies.index') }}" class="h-9 leading-9 flex items-center text-sm px-2 mt-2 border-t rounded-bl rounded-br group hover:bg-purple" override="class">
|
||||
<div class="w-full h-full flex items-center rounded-md px-2">
|
||||
<span class="material-icons-outlined text-purple text-xl group-hover:text-white">settings</span>
|
||||
@ -153,9 +149,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</x-link>
|
||||
@endcan
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="main-menu transform">
|
||||
|
Loading…
x
Reference in New Issue
Block a user