Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
1a4c4e24
Commit
1a4c4e24
authored
Sep 11, 2024
by
Sarun Mungthanya
Browse files
update ui user management
parent
7fe8bcbb
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/Http/Livewire/Pages/User/UserCreate.php
View file @
1a4c4e24
...
@@ -5,21 +5,22 @@ namespace App\Http\Livewire\Pages\User;
...
@@ -5,21 +5,22 @@ namespace App\Http\Livewire\Pages\User;
use
Livewire\Component
;
use
Livewire\Component
;
use
App\Models\User
;
use
App\Models\User
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Hash
;
use
Str
;
class
UserCreate
extends
Component
class
UserCreate
extends
Component
{
{
public
$
name
,
$email
,
$password
,
$password_confirmation
;
public
$
username
,
$first_name
,
$last_name
,
$phone
,
$email
,
$password
,
$password_confirmation
;
public
$description
;
public
$description
;
public
$action
;
public
$action
;
public
$group_lists
;
public
$group_lists
;
protected
$rules
=
[
protected
$rules
=
[
'name'
=>
'required|string|max:255'
,
'
user
name'
=>
'required|string|max:255'
,
'email'
=>
'required|string|email|max:255|unique:users,email'
,
'email'
=>
'required|string|email|max:255|unique:users,email'
,
'password'
=>
'required|string|min:8|confirmed'
,
'password'
=>
'required|string|min:8|confirmed'
,
];
];
protected
$messages
=
[
protected
$messages
=
[
'name.required'
=>
'The name field is required.'
,
'
user
name.required'
=>
'The
user
name field is required.'
,
'email.required'
=>
'The email field is required.'
,
'email.required'
=>
'The email field is required.'
,
'email.email'
=>
'The email must be a valid email address.'
,
'email.email'
=>
'The email must be a valid email address.'
,
'email.unique'
=>
'This email address is already taken.'
,
'email.unique'
=>
'This email address is already taken.'
,
...
@@ -41,8 +42,11 @@ class UserCreate extends Component
...
@@ -41,8 +42,11 @@ class UserCreate extends Component
{
{
$this
->
validate
();
$this
->
validate
();
$UsereData
=
[
$UsereData
=
[
'name'
=>
$this
->
name
,
'username'
=>
$this
->
username
,
'uid'
=>
\
Str
::
random
(
40
),
'first_name'
=>
$this
->
first_name
,
'last_name'
=>
$this
->
last_name
,
'phone'
=>
$this
->
phone
,
'uid'
=>
Str
::
random
(
40
),
'email'
=>
$this
->
email
,
'email'
=>
$this
->
email
,
'password'
=>
Hash
::
make
(
$this
->
password
)
'password'
=>
Hash
::
make
(
$this
->
password
)
];
];
...
@@ -60,17 +64,17 @@ class UserCreate extends Component
...
@@ -60,17 +64,17 @@ class UserCreate extends Component
}
}
$this
->
reset
([
$this
->
reset
([
'name'
,
'email'
,
'description'
,
'group_lists'
'
user
name'
,
'email'
,
'description'
,
'group_lists'
]);
]);
if
(
auth
()
->
guest
())
{
if
(
auth
()
->
guest
())
{
return
redirect
()
->
route
(
'login'
);
// เปลี่ยนเส้นทางไปยังหน้า register
return
redirect
()
->
route
(
'login'
);
}
}
$this
->
emit
(
'showUserList'
,
'User successfully created.'
);
$this
->
emit
(
'showUserList'
,
'User successfully created.'
);
}
}
public
function
goBack
()
public
function
goBack
()
{
{
if
(
auth
()
->
guest
())
{
if
(
auth
()
->
guest
())
{
return
redirect
()
->
route
(
'login'
);
// เปลี่ยนเส้นทางไปยังหน้า register
return
redirect
()
->
route
(
'login'
);
}
}
$this
->
emit
(
'showUserList'
);
$this
->
emit
(
'showUserList'
);
}
}
...
...
app/Http/Livewire/Pages/User/UserEdit.php
View file @
1a4c4e24
...
@@ -11,13 +11,13 @@ class UserEdit extends Component
...
@@ -11,13 +11,13 @@ class UserEdit extends Component
public
$editUserId
;
public
$editUserId
;
public
$userId
;
public
$userId
;
public
$user
;
public
$user
;
public
$username
,
$email
,
$current_password
,
$new_password
,
$new_password_confirmation
,
$changePassword
=
false
;
public
$username
,
$first_name
,
$last_name
,
$phone
,
$email
,
$current_password
,
$new_password
,
$new_password_confirmation
,
$changePassword
=
false
;
public
$group_lists
;
public
$group_lists
;
protected
function
rules
()
protected
function
rules
()
{
{
$rules
=
[
$rules
=
[
'name'
=>
'required|string|max:255'
,
'
user
name'
=>
'required|string|max:255'
,
'email'
=>
'required|string|email|max:255|unique:users,email,'
.
$this
->
user
->
id
,
'email'
=>
'required|string|email|max:255|unique:users,email,'
.
$this
->
user
->
id
,
];
];
...
@@ -30,7 +30,7 @@ class UserEdit extends Component
...
@@ -30,7 +30,7 @@ class UserEdit extends Component
}
}
protected
$messages
=
[
protected
$messages
=
[
'name.required'
=>
'The name field is required.'
,
'
user
name.required'
=>
'The
user
name field is required.'
,
'email.required'
=>
'The email field is required.'
,
'email.required'
=>
'The email field is required.'
,
'email.email'
=>
'The email must be a valid email address.'
,
'email.email'
=>
'The email must be a valid email address.'
,
'email.unique'
=>
'This email address is already taken.'
,
'email.unique'
=>
'This email address is already taken.'
,
...
@@ -45,6 +45,9 @@ class UserEdit extends Component
...
@@ -45,6 +45,9 @@ class UserEdit extends Component
$this
->
editUserId
=
$editUserId
;
$this
->
editUserId
=
$editUserId
;
$this
->
user
=
User
::
findOrFail
(
$editUserId
);
$this
->
user
=
User
::
findOrFail
(
$editUserId
);
$this
->
username
=
$this
->
user
->
username
;
$this
->
username
=
$this
->
user
->
username
;
$this
->
first_name
=
$this
->
user
->
first_name
;
$this
->
last_name
=
$this
->
user
->
last_name
;
$this
->
phone
=
$this
->
user
->
phone
;
$this
->
email
=
$this
->
user
->
email
;
$this
->
email
=
$this
->
user
->
email
;
$this
->
group_lists
=
$this
->
user
->
groups
()
->
pluck
(
'group_id'
)
->
implode
(
','
);
$this
->
group_lists
=
$this
->
user
->
groups
()
->
pluck
(
'group_id'
)
->
implode
(
','
);
}
}
...
@@ -69,7 +72,10 @@ class UserEdit extends Component
...
@@ -69,7 +72,10 @@ class UserEdit extends Component
}
}
$this
->
user
->
username
=
$this
->
username
;
$this
->
user
->
username
=
$this
->
username
;
$this
->
user
->
email
=
$this
->
email
;
$this
->
user
->
email
=
$this
->
email
;
$this
->
first_name
=
$this
->
user
->
first_name
;
$this
->
last_name
=
$this
->
user
->
last_name
;
$this
->
phone
=
$this
->
user
->
phone
;
if
(
$this
->
changePassword
)
{
if
(
$this
->
changePassword
)
{
$this
->
user
->
password
=
Hash
::
make
(
$this
->
new_password
);
$this
->
user
->
password
=
Hash
::
make
(
$this
->
new_password
);
}
}
...
...
app/Http/Livewire/Pages/User/UserIndex.php
View file @
1a4c4e24
...
@@ -15,12 +15,12 @@ class UserIndex extends Component
...
@@ -15,12 +15,12 @@ class UserIndex extends Component
protected
$paginationTheme
=
'bootstrap'
;
protected
$paginationTheme
=
'bootstrap'
;
public
$perPage
=
10
;
public
$perPage
=
10
;
public
$url
;
public
$url
;
public
$searchSelected
=
'name'
;
public
$searchSelected
=
'
user
name'
;
public
$editUserId
;
public
$editUserId
;
public
$deleteUserId
;
public
$deleteUserId
;
public
$keyword
=
''
;
public
$keyword
=
''
;
public
$route
=
''
;
public
$route
=
''
;
public
$selectedOption
=
'name'
;
public
$selectedOption
=
'
user
name'
;
public
$searchBy
;
public
$searchBy
;
public
$menu
;
public
$menu
;
public
$action
=
'list'
;
public
$action
=
'list'
;
...
@@ -39,7 +39,10 @@ class UserIndex extends Component
...
@@ -39,7 +39,10 @@ class UserIndex extends Component
// $this->message = session('message');
// $this->message = session('message');
// $this->showMessage = true;
// $this->showMessage = true;
}
}
public
function
search
()
{
$this
->
resetPage
();
}
public
function
render
()
public
function
render
()
{
{
...
@@ -59,7 +62,7 @@ class UserIndex extends Component
...
@@ -59,7 +62,7 @@ class UserIndex extends Component
]);
]);
}
}
public
function
showUser
Create
Form
()
public
function
showUser
Add
Form
()
{
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'add-user'
]))
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'add-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
$this
->
showNoPermissionModal
=
TRUE
;
...
...
app/Models/User.php
View file @
1a4c4e24
...
@@ -22,6 +22,9 @@ class User extends Authenticatable
...
@@ -22,6 +22,9 @@ class User extends Authenticatable
protected
$dates
=
[
'deleted_at'
];
protected
$dates
=
[
'deleted_at'
];
protected
$fillable
=
[
protected
$fillable
=
[
'username'
,
'username'
,
'first_name'
,
'last_name'
,
'phone'
,
'uid'
,
'uid'
,
'email'
,
'email'
,
'password'
,
'password'
,
...
...
resources/views/components/app-layout.blade.php
View file @
1a4c4e24
...
@@ -53,9 +53,9 @@
...
@@ -53,9 +53,9 @@
</style>
</style>
</head>
</head>
<body
class=
"h-full bg-
slate-150
"
>
<body
class=
"h-full bg-
main-container
"
>
<main
class=
"flex-grow overflow-auto bg-
slate-150
"
>
<main
class=
"flex-grow overflow-auto bg-
main-container
"
>
{{ $slot }}
{{ $slot }}
@yield('content')
@yield('content')
</main>
</main>
...
...
resources/views/livewire/pages/patch/patch-create.blade.php
View file @
1a4c4e24
...
@@ -163,8 +163,8 @@
...
@@ -163,8 +163,8 @@
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"pdesc"
class=
"block text-gray-700"
>
Patch Desciption
</label>
<label
for=
"pdesc"
class=
"block text-gray-700"
>
Patch Desciption
</label>
<
input
type=
"text"
id=
"pdesc"
wire:model.defer=
"PDESC"
<
textarea
id=
"pdesc"
wire:model.defer=
"PDESC"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
rows=
"3"
></textarea
>
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"remark"
class=
"block text-gray-700"
>
Remark
</label>
<label
for=
"remark"
class=
"block text-gray-700"
>
Remark
</label>
...
...
resources/views/livewire/pages/patch/patch-edit.blade.php
View file @
1a4c4e24
...
@@ -265,8 +265,8 @@
...
@@ -265,8 +265,8 @@
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"pdesc"
class=
"block text-gray-700"
>
Patch Description
</label>
<label
for=
"pdesc"
class=
"block text-gray-700"
>
Patch Description
</label>
<
input
type=
"text"
id=
"pdesc"
wire:model.defer=
"PDESC"
<
textarea
id=
"pdesc"
wire:model.defer=
"PDESC"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
rows=
"3"
></textarea
>
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"remark"
class=
"block text-gray-700"
>
Remark
</label>
<label
for=
"remark"
class=
"block text-gray-700"
>
Remark
</label>
...
@@ -276,7 +276,7 @@
...
@@ -276,7 +276,7 @@
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"owner"
class=
"block text-gray-700"
>
Owner
</label>
<label
for=
"owner"
class=
"block text-gray-700"
>
Owner
</label>
<input
type=
"text"
id=
"owner"
wire:model.defer=
"POWNER"
<input
type=
"text"
id=
"owner"
wire:model.defer=
"POWNER"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
value=
"aom"
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"papprovedate"
class=
"block text-gray-700"
>
Papprovedate
</label>
<label
for=
"papprovedate"
class=
"block text-gray-700"
>
Papprovedate
</label>
...
...
resources/views/livewire/pages/user/user-create.blade.php
View file @
1a4c4e24
<div
class=
"grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6"
>
<div
class=
"max-w-lg mx-auto p-8 bg-white shadow-lg rounded-lg"
>
<form
wire:submit.prevent=
"submitForm"
>
<form
wire:submit.prevent=
"submitForm"
>
@csrf
@csrf
<div
class=
"card pb-4"
>
<div
class=
"mb-6"
>
<div
class=
"my-3 flex h-8 items-center justify-between px-4 sm:px-5"
>
<h2
<h2
class=
"font-medium tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base"
>
class=
"font-medium flex items-center tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base"
>
<i
class=
"fa-solid fa-edit text-primary"
></i>
Create
<i
class=
"fa-solid fa-edit text-primary"
></i>
Create
</h2>
</h2>
</div>
<form
class=
"space-y-6"
>
<div
class=
"mb-2"
>
<label
for=
"username"
class=
"block text-sm font-medium text-gray-700"
>
Username:
</label>
<input
type=
"text"
wire:model.defer=
"username"
id=
"username"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('username')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"first_name"
class=
"block text-sm font-medium text-gray-700"
>
Firstname:
</label>
<input
type=
"text"
wire:model.defer=
"first_name"
id=
"first_name"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('first_name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"last_name"
class=
"block text-sm font-medium text-gray-700"
>
Lastname:
</label>
<input
type=
"text"
wire:model.defer=
"last_name"
id=
"last_name"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('last_name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
</div>
<div
class=
"w-3/4 px-3 space-y-3 m-auto mb-4"
>
<div
class=
"flex items-center"
>
<label
class=
"w-2/12 mr-2"
>
<span>
Name :
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
wire:model.defer=
"name"
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
""
name=
"name"
type=
"text"
value=
"{{ old('name') }}"
/>
@error('name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"mb-2"
>
<label
for=
"email"
class=
"block text-sm font-medium text-gray-700"
>
Email:
</label>
<input
type=
"email"
wire:model.email=
"email"
id=
"email"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your email"
>
@error('email')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"phone"
class=
"block text-sm font-medium text-gray-700"
>
Phone:
</label>
<input
type=
"text"
wire:model.defer=
"phone"
id=
"phone"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('phone')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"password"
class=
"block text-sm font-medium text-gray-700"
>
Password:
</label>
<input
type=
"password"
wire:model.password=
"password"
id=
"password"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your password"
>
@error('password')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"flex items-center"
>
<div
class=
"mb-2"
>
<label
class=
"w-2/12 mr-2"
>
<label
for=
"password_confirmation"
class=
"block text-sm font-medium text-gray-700"
>
Confirm
<span>
Email :
</span>
Password:
</label>
</label>
<input
type=
"password"
wire:model.defer=
"password_confirmation"
id=
"password_confirmation"
<span
class=
"relative flex w-full"
>
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
<input
wire:model.email=
"email"
placeholder=
"Confirm your password"
>
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
""
name=
"email"
type=
"text"
value=
"{{ old('email') }}"
/>
@error('email')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"flex items-center"
>
<label
class=
"w-2/12 mr-2"
>
<span>
Password :
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
wire:model.password=
"password"
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
""
name=
"password"
type=
"password"
value=
"{{ old('password') }}"
/>
@error('password')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"flex items-center"
>
<label
class=
"w-2/12 mr-2"
>
<span>
Confirm Password :
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
wire:model.defer=
"password_confirmation"
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
""
name=
"password_confirmation"
type=
"password"
/>
</span>
</div>
@error('password_confirmation')
@error('password_confirmation')
<span
class=
"text-red-500 text-xs"
>
{{ $message }}
</span>
<span
class=
"text-red-500 text-xs"
>
{{ $message }}
</span>
@enderror
@enderror
<div
class=
"flex items-center "
wire:ignore
>
<label
class=
"w-2/12 mr-2"
>
<span>
Add Groups :
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
class=
"mt-1.5 relative flex w-2/4"
wire:ignore
x-data=
"{ groupLists: @entangle('group_lists') }"
x-init=
"groupLists = [];
const tempGroup = pages.groupSelect;
pages.fetchGroups(tempGroup).then(() => {
$el._x_tom = new Tom($el, {
...tempGroup.group,
onChange: (value) => {
groupLists = value;
}
});
})"
type=
"text"
>
</span>
</div>
</div>
</div>
<div
class=
"grid grid-cols-12 justify-center space-x-2 pt-4"
>
<span
wire:click=
"goBack"
<div
wire:ignore
class=
"mb-2"
>
class=
"col-start-4 btn border border-slate-300 font-medium text-slate-800 hover:bg-slate-150 focus:bg-slate-150 active:bg-slate-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90"
>
<label
for=
"group"
class=
"block text-sm font-medium text-gray-700"
>
Add Groups:
</label>
Cancel
<span
class=
"relative flex w-full"
>
<input
class=
"mt-1.5 relative flex w-full"
x-data=
"{ groupLists: @entangle('group_lists') }"
x-init=
"groupLists = [];
const tempGroup = pages.groupSelect;
pages.fetchGroups(tempGroup).then(() => {
$el._x_tom = new Tom($el, {
...tempGroup.group,
onChange: (value) => {
groupLists = value;
}
});
})"
type=
"text"
>
</span>
</span>
<button
type=
"submit"
class=
"btn ml-3 bg-primary font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
>
Save
</button>
</div>
</div>
</div>
</form>
<div
class=
"flex justify-end space-x-4 mt-3"
>
<button
type=
"button"
wire:click=
"goBack"
class=
"px-4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
>
Cancel
</button>
<button
type=
"submit"
type=
"submit"
class=
"px-4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
>
Save
</button>
</div>
</form>
</div>
</div>
resources/views/livewire/pages/user/user-edit.blade.php
View file @
1a4c4e24
<div
class=
"
grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6"
x-data=
"{ changePassword: @entangle('changePassword'), tomGReady: false }"
x-show=
"tomGReady"
>
<div
class=
"
max-w-lg mx-auto p-8 bg-white shadow-lg rounded-lg"
x-data=
"{ changePassword: @entangle('changePassword'), tomGReady: false }"
x-show=
"tomGReady"
>
<form
wire:submit.prevent=
"submitEditForm"
>
<form
wire:submit.prevent=
"submitEditForm"
>
@csrf
@csrf
<div
class=
"card pb-4"
>
<div
class=
"mb-6"
>
<div
class=
"my-3 flex h-8 items-center justify-between px-4 sm:px-5"
>
<h2
<h2
class=
"font-medium tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base"
>
class=
"font-medium flex items-center tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base"
>
<i
class=
"fa-solid fa-edit text-primary"
></i>
Edit User
<i
class=
"fa-solid fa-edit text-primary"
></i>
Edit User
</h2>
</h2>
</div>
</div>
<div
class=
"w-3/4 px-3 space-y-3 m-auto mb-4"
>
<div
class=
"flex items-center"
>
<label
class=
"w-2/12 mr-2"
>
<span>
Name:
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
wire:model.defer=
"name"
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
"Name"
name=
"name"
type=
"text"
/>
@error('name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"flex items-center"
>
<form
class=
"space-y-6"
>
<label
class=
"w-2/12 mr-2"
>
<div
class=
"mb-2"
>
<span>
Email:
</span>
<label
for=
"username"
class=
"block text-sm font-medium text-gray-700"
>
Username:
</label>
</label>
<input
type=
"text"
wire:model.defer=
"username"
id=
"username"
<span
class=
"relative flex w-full"
>
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
<input
wire:model.defer=
"email"
placeholder=
"Enter your name"
>
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
@error('username')
placeholder=
"Email"
name=
"email"
type=
"email"
/>
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@error('email')
@enderror
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
</div>
@enderror
<div
class=
"mb-2"
>
</span>
<label
for=
"first_name"
class=
"block text-sm font-medium text-gray-700"
>
Firstname:
</label>
</div>
<input
type=
"text"
wire:model.defer=
"first_name"
id=
"first_name"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('first_name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"last_name"
class=
"block text-sm font-medium text-gray-700"
>
Lastname:
</label>
<input
type=
"text"
wire:model.defer=
"last_name"
id=
"last_name"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('last_name')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"email"
class=
"block text-sm font-medium text-gray-700"
>
Email:
</label>
<input
type=
"email"
wire:model.email=
"email"
id=
"email"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your email"
>
@error('email')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-2"
>
<label
for=
"phone"
class=
"block text-sm font-medium text-gray-700"
>
Phone:
</label>
<input
type=
"text"
wire:model.defer=
"phone"
id=
"phone"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Enter your name"
>
@error('phone')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</div>
<div
wire:ignore
class=
"mb-2"
>
<label
for=
"group"
class=
"block text-sm font-medium text-gray-700"
>
Add Groups:
</label>
<span
class=
"relative flex w-full"
>
<input
class=
"mt-1.5 relative flex w-full"
wire:ignore
x-data=
"{ groupLists: @entangle('group_lists') }"
x-init=
"groupLists = @js($userGroups);
const tempGroup = pages.groupSelect;
pages.fetchGroups(tempGroup).then(() => {
$el._x_tom = new Tom($el, {
...tempGroup.group,
onChange: (value) => {
groupLists = value;
}
});
$el._x_tom.setValue(groupLists);
tomGReady = true
})"
type=
"text"
>
</span>
</div>
<div
class=
"mb-2"
>
<button
type=
"button"
@
click=
"changePassword = !changePassword"
class=
"btn border bg-gray-300 border-gray-300 font-medium text-gray-800 hover:text-white focus:text-white hover:bg-gray-500 focus:bg-gray-500 active:bg-gray-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90"
>
Change Password
</button>
</div>
<div
x-show=
"changePassword"
>
<div
class=
"mb-2"
>
<label
for=
"current_password"
class=
"block text-sm font-medium text-gray-700"
>
Current Password:
</label>
<input
type=
"password"
wire:model.defer=
"current_password"
id=
"current_password"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Current Password"
>
@error('current_password')
<span
class=
"text-red-500 text-xs"
>
{{ $message }}
</span>
@enderror
<div
class=
"flex items-center "
wire:ignore
>
<span
class=
"w-2/12 mr-2"
>
Add Groups:
</span>
<span
class=
"relative flex w-full"
>
<input
class=
"mt-1.5 relative flex w-1/2"
wire:ignore
x-data=
"{ groupLists: @entangle('group_lists') }"
x-init=
"groupLists = @js($userGroups);
const tempGroup = pages.groupSelect;
pages.fetchGroups(tempGroup).then(() => {
$el._x_tom = new Tom($el, {
...tempGroup.group,
onChange: (value) => {
groupLists = value;
}
});
$el._x_tom.setValue(groupLists);
tomGReady = true
})"
type=
"text"
>
</span>
</div>
<!-- Toggle Button for Change Password -->
<div
class=
"flex items-center"
>
<button
type=
"button"
@
click=
"changePassword = !changePassword"
class=
"btn border bg-gray-300 border-gray-300 font-medium text-gray-800 hover:text-white focus:text-white hover:bg-gray-500 focus:bg-gray-500 active:bg-gray-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90"
>
Change Password
</button>
</div>
</div>
<!-- Password Fields (Hidden by Default) -->
<div
class=
"mb-2"
>
<div
x-show=
"changePassword"
>
<label
for=
"new_password"
class=
"block text-sm font-medium text-gray-700"
>
New Password:
</label>
<div
class=
"flex items-center mt-4"
>
<input
type=
"password"
wire:model.defer=
"new_password"
id=
"new_password"
<label
class=
"w-2/12 mr-2"
>
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
<span>
Current Password:
</span>
placeholder=
"Current Password"
>
</label>
@error('new_password')
<span
class=
"relative flex w-full"
>
<span
class=
"text-red-500 text-xs"
>
{{ $message }}
</span>
<input
wire:model.defer=
"current_password"
@enderror
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
"Current Password"
name=
"current_password"
type=
"password"
/>
</div>
@error('current_password')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"flex items-center mt-4"
>
<div
class=
"mb-2"
>
<label
class=
"w-2/12 mr-2"
>
<label
for=
"new_password_confirmation"
class=
"block text-sm font-medium text-gray-700"
>
Confirm New Password:
</label>
<span>
New Password:
</span>
<input
type=
"password"
wire:model.defer=
"new_password_confirmation"
id=
"new_password_confirmation"
</label>
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
<span
class=
"relative flex w-full"
>
placeholder=
"Current Password"
>
<input
wire:model.defer=
"new_password"
@error('new_password_confirmation')
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
<span
class=
"text-red-500 text-xs"
>
{{ $message }}
</span>
placeholder=
"New Password"
name=
"new_password"
type=
"password"
/>
@enderror
@error('new_password')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
<div
class=
"flex items-center mt-4"
>
<label
class=
"w-2/12 mr-2"
>
<span>
Confirm New Password:
</span>
</label>
<span
class=
"relative flex w-full"
>
<input
wire:model.defer=
"new_password_confirmation"
class=
"form-input w-2/4 rounded-lg border border-slate-300 bg-transparent px-3 py-2 text-xs pl-4 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
"Confirm New Password"
name=
"new_password_confirmation"
type=
"password"
/>
@error('new_password_confirmation')
<span
class=
"text-red-500 text-md self-center ml-4"
>
{{ $message }}
</span>
@enderror
</span>
</div>
</div>
</div>
</div>
</div>
<div
class=
"grid grid-cols-12 justify-center space-x-2 pt-4"
>
<span
wire:click=
"goBack"
<div
class=
"flex justify-end space-x-4 mt-3"
>
class=
"col-start-4 btn border border-slate-300 font-medium text-slate-800 hover:bg-slate-150 focus:bg-slate-150 active:bg-slate-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90"
>
<button
type=
"button"
wire:click=
"goBack"
Cancel
class=
"px-4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
>
Cancel
</button>
</span>
<button
type=
"submit"
type=
"submit"
<button
type=
"submit"
class=
"px-4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
>
Save
</button>
class=
"btn ml-3 bg-primary font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
>
Save
</button>
</div>
</div>
</div>
</form>
</form>
</div>
</div>
resources/views/livewire/pages/user/user-index.blade.php
View file @
1a4c4e24
<div>
<div
class=
"border-0 shadow-none"
>
@include('components.no-permission')
`
<div
wire:loading.class=
""
wire:loading.class.remove=
"hidden"
wire:target=
"save"
class=
"absolute inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden"
>
<div
class=
"flex items-center space-x-4 py-5 lg:py-6 "
>
<div
class=
"flex justify-center items-center "
>
<ul
class=
"hidden flex-wrap items-center space-x-2 sm:flex"
>
<div
class=
"items-center h-100vh"
style=
"align-content: center;"
>
<li
class=
"flex items-center space-x-2"
>
<div
class=
"animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-blue-500"
></div>
<a
class=
"text-primary transition-colors hover:text-primary-focus dark:text-accent-light dark:hover:text-accent"
</div>
href=
"/"
>
Home
</a>
<svg
x-ignore
xmlns=
"http://www.w3.org/2000/svg"
class=
"h-4 w-4"
fill=
"none"
viewBox=
"0 0 24 24"
stroke=
"currentColor"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
d=
"M9 5l7 7-7 7"
/>
</svg>
</li>
<li
class=
"flex items-center space-x-2"
>
<a
class=
"text-primary transition-colors hover:text-primary-focus dark:text-accent-light dark:hover:text-accent"
wire:click=
"$emit('menuClicked', 'User')"
>
User Management
</a>
</li>
</ul>
</div>
@if ($action === 'list')
<div
x-data=
"{ show: @entangle('showMessage'), message: '' }"
x-init=
"window.addEventListener('show-message', event => {
show = true;
message = event.detail.message;
console.log(show, message);
setTimeout(() => { show = false, console.log(show, message); }, 3000);
});"
>
<div
x-show.transition.duration.500ms=
"show"
class=
"fixed top-5 right-5 z-50 bg-green-500 text-white py-2 px-4 rounded-md shadow-lg"
>
{{ $message }}
</div>
</div>
</div>
</div>
<div
x-data=
"{
<div
class=
"m-2"
>
showDeleteListModal: @entangle('showDeleteListModal'),
{{--
<div
wire:loading.class=
"flex"
wire:loading.class.remove=
"hidden"
showAlert: false,
class=
"absolute inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden"
>
toggleGroup(event) {
<div
class=
"flex justify-center items-center "
>
const groupId = event.target.value;
<div
class=
"animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-blue-500"
></div>
if (event.target.checked) {
if (!this.selectedUsersAlpine.includes(groupId)) {
this.selectedUsersAlpine.push(groupId);
}
} else {
this.selectedUsersAlpine = this.selectedUsersAlpine.filter(id => id !== groupId);
}
},
selectedUsersAlpine: [],
selectedUsers: @entangle('selectedUsers')
}"
class=
"grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 "
>
<div
class=
"card pb-4"
>
<div
class=
"my-3 flex h-8 items-center justify-between px-4 sm:px-5"
>
<h2
class=
"font-medium tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base"
>
User Management
</h2>
</div>
</div>
{{-- @include('components/search-by', ['searchBy' => $searchBy ?? []]) --}}
</div>
--}}
<div
class=
"flex justify-between"
>
@if ($action === 'list')
<div
class=
"px-2 ml-4"
>
@if ($message)
<button
wire:click=
"showUserCreateForm()"
<div
class=
"alert alert-success"
>
class=
"btn h-6 w-28 rounded space-x-1 bg-primary px-3 text-xs font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
>
<div
wire:ignore
x-data=
"{ show: true }"
x-init=
"setTimeout(() => show = false, 3000)"
<svg
xmlns=
"http://www.w3.org/2000/svg"
fill=
"none"
viewBox=
"0 0 24 24"
x-show.transition.duration.500ms=
"show"
stroke-width=
"1.5"
stroke=
"currentColor"
class=
"w-3 h-3"
>
class=
"fixed top-5 right-5 z-50 bg-green-500 text-white py-2 px-4 rounded-md shadow-lg"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
{{ $message }}
d=
"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
>
</path>
</svg>
<span>
Create
</span>
</button>
<a
@
click.prevent=
"if (selectedUsersAlpine.length > 0) { showDeleteListModal = true; } else { showAlert = true;}"
class=
"btn h-6 w-28 rounded space-x-1 bg-primary px-3 text-xs font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
fill=
"none"
viewBox=
"0 0 24 24"
stroke-width=
"1.5"
stroke=
"currentColor"
class=
"w-3 h-3"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
d=
"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
>
</path>
</svg>
<span>
Delete
</span>
</a>
</div>
<div
class=
"inline-flex flex-initial"
>
<div
x-data=
"{ isInputActive: true }"
>
<div
class=
"flex gap-3 px-5 items-center"
>
<button
@
click=
"isInputActive = !isInputActive"
class=
"btn h-8 w-10 rounded-full p-0 hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
class=
"h-4.5 w-4.5"
fill=
"none"
viewBox=
"0 0 24 24"
stroke=
"currentColor"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"1.5"
d=
"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>
</button>
<span
class=
"w-64"
x-show=
"isInputActive === true"
>
<input
class=
"form-input h-9 peer w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
placeholder=
"Search Keyword"
type=
"text"
wire:model=
"keyword"
/>
</span>
<span
class=
"w-52"
x-show=
"isInputActive === true"
>
<select
wire:model=
"searchSelected"
class=
"form-select h-9 w-full rounded-lg border border-slate-300 bg-white px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent"
>
@foreach ($searchBy as $key => $by)
<option
value=
"{{ $key }}"
>
{{ $by }}
</option>
@endforeach
</select>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
@endif
@include('livewire.select-atleast-modal')
<div
class=
"grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 bg-main-container rounded-md"
>
<div
class=
"mx-3 mt-3 px-4"
>
<div
class=
"my-1 flex h-8 items-center justify-between px-4 sm:px-5"
>
<div
class=
"is-scrollbar-hidden min-w-full overflow-x-auto"
x-data=
"pages.tables.initExample1"
>
<h2
class=
"text-2xl text-black "
>
<table
class=
"is-hoverable w-full text-left"
>
User Management
<thead>
</h2>
<tr>
<th
class=
"whitespace-nowrap rounded-tl-lg bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
#
</th>
<th
class=
"whitespace-nowrap bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Name
</th>
<th
class=
"whitespace-nowrap bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Email
</th>
<th
class=
"whitespace-nowrap bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Group
</th>
<th
class=
"whitespace-nowrap bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Create Date
</th>
<th
class=
"whitespace-nowrap rounded-tr-lg bg-slate-200 px-4 py-3 font-semibold uppercase text-slate-800 dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Action
</th>
</tr>
</thead>
<tbody>
@foreach ($results as $user)
<tr
class=
"border-y border-transparent border-b-slate-200 dark:border-b-navy-500"
>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
<label
class=
"inline-flex items-center space-x-2"
>
<input
@
change=
"toggleGroup($event)"
class=
"form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary hover:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type=
"checkbox"
wire:model.defer=
"selectedUsers"
value=
"{{ $user->id }}"
/>
</label>
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->username }}
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->email }}
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
@php
$groups = $user->groups->take(5); // Take the first 5 groups
$remainingCount = $user->groups->count() - $groups->count();
@endphp
@foreach ($groups as $group)
<li
class=
"inline-block mr-2 mb-2 px-2 py-1 bg-primary text-white rounded text-xs"
>
{{ $group->name }}
</li>
@endforeach
@if ($remainingCount > 0)
<li
class=
"inline-block px-2 py-1 bg-gray-300 text-gray-700 rounded"
>
+
{{ $remainingCount }} more
</li>
@endif
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->created_at }}
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
<div
class=
"flex justify-center space-x-2"
>
<a
wire:click=
"showUserEditForm({{ $user->id }})"
class=
"btn h-8 w-8 p-0 text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25"
>
<i
class=
"fa fa-edit"
></i>
</a>
<div>
<a
@
click=
"$wire.emit('showDeleteModal', {{ $user->id }})"
class=
"btn h-8 w-8 p-0 text-error hover:bg-error/20 focus:bg-error/20 active:bg-error/25"
>
<i
class=
"fa fa-trash-alt"
></i>
</a>
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div
class=
"pb-4 pt-5 bg-white rounded-lg shadow-lg"
>
<template
x-if=
"showDeleteListModal"
>
<div
class=
"flex justify-between"
>
<div
class=
"fixed inset-0 z-[100] flex flex-col items-center justify-center overflow-hidden px-4 py-6 sm:px-5"
<div
class=
"px-2 ml-4"
>
@
keydown.window.escape=
"showDeleteListModal = false"
>
<button
type=
"button"
class=
"py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus"
<div
class=
"absolute inset-0 bg-slate-900/60 transition-opacity duration-300"
wire:click=
"showUserAddForm"
>
Add
</button>
@
click=
"showDeleteListModal = false"
></div>
</div>
<div
<div
class=
"inline-flex flex-initial"
>
class=
"relative p-4 max-w-lg rounded-lg bg-white px-4 py-10 text-center transition-opacity duration-300 dark:bg-navy-700 sm:px-5"
>
<div
x-data=
"{ isInputActive: true }"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
class=
"inline h-28 w-28 text-error"
<div
class=
"flex gap-4 px-5 items-center"
>
fill=
"none"
viewBox=
"0 0 24 24"
stroke=
"currentColor"
>
<button
@
click=
"isInputActive = !isInputActive"
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
class=
"btn h-8 w-10 rounded-full p-0 hover:bg-primary-focus hover:text-main-container active:text-main-container focus:text-main-container primary-focus hover:text-main-container active:text-main-container focus:text-main-container dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25"
>
d=
"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
class=
"h-4.5 w-4.5"
fill=
"none"
</path>
viewBox=
"0 0 24 24"
stroke=
"currentColor"
>
</svg>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"1.5"
<div
class=
"mt-4 mx-5"
>
d=
"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
<h2
class=
"text-2xl text-slate-700 dark:text-navy-100"
>
</svg>
Are you sure
<br>
you want to delete
<span
</button>
x-text=
"selectedUsersAlpine.length"
></span>
users?
<span
class=
"w-64"
x-show=
"isInputActive === true"
>
</h2>
<input
<p
class=
"mt-2"
></p>
class=
"form-input h-9 peer w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
<button
@
click=
"showDeleteListModal = false"
placeholder=
"Search Keyword"
type=
"text"
wire:model.defer=
"keyword"
/>
class=
"btn mt-6 bg-[#6a6e69] font-medium text-white hover:bg-[#313430] focus:bg-[#313430]-focus active:bg-[#313430]-focus/90"
>
</span>
Close
<span
class=
"w-52"
x-show=
"isInputActive === true"
>
</button>
<select
wire:model.defer=
"searchSelected"
<button
class=
"form-select h-9 w-full rounded-lg border border-slate-300 bg-main-container px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent"
>
@
click=
"$wire.emitSelf('deleteSelected', selectedUsers ); showDeleteListModal = false"
@foreach ($searchBy as $key => $by)
class=
"btn mt-6 bg-error font-medium text-white hover:bg-error-focus focus:bg-error-focus active:bg-error-focus/90"
>
<option
value=
"{{ $key }}"
>
{{ $by }}
</option>
Confirm
@endforeach
</button>
</select>
</span>
<button
type=
"button"
class=
"bg-primary text-white px-4 py-2 rounded hover:bg-primary-focus"
wire:click=
"search"
>
Search
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<div
class=
"mx-3 mt-3 px-4"
>
<div
class=
"is-scrollbar-hidden min-w-full table-responsive"
x-data=
"pages.tables.initExample1"
>
<livewire:delete-modal
/>
<table
class=
"is-hoverable table w-full text-left border-b"
>
{{ $results->links('livewire.paginate-custom') }}
<thead>
<tr>
<th
class=
"whitespace-nowrap rounded-tl-lg bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
#
</th>
<th
class=
"whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Name
</th>
<th
class=
"whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Email
</th>
<th
class=
"whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Group
</th>
<th
class=
"whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Create Date
</th>
<th
class=
"whitespace-nowrap rounded-tr-lg bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5"
>
Action
</th>
</tr>
</thead>
<tbody>
@foreach ($results as $user)
<tr
class=
"border-y border-transparent border-b-slate-200 dark:border-b-navy-500"
>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
<label
class=
"inline-flex items-center space-x-2"
>
<input
@
change=
"toggleGroup($event)"
class=
"form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary hover:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type=
"checkbox"
wire:model.defer=
"selectedUsers"
value=
"{{ $user->id }}"
/>
</label>
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->username }}
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->email }}
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
@php
$groups = $user->groups->take(5);
$remainingCount = $user->groups->count() - $groups->count();
@endphp
@foreach ($groups as $group)
<li
class=
"inline-block mr-2 mb-2 px-2 py-1 bg-primary text-white rounded text-xs"
>
{{ $group->name }}
</li>
@endforeach
@if ($remainingCount > 0)
<li
class=
"inline-block px-2 py-1 bg-gray-300 text-gray-700 rounded"
>
+
{{ $remainingCount }} more
</li>
@endif
</td>
<td
class=
"whitespace-nowrap px-4 py-3 sm:px-5"
>
{{ $user->created_at }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
<div
class=
"flex justify-center space-x-2"
>
<a
wire:click=
"showUserEditForm({{ $user->id }})"
class=
"btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25"
>
<i
class=
"fa fa-edit"
></i>
</a>
<a
@
click=
"$wire.emit('showDeleteModal', {{ $user->id }})"
class=
"btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25"
>
<i
class=
"fa fa-trash"
></i>
</a>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<template
x-if=
"showDeleteListModal"
>
<div
class=
"fixed inset-0 z-[100] flex flex-col items-center justify-center overflow-hidden px-4 py-6 sm:px-5"
@
keydown.window.escape=
"showDeleteListModal = false"
>
<div
class=
"absolute inset-0 bg-slate-900/60 transition-opacity duration-300"
@
click=
"showDeleteListModal = false"
></div>
<div
class=
"relative p-4 max-w-lg rounded-lg bg-white px-4 py-10 text-center transition-opacity duration-300 dark:bg-navy-700 sm:px-5"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
class=
"inline h-28 w-28 text-error"
fill=
"none"
viewBox=
"0 0 24 24"
stroke=
"currentColor"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
d=
"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
>
</path>
</svg>
<div
class=
"mt-4 mx-5"
>
<h2
class=
"text-2xl text-slate-700 dark:text-navy-100"
>
Are you sure
<br>
you want to delete
<span
x-text=
"selectedUsersAlpine.length"
></span>
users?
</h2>
<p
class=
"mt-2"
></p>
<button
@
click=
"showDeleteListModal = false"
class=
"btn mt-6 bg-[#6a6e69] font-medium text-white hover:bg-[#313430] focus:bg-[#313430]-focus active:bg-[#313430]-focus/90"
>
Close
</button>
<button
@
click=
"$wire.emitSelf('deleteSelected', selectedUsers ); showDeleteListModal = false"
class=
"btn mt-6 bg-error font-medium text-white hover:bg-error-focus focus:bg-error-focus active:bg-error-focus/90"
>
Confirm
</button>
</div>
</div>
</div>
</template>
<livewire:delete-modal
/>
{{ $results->links('livewire.paginate-custom') }}
</div>
</div>
</div>
</div>
</div>
@elseif($action === 'create')
<livewire:pages.user.user-create
wire:key=
"user-create"
/>
{{--
<div
class=
"px-4"
>
@elseif($action === 'edit')
<div
x-data=
"pages.basicTable.initGridTable({{ $json_columns }}, {{ $users }}, {{ $paginate }}, '{{ $url }}', {{ json_encode($permission) }})"
></div>
<livewire:pages.user.user-edit
:editUserId=
"$editUserId"
wire:key=
"user-edit"
/>
</div>
--}}
@else
<div></div>
@endif
</div>
</div>
@elseif($action === 'create')
</div>
<livewire:pages.user.user-create
wire:key=
"user-create"
/>
@elseif($action === 'edit')
\ No newline at end of file
<livewire:pages.user.user-edit
:editUserId=
"$editUserId"
wire:key=
"user-edit"
/>
@else
<div></div>
@endif
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment