Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 62f214a

Browse files
Merge pull request #4 from sayasuhendra/main
Added optional User Management and Developer Menu Component for desktop and mobile.
2 parents ae5668e + 7ab1e70 commit 62f214a

10 files changed

+167
-24
lines changed

README.md

+33-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# LLoadout
99

10-
LLoadout is your loadout for Laravel. It helps you with tips , code examples and packages to make you a better Laravel developer.
10+
LLoadout is your loadout for Laravel. It helps you with tips , code examples and packages to make you a better Laravel developer.
1111

1212
# LLoadout inforce
1313

@@ -19,20 +19,20 @@ With LLoadout Inforce you will kickstart your Laravel development when using Lar
1919

2020
## Users, roles and permissions
2121

22-
LLoadout inforce will add a ui for managing users, roles, permission and menus. It will also provide you with
22+
LLoadout inforce will add a ui for managing users, roles, permission and menus. It will also provide you with
2323
an ui to link users to roles and assign permissions to roles.
2424

25-
### manage roles
25+
### manage roles
2626

27-
you can manage roles and assign permissions to the roles
27+
you can manage roles and assign permissions to the roles
2828

2929
<p align="center">
3030
<img src="https://github.com/LLoadout/assets/blob/master/inforce/roles.png" title="LLoadout inforce">
3131
</p>
3232

33-
### manage users
33+
### manage users
3434

35-
you can manage users and assign them a role. You can also assign permissions on user level.
35+
you can manage users and assign them a role. You can also assign permissions on user level.
3636

3737
<p align="center">
3838
<img src="https://github.com/LLoadout/assets/blob/master/inforce/users.png" title="LLoadout inforce">
@@ -46,12 +46,9 @@ you can manage menus
4646
<img src="https://github.com/LLoadout/assets/blob/master/inforce/menus.png" title="LLoadout inforce">
4747
</p>
4848

49-
50-
5149
## Installation
5250

53-
54-
## Installing Laravel Jetstream, the Livewire version
51+
## Installing Laravel Jetstream, the Livewire version
5552

5653
Laravel Jetstream is a requirement for this package, if you haven't allready install it i refer
5754
to the docs of Jetstream to install it.
@@ -66,13 +63,13 @@ https://spatie.be/docs/laravel-permission/v4/installation-laravel
6663

6764
Attention : don't forget to read the prerequisites : https://spatie.be/docs/laravel-permission/v4/prerequisites
6865

69-
## Installation of LLoadout inforce
66+
## Installation of LLoadout inforce
7067

7168
```shell
7269
composer require lloadout/inforce
7370
```
7471

75-
### Assets
72+
### Assets
7673

7774
LLoadout inforce uses some default menus and permissions, these can be created via the provided migrations and seeder.
7875

@@ -96,8 +93,24 @@ It provides a ui for navigation management and navigation permissions.
9693

9794
Therefore you have to add this tag after the Navigation Links section navigation-menu.blade.php. Default on line 19
9895

99-
```php
96+
```php
10097
<livewire:navigation/>
98+
99+
or
100+
101+
@if(Auth::user()->hasRole('superuser')) // or your optional roles
102+
<livewire:user-management-menus/>
103+
<livewire:developer-menus/>
104+
@endif
105+
```
106+
107+
And add mobile menu default on line 214
108+
109+
```php
110+
@if(Auth::user()->hasRole('superuser')) // or your optional roles
111+
<livewire:user-management-menus-mobile/>
112+
<livewire:developer-menus-mobile/>
113+
@endif
101114
```
102115

103116
## Logging in
@@ -106,16 +119,17 @@ LLoadout inforce will default create a user with username of `[email protected]` and
106119

107120
## Extending the package
108121

109-
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.
122+
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.
110123
Herefore you have to create your own route to your own created component.
111124

112-
This is the route
125+
This is the route
113126

114127
```php
115-
Route::get('/user/detail/{user?}', \App\Http\Livewire\MyUser::class)->whereNumber('id')->name('users.edit');
128+
Route::get('/user/detail/{user?}', \App\Http\Livewire\MyUser::class)->whereNumber('id')->name('users.edit');
116129
```
117130

118131
This can be your component
132+
119133
```php
120134
<?php
121135

@@ -144,8 +158,8 @@ class MyUser extends \LLoadoutInforce\Http\Livewire\User
144158

145159
```
146160

147-
# Documentation
161+
# Documentation
148162

149-
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.
163+
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.
150164

151-
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.
165+
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="ml-3 relative">
2+
<x-jet-dropdown align="right" width="48">
3+
<x-slot name="trigger">
4+
<span class="inline-flex rounded-md">
5+
<button type="button" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:bg-gray-50 hover:text-gray-700 focus:outline-none focus:bg-gray-50 active:bg-gray-50 transition">
6+
{{ __('Developer Menu') }}
7+
<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
8+
<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" />
9+
</svg>
10+
</button>
11+
</span>
12+
</x-slot>
13+
14+
<x-slot name="content">
15+
<x-jet-dropdown-link href="{{ route('developers.permissions') }}">
16+
{{ __('Permissions') }}
17+
</x-jet-dropdown-link>
18+
<x-jet-dropdown-link href="{{ route('developers.menus') }}">
19+
{{ __('Menus') }}
20+
</x-jet-dropdown-link>
21+
</x-slot>
22+
</x-jet-dropdown>
23+
</div>
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="border-t border-gray-200"></div>
2+
3+
<div class="block px-4 py-2 text-xs text-gray-400">
4+
{{ __('Developer Menu') }}
5+
</div>
6+
<div class="border-t border-gray-100"></div>
7+
<x-jet-responsive-nav-link href="{{ route('developers.permissions') }}">
8+
{{ __('Permissions') }}
9+
</x-jet-responsive-nav-link>
10+
<x-jet-responsive-nav-link href="{{ route('developers.menus') }}">
11+
{{ __('Menus') }}
12+
</x-jet-responsive-nav-link>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="ml-3 relative">
2+
<x-jet-dropdown align="right" width="48">
3+
<x-slot name="trigger">
4+
<span class="inline-flex rounded-md">
5+
<button type="button" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:bg-gray-50 hover:text-gray-700 focus:outline-none focus:bg-gray-50 active:bg-gray-50 transition">
6+
{{ __('User Management') }}
7+
<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
8+
<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" />
9+
</svg>
10+
</button>
11+
</span>
12+
</x-slot>
13+
14+
<x-slot name="content">
15+
<x-jet-dropdown-link href="{{ route('users.index') }}">
16+
{{ __('Manage Users') }}
17+
</x-jet-dropdown-link>
18+
<x-jet-dropdown-link href="{{ route('users.roles') }}">
19+
{{ __('Manage Roles') }}
20+
</x-jet-dropdown-link>
21+
</x-slot>
22+
</x-jet-dropdown>
23+
</div>
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="border-t border-gray-200"></div>
2+
3+
<div class="block px-4 py-2 text-xs text-gray-400">
4+
{{ __('User Management') }}
5+
</div>
6+
<x-jet-responsive-nav-link href="{{ route('users.index') }}">
7+
{{ __('Manage Users') }}
8+
</x-jet-responsive-nav-link>
9+
<x-jet-responsive-nav-link href="{{ route('users.roles') }}">
10+
{{ __('Manage Roles') }}
11+
</x-jet-responsive-nav-link>
12+

src/Http/Livewire/DeveloperMenus.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace LLoadoutInforce\Http\Livewire;
4+
5+
use Livewire\Component;
6+
7+
class DeveloperMenus extends Component
8+
{
9+
public function render()
10+
{
11+
return view('LLoadoutInforce-views::menu-ui.developer-desktop');
12+
}
13+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace LLoadoutInforce\Http\Livewire;
4+
5+
use Livewire\Component;
6+
7+
class DeveloperMenusMobile extends Component
8+
{
9+
public function render()
10+
{
11+
return view('LLoadoutInforce-views::menu-ui.developer-mobile');
12+
}
13+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace LLoadoutInforce\Http\Livewire;
4+
5+
use Livewire\Component;
6+
7+
class UserManagementMenus extends Component
8+
{
9+
public function render()
10+
{
11+
return view('LLoadoutInforce-views::menu-ui.user-desktop');
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace LLoadoutInforce\Http\Livewire;
4+
5+
use Livewire\Component;
6+
7+
class UserManagementMenusMobile extends Component
8+
{
9+
public function render()
10+
{
11+
return view('LLoadoutInforce-views::menu-ui.user-mobile');
12+
}
13+
}

src/LLoadoutInforceServiceProvider.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<?php namespace LLoadoutInforce;
22

33
use Livewire\Livewire;
4-
use LLoadoutInforce\Http\Livewire\Access;
54
use LLoadoutInforce\Http\Livewire\Menu;
5+
use LLoadoutInforce\Http\Livewire\Role;
6+
use LLoadoutInforce\Http\Livewire\User;
7+
use Spatie\LaravelPackageTools\Package;
8+
use LLoadoutInforce\Http\Livewire\Access;
69
use LLoadoutInforce\Http\Livewire\MenusTable;
710
use LLoadoutInforce\Http\Livewire\Navigation;
811
use LLoadoutInforce\Http\Livewire\Permission;
9-
use LLoadoutInforce\Http\Livewire\PermissionsTable;
10-
use LLoadoutInforce\Http\Livewire\Role;
1112
use LLoadoutInforce\Http\Livewire\RolesTable;
12-
use LLoadoutInforce\Http\Livewire\User;
1313
use LLoadoutInforce\Http\Livewire\UsersTable;
14-
use Spatie\LaravelPackageTools\Package;
14+
use LLoadoutInforce\Http\Livewire\PermissionsTable;
15+
use LLoadoutInforce\Http\Livewire\UserManagementMenus;
1516
use Spatie\LaravelPackageTools\PackageServiceProvider;
1617

1718
class LLoadoutInforceServiceProvider extends PackageServiceProvider
@@ -63,6 +64,10 @@ private function loadLivewireComponents()
6364
Livewire::component('menu', Menu::class);
6465
Livewire::component('menus-table', MenusTable::class);
6566
Livewire::component('navigation', Navigation::class);
67+
Livewire::component('user-management-menus', UserManagementMenus::class);
68+
Livewire::component('user-management-menus-mobile', UserManagementMenusMobile::class);
69+
Livewire::component('developer-menus', DeveloperMenus::class);
70+
Livewire::component('developer-menus-mobile', DeveloperMenusMobile::class);
6671

6772
Livewire::component('roles-table', RolesTable::class);
6873
Livewire::component('users-table', UsersTable::class);

0 commit comments

Comments
 (0)