Update Module Users

This commit is contained in:
Daeng Deni Mardaeni 2023-04-17 12:36:48 +07:00
parent 6c1635804c
commit a3dd7e93de
20 changed files with 637 additions and 2008 deletions

View File

@ -22,24 +22,14 @@ class UsersDataTable extends DataTable
->filter(function ($query) {
$search = request()->get('search');
if ($search['value']!=="") {
$query->where('first_name', 'like', "%" . $search['value'] . "%")
->orWhere('email', 'like', "%" . $search['value'] . "%")
->orWhereRelation('info','phone', 'like', "%" . $search['value'] . "%");
$query->where('name', 'like', "%" . $search['value'] . "%")
->orWhere('email', 'like', "%" . $search['value'] . "%");
}
})
->rawColumns(['first_name','action'])
->rawColumns(['action'])
->addIndexColumn()
->editColumn('first_name', function (User $model) {
return view('pages.users._avatar', compact('model'));
})
->editColumn('email', function (User $model) {
return $model->email;
})
->addColumn('phone', function (User $model) {
return $model->info->phone;
})
->addColumn('action', function (User $model) {
return view('pages.users._action', compact('model'));
return view('pages.users.users._action', compact('model'));
});
}
@ -62,7 +52,7 @@ class UsersDataTable extends DataTable
public function html()
{
return $this->builder()
->setTableId('users-table')
->setTableId('user-users-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(1,'asc')
@ -85,9 +75,8 @@ class UsersDataTable extends DataTable
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('first_name')->title(__('Name')),
Column::make('name')->title(__('Name')),
Column::make('email'),
Column::make('phone'),
Column::computed('action')
->exportable(false)
->printable(false)

View File

@ -1,211 +1,238 @@
<?php
namespace App\Http\Controllers\Users;
namespace App\Http\Controllers\Users;
use App\DataTables\Users\UsersDataTable;
use App\Models\User;
use App\Http\Controllers\Controller;
use App\Models\UserInfo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\Permission;
use Spatie\Permission\Models\Role;
use App\DataTables\Users\UsersDataTable;
use App\Models\Directorat;
use App\Models\User;
use App\Http\Controllers\Controller;
use App\Models\UserInfo;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\Permission;
use Spatie\Permission\Models\Role;
class UsersController extends Controller
class UsersController extends Controller
{
public $user;
public function __construct()
{
public $user;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(UsersDataTable $dataTable)
{
if (is_null($this->user) || !$this->user->can('user.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any users !');
}
return $dataTable->render('pages.users.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('user.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any users !');
}
$roles = Role::all();
return view('pages.users.create', compact('roles'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if (is_null($this->user) || !$this->user->can('user.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any users !');
}
// Validation Data
$request->validate([
'first_name' => 'required|max:50',
'last_name' => 'max:50',
'email' => 'required|max:100|email|unique:users',
'password' => 'required|min:6|confirmed',
'phone' => 'unique:user_infos|numeric'
]);
// Create New User
$user = new User();
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->email = $request->email;
$user->password = Hash::make($request->password);
if($user->save()){
$userInfo = new UserInfo();
$userInfo->user_id = $user->id;
$userInfo->phone = $request->phone;
$userInfo->save();
}
if ($request->roles) {
$user->assignRole($request->roles);
}
session()->flash('success', 'User has been created !!');
return redirect()->route('users.index');
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
if (is_null($this->user) || !$this->user->can('user.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any users !');
}
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
if (is_null($this->user) || !$this->user->can('user.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any users !');
}
$user = User::with(['info'])->find($id);
$roles = Role::all();
return view('pages.users.edit', compact('user', 'roles'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
if (is_null($this->user) || !$this->user->can('user.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any users !');
}
// Create New User
$user = User::find($id);
$userInfo = userInfo::where('user_id', $user->id)->first();
// Validation Data
if ($request->password !== '') {
$request->validate([
'first_name' => 'required|max:50',
'last_name' => 'max:50',
'email' => 'required|max:100|email|unique:users,email,' . $id,
'password' => 'nullable|min:6|confirmed',
'phone' => 'numeric|unique:user_infos,phone,'.$userInfo->id
]);
} else {
$request->validate([
'first_name' => 'required|max:50',
'last_name' => 'max:50',
'email' => 'required|max:100|email|unique:users,email,' . $id,
'phone' => 'numeric|unique:user_infos,phone,'.$userInfo->id
]);
}
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->email = $request->email;
if ($request->password) {
$user->password = Hash::make($request->password);
}
if($user->save()){
$userInfo->phone = $request->phone;
$userInfo->save();
}
$user->roles()->detach();
if ($request->roles) {
$user->assignRole($request->roles);
}
session()->flash('success', 'User has been updated !!');
return redirect()->route('users.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if (is_null($this->user) || !$this->user->can('user.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any users !');
}
$user = User::find($id);
$info = UserInfo::where(['user_id' => $user->id])->first();
if (!is_null($user)) {
$user->delete();
$info->delete();
}
session()->flash('success', 'User has been deleted !!');
return redirect()->route('users.index');
}
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(UsersDataTable $dataTable)
{
/*if (is_null($this->user) || !$this->user->can('user.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any users !');
}*/
addVendor('chained-select');
$directorat = Directorat::all();
$roles = Role::all();
return $dataTable->render('pages.users.users.index', compact('directorat', 'roles'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
/* if (is_null($this->user) || !$this->user->can('user.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any users !');
}*/
$roles = Role::all();
return view('pages.users.create', compact('roles'));
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Request $request)
{
/* if (is_null($this->user) || !$this->user->can('user.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any users !');
}*/
// Validation Data
$request->password = 'bagbag';
$validated = $request->validate([
'name' => 'required|max:50',
'email' => 'required|max:100|email|unique:users'
]);
if ($validated) {
try {
// Create New User
$user = new User();
$user->name = $request->name;
$user->email = $request->email;
$user->directorat_id = $request->directorat_id;
$user->sub_directorat_id = $request->sub_directorat_id;
$user->password = Hash::make($request->password);
$user->save();
if ($request->roles) {
$user->assignRole($request->roles);
}
echo json_encode([
'status' => 'success',
'message' => 'User Created Successfully'
]);
} catch (Exception $e) {
echo json_encode([
'status' => 'error',
'message' => $e->getMessage()
]);
}
}
return false;
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
/*if (is_null($this->user) || !$this->user->can('user.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any users !');
}*/
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
/*if (is_null($this->user) || !$this->user->can('user.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any users !');
}*/
$user = User::find($id);
$roles = $user->roles;
echo json_encode([
'status' => 'success',
'data' => $user,
'roles' => $roles
]);
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
*
* @return Response
*/
public function update(Request $request, $id)
{
/* if (is_null($this->user) || !$this->user->can('user.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any users !');
}*/
// Create New User
$user = User::find($id);
// Validation Data
if ($request->password !== '') {
$validated = $request->validate([
'name' => 'required|max:50',
'email' => 'required|max:100|email|unique:users,email,' . $id,
'password' => 'nullable|min:6|confirmed'
]);
} else {
$validated = $request->validate([
'name' => 'required|max:50',
'email' => 'required|max:100|email|unique:users,email,' . $id
]);
}
if ($validated) {
try {
$user->name = $request->name;
$user->email = $request->email;
$user->directorat_id = $request->directorat_id;
$user->sub_directorat_id = $request->sub_directorat_id;
if ($request->password) {
$user->password = Hash::make($request->password);
}
$user->save();
$user->roles()->detach();
if ($request->roles) {
$user->assignRole($request->roles);
}
echo json_encode([
'status' => 'success',
'message' => 'User Updated Successfully'
]);
} catch (Exception $e) {
echo json_encode([
'status' => 'error',
'message' => $e->getMessage()
]);
}
}
return false;
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy(User $user)
{
/*if (is_null($this->user) || !$this->user->can('user.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any users !');
}*/
$user->delete();
echo json_encode([
'status' => 'success',
'message' => 'User Deleted Successfully'
]);
}
}

View File

@ -7,10 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use Wildside\Userstamps\Userstamps;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens, HasFactory, Notifiable, Userstamps;
use HasRoles;
/**
* The attributes that are mass assignable.
@ -21,6 +24,8 @@ class User extends Authenticatable
'name',
'email',
'password',
'directorat_id',
'sub_directorat_id',
];
/**

View File

@ -15,6 +15,8 @@ return new class extends Migration
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->foreignIdFor('App\Models\Directorat', 'directorat_id')->nullable();
$table->foreignIdFor('App\Models\SubDirectorat', 'sub_directorat_id')->nullable();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();

View File

@ -7,7 +7,7 @@
<!--begin::Title-->
<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0 text-capitalize">
@if(count($route) > 1)
@if($route[1] !== 'index')
@if($route[1] !== 'index' && $route[1] !== 'users')
{{ $route[1] }}
@endif
@endif
@ -28,7 +28,7 @@
<!--end::Item-->
@if(count($route) > 1)
@if($route[1] !== 'index')
@if($route[1] !== 'index' && $route[1] !=='users')
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</li>
<!--end::Item-->
@ -40,6 +40,10 @@
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[1])).' '.ucfirst(str_replace('-',' ',$route[0]))}}</li>
<!--end::Item-->
@else
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</li>
<!--end::Item-->
@endif
@else
<!--begin::Item-->

View File

@ -16,13 +16,23 @@
</div>
<!--end::Actions-->
@elseif(isset($route[2]) && $route[2] == 'index' && $route[0] == 'user')
<!--begin::Actions-->
<div class="d-flex align-items-center gap-2 gap-lg-3">
<!--begin::Primary button-->
<a href="{{ route($route[0].'.'.$route[1].'.create') }}" class="btn btn-sm fw-bold btn-primary text-capitalize" data-bs-toggle="modal" data-bs-target="#kt_modal_{{ $route[0] }}_{{ $route[1] }}">Add {{ str_replace('-',' ',$route[1]) }} {{ str_replace('-',' ',$route[0]) }}</a>
<!--end::Primary button-->
</div>
<!--end::Actions-->
@if($route[1]!=='users')
<!--begin::Actions-->
<div class="d-flex align-items-center gap-2 gap-lg-3">
<!--begin::Primary button-->
<a href="{{ route($route[0].'.'.$route[1].'.create') }}" class="btn btn-sm fw-bold btn-primary text-capitalize" data-bs-toggle="modal" data-bs-target="#kt_modal_{{ $route[0] }}_{{ $route[1] }}">Add {{ str_replace('-',' ',$route[1]) }} {{ str_replace('-',' ',$route[0]) }}</a>
<!--end::Primary button-->
</div>
<!--end::Actions-->
@else
<!--begin::Actions-->
<div class="d-flex align-items-center gap-2 gap-lg-3">
<!--begin::Primary button-->
<a href="{{ route($route[0].'.'.$route[1].'.create') }}" class="btn btn-sm fw-bold btn-primary text-capitalize" data-bs-toggle="modal" data-bs-target="#kt_modal_{{ $route[0] }}_{{ $route[1] }}">Add {{ str_replace('-',' ',$route[1]) }}</a>
<!--end::Primary button-->
</div>
<!--end::Actions-->
@endif
@endif
</div>
<!--end::Toolbar container-->

View File

@ -1,41 +1,5 @@
<!--begin::Navbar-->
<div class="app-navbar flex-shrink-0">
<!--begin::Search-->
<div class="app-navbar-item align-items-stretch ms-1 ms-md-3">
@include(config('settings.KT_THEME_LAYOUT_DIR').'/partials/sidebar-layout/search/_dropdown')
</div>
<!--end::Search-->
<!--begin::Activities-->
<div class="app-navbar-item ms-1 ms-md-3">
<!--begin::Drawer toggle-->
<div class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-30px h-30px w-md-40px h-md-40px" id="kt_activities_toggle">{!! getIcon('chart-simple', 'fs-2 fs-md-1') !!}</div>
<!--end::Drawer toggle-->
</div>
<!--end::Activities-->
<!--begin::Notifications-->
<div class="app-navbar-item ms-1 ms-md-3">
<!--begin::Menu- wrapper-->
<div class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-30px h-30px w-md-40px h-md-40px" data-kt-menu-trigger="{default: 'click', lg: 'hover'}" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end" id="kt_menu_item_wow">{!! getIcon('element-plus', 'fs-2 fs-md-1') !!}</div>
@include('partials/menus/_notifications-menu')
<!--end::Menu wrapper-->
</div>
<!--end::Notifications-->
<!--begin::Chat-->
<div class="app-navbar-item ms-1 ms-md-3">
<!--begin::Menu wrapper-->
<div class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-30px h-30px w-md-40px h-md-40px position-relative" id="kt_drawer_chat_toggle">{!! getIcon('message-text-2', 'fs-2 fs-md-1') !!}
<span class="bullet bullet-dot bg-success h-6px w-6px position-absolute translate-middle top-0 start-50 animation-blink"></span></div>
<!--end::Menu wrapper-->
</div>
<!--end::Chat-->
<!--begin::My apps links-->
<div class="app-navbar-item ms-1 ms-md-3">
<!--begin::Menu wrapper-->
<div class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-30px h-30px w-md-40px h-md-40px" data-kt-menu-trigger="{default: 'click', lg: 'hover'}" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end">{!! getIcon('element-11', 'fs-2 fs-md-1') !!}</div>
@include('partials/menus/_my-apps-menu')
<!--end::Menu wrapper-->
</div>
<!--end::My apps links-->
<!--begin::Theme mode-->
<div class="app-navbar-item ms-1 ms-md-3">
@include('partials/theme-mode/_main')

View File

@ -1,14 +1,13 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
@if(Auth::user()->can('user.update'))
<a href="{{ route('users.edit',['user' => $model->id]) }}"
class="btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1">
{!! theme()->getSvgIcon("icons/duotune/art/art005.svg", "svg-icon-3") !!}
<a href="{{ route($route[0].'.'.$route[1].'.edit',['user' => $model->id]) }}"
class="kt_edit_form btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1">
{!! getIcon("pencil", "fs-1 text-info","duotune") !!}
</a>
@endif
@if(Auth::user()->can('user.delete'))
{!! Form::open(['method' => 'DELETE','route' => ['users.destroy', $model->id],'class'=>'']) !!}
{{ Form::button(theme()->getSvgIcon("icons/duotune/general/gen027.svg", "svg-icon-3"), ['type' => 'submit', 'class' => 'delete btn btn-icon btn-bg-light btn-active-light-danger btn-sm'] ) }}
{!! Form::open(['method' => 'DELETE','route' => [$route[0].'.'.$route[1].'.destroy', $model->id],'class'=>'']) !!}
{{ Form::button(getIcon("trash", "fs-1 text-danger","duotune"), ['type' => 'submit', 'class' => 'delete btn btn-icon btn-bg-light btn-active-light-danger btn-sm'] ) }}
{!! Form::close() !!}
@endif
</div>

View File

@ -1,9 +0,0 @@
<div class="d-flex align-items-center">
<div class="symbol symbol-45px me-5">
<img src="{{ $model->getAvatarUrlAttribute() }}" alt=""/>
</div>
<div class="d-flex justify-content-start flex-column">
<a href="#" class="text-dark fw-bolder text-hover-primary fs-6">{{ $model->first_name.' '.$model->last_name }}</a>
</div>
</div>

View File

@ -1,5 +0,0 @@
<td>
<div class="form-check form-check-sm form-check-custom form-check-solid">
<input class="form-check-input widget-9-check" name="id[]" type="checkbox" value="{{ $model->id() }}"/>
</div>
</td>

View File

@ -1,154 +0,0 @@
<form id="kt_modal_add_user_form" method="POST" class="form" action="{{ route('users.store') }}">
{{ csrf_field() }}
<!--begin::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_user_scroll" data-kt-scroll="true"
data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto"
data-kt-scroll-dependencies="#kt_modal_add_user_header" data-kt-scroll-wrappers="#kt_modal_add_user_scroll"
data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">First Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="first_name"
class="form-control form-control-solid mb-3 mb-lg-0 @error('first_name') is-invalid @enderror"
placeholder="First name" value=""/>
</div>
@error('first_name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Last Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="last_name"
class="form-control form-control-solid mb-3 mb-lg-0 @error('last_name') is-invalid @enderror"
placeholder="Last name" value=""/>
</div>
@error('last_name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Email</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="email" name="email"
class="form-control form-control-solid mb-3 mb-lg-0 @error('email') is-invalid @enderror"
placeholder="example@domain.com" value=""/>
</div>
@error('email')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Phone</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="phone"
class="form-control form-control-solid mb-3 mb-lg-0 @error('phone') is-invalid @enderror"
placeholder="081234567890" value=""/>
</div>
@error('phone')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Password</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="password" name="password"
class="form-control form-control-solid mb-3 mb-lg-0 @error('password') is-invalid @enderror"
value=""/>
</div>
<!--end::Input-->
</div>
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Confirm Password</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="password"
class="form-control form-control-solid mb-3 mb-lg-0 @error('password') is-invalid @enderror"
value="" name="password_confirmation" autocomplete="current-password"/>
</div>
@error('password')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<div class="mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-5">Role</label>
<!--end::Label-->
<!--begin::Roles-->
@php $n = 1; @endphp
@foreach($roles as $role)
<!--begin::Input row-->
<div class="d-flex fv-row">
<!--begin::Radio-->
<div class="form-check form-check-custom form-check-solid">
<!--begin::Input-->
<input class="form-check-input me-3" name="roles" type="radio" value="{{ $role->id }}"
id="{{ Str::slug($role->name,'-') }}" checked="checked">
<!--end::Input-->
<!--begin::Label-->
<label class="form-check-label" for="{{ Str::slug($role->name,'-') }}">
<div class="fw-bolder text-gray-800 text-capitalize">{{ $role->name }}</div>
</label>
<!--end::Label-->
</div>
<!--end::Radio-->
</div>
@if($n < count($roles))
<div class="separator separator-dashed my-5"></div>
@endif
<!--end::Input row-->
@php $n++; @endphp
@endforeach
<!--end::Roles-->
</div>
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-kt-users-modal-action="cancel">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-users-modal-action="submit">
<span class="indicator-label">Submit</span>
<span class="indicator-progress">Please wait...
<span
class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
</button>
</div>
<!--end::Actions-->
</form>

View File

@ -1,140 +0,0 @@
<form id="kt_modal_add_user_form" method="POST" class="form" action="{{ route('users.update',['user' => $user->id]) }}">
@method('PUT')
{{ csrf_field() }}
<!--begin::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_user_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_user_header" data-kt-scroll-wrappers="#kt_modal_add_user_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">First Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="first_name" class="form-control form-control-solid mb-3 mb-lg-0 @error('first_name') is-invalid @enderror" placeholder="First name" value="{{ $user->first_name ?? '' }}" />
</div>
@error('first_name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Last Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="last_name" class="form-control form-control-solid mb-3 mb-lg-0 @error('last_name') is-invalid @enderror" placeholder="Last name" value="{{ $user->last_name ?? '' }}" />
</div>
@error('last_name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Email</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="email" name="email" class="form-control form-control-solid mb-3 mb-lg-0 @error('email') is-invalid @enderror" placeholder="example@domain.com" value="{{ $user->email ?? '' }}" />
</div>
@error('email')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Phone</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="phone" class="form-control form-control-solid mb-3 mb-lg-0 @error('phone') is-invalid @enderror" placeholder="081234567890" value="{{ $user->info->phone ?? '' }}" />
</div>
@error('phone')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="row fv-row">
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Password</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="password" name="password" class="form-control form-control-solid mb-3 mb-lg-0 @error('password') is-invalid @enderror" value="" />
</div>
<!--end::Input-->
</div>
<div class="fv-row col-6 mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Confirm Password</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="password" class="form-control form-control-solid mb-3 mb-lg-0 @error('password') is-invalid @enderror" value="" name="password_confirmation" />
</div>
@error('password')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
</div>
<!--end::Input group-->
<div class="mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-5">Role</label>
<!--end::Label-->
<!--begin::Roles-->
@php $n = 1; @endphp
@foreach($roles as $role)
<!--begin::Input row-->
<div class="d-flex fv-row">
<!--begin::Radio-->
<div class="form-check form-check-custom form-check-solid">
<!--begin::Input-->
<input class="form-check-input me-3" name="roles" type="radio" value="{{ $role->id }}"
id="{{ Str::slug($role->name,'-') }}" {{ $user->hasRole($role->name) ? 'checked="checked"' : '' }}>
<!--end::Input-->
<!--begin::Label-->
<label class="form-check-label" for="{{ Str::slug($role->name,'-') }}">
<div class="fw-bolder text-gray-800 text-capitalize">{{ $role->name }}</div>
</label>
<!--end::Label-->
</div>
<!--end::Radio-->
</div>
@if($n < count($roles))
<div class="separator separator-dashed my-5"></div>
@endif
<!--end::Input row-->
@php $n++; @endphp
@endforeach
<!--end::Roles-->
</div>
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-kt-users-modal-action="cancel">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-users-modal-action="submit">
<span class="indicator-label">Submit</span>
<span class="indicator-progress">Please wait...
<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
</button>
</div>
<!--end::Actions-->
</form>

View File

@ -0,0 +1,142 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_users" tabindex="-1" aria-hidden="true">
<!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered mw-650px">
<!--begin::Modal content-->
<div class="modal-content rounded">
<!--begin::Modal header-->
<div class="modal-header pb-0 border-0 justify-content-end">
<!--begin::Close-->
<div class="btn btn-sm btn-icon btn-active-color-primary"
data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div>
<!--end::Close-->
</div>
<!--begin::Modal header-->
<!--begin::Modal body-->
<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
<!--begin:Form-->
<form class="form_{{$route[0].'_'.$route[1]}}" method="POST"
action="{{ route($route[0].'.'.$route[1].'.store') }}">
@csrf
<!--begin::Heading-->
<div class="mb-13 text-center">
<!--begin::Title-->
<h1 class="mb-3 text-capitalize"
id="title_form">{{ str_replace('-',' ',$route[0].' '.$route[1]) }}</h1>
<!--end::Title-->
</div>
<!--end::Heading-->
<!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label-->
<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
<span class="required">Name</span>
<span class="ms-1" data-bs-toggle="tooltip"
title="Specify a target name for future usage and reference"></span>
</label>
<!--end::Label-->
<input type="hidden" id="user_users_id" name="id"/>
<input type="text" id="user_users_name" maxlength="50" class="form-control form-control-solid"
placeholder="Enter User Name" name="name"/>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label-->
<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
<span class="required">Email</span>
<span class="ms-1" data-bs-toggle="tooltip"
title="Specify a target name for future usage and reference"></span>
</label>
<!--end::Label-->
<input type="email" id="user_users_email" maxlength="50" class="form-control form-control-solid"
placeholder="Enter User Email" name="email"/>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label-->
<label class="d-flex align-items-center fs-6 fw-semibold mb-2" for="directorat_id">
<span class="required">Directorat</span>
<span class="ms-1" data-bs-toggle="tooltip"
title="Specify a target name for future usage and reference"></span>
</label>
<!--end::Label-->
<select class="form-select" name="directorat_id" id="directorat_id">
<option>Select Directorat</option>
@foreach($directorat as $item)
<option value="{{$item->id}}">{{$item->name}}</option>
@endforeach
</select>
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label-->
<label class="d-flex align-items-center fs-6 fw-semibold mb-2" for="sub_directorat_id">
<span class="required">Sub Directorat</span>
<span class="ms-1" data-bs-toggle="tooltip"
title="Specify a target name for future usage and reference"></span>
</label>
<!--end::Label-->
<select class="form-select" name="sub_directorat_id" id="sub_directorat_id">
<option>Select Sub Directorat</option>
</select>
</div>
<!--end::Input group-->
<div class="mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-5">Role</label>
<!--end::Label-->
<!--begin::Roles-->
@php $n = 1; @endphp
@foreach($roles as $role)
<!--begin::Input row-->
<div class="d-flex fv-row">
<!--begin::Radio-->
<div class="form-check form-check-custom form-check-solid">
<!--begin::Input-->
<input class="form-check-input me-3" name="roles" type="radio"
value="{{ $role->id }}"
id="role_{{ Str::slug($role->name,'-') }}">
<!--end::Input-->
<!--begin::Label-->
<label class="form-check-label" for="{{ Str::slug($role->name,'-') }}">
<div class="fw-bolder text-gray-800 text-capitalize">{{ $role->name }}</div>
</label>
<!--end::Label-->
</div>
<!--end::Radio-->
</div>
@if($n < count($roles))
<div class="separator separator-dashed my-5"></div>
@endif
<!--end::Input row-->
@php $n++; @endphp
@endforeach
<!--end::Roles-->
</div>
<!--begin::Actions-->
<div class="text-center">
<button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
<!--end::Actions-->
</form>
<!--end:Form-->
</div>
<!--end::Modal body-->
</div>
<!--end::Modal content-->
</div>
<!--end::Modal dialog-->
</div>
<!--end::Modal - New Target-->

View File

@ -8,14 +8,87 @@
@endsection
@push('customscript')
@php
$route = explode('.', Route::currentRouteName());
@endphp
<script>
$("#searchbox").on("keyup search input paste cut", function() {
LaravelDataTables["users-table"].search(this.value).draw();
$("#searchbox").on("keyup search input paste cut", function () {
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].search(this.value).draw();
});
$(function(){
LaravelDataTables["users-table"].on('click','.delete',function(event){
var form = $(this).closest("form");
$(function () {
const documentTitle = '{{ ucfirst($route[0].' '.$route[1]) }} Report';
var buttons = new $.fn.dataTable.Buttons(LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"], {
buttons: [
{
extend: 'copyHtml5',
title: documentTitle
},
{
extend: 'excelHtml5',
title: documentTitle
},
{
extend: 'csvHtml5',
title: documentTitle
},
{
extend: 'pdfHtml5',
title: documentTitle
},
{
extend: 'print',
title: documentTitle
}
]
}).container().appendTo($('#kt_datatable_example_buttons'));
// Hook dropdown menu click event to datatable export buttons
const exportButtons = document.querySelectorAll('#kt_datatable_example_export_menu [data-kt-export]');
exportButtons.forEach(exportButton => {
exportButton.addEventListener('click', e => {
e.preventDefault();
console.log(e.target.getAttribute('data-kt-export'));
// Get clicked export value
const exportValue = e.target.getAttribute('data-kt-export');
const target = document.querySelector('.dt-buttons .buttons-' + exportValue);
// Trigger click event on hidden datatable export buttons
target.click();
});
});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click','.kt_edit_form',function(event){
event.preventDefault();
$.ajax({
url: $(this).attr('href'),
type: 'GET',
dataType: 'json',
success: function (response) {
console.log(response);
$('#title_form').text('Edit {{ ucfirst(str_replace('-',' ',$route[0].' '.$route[1])) }}');
$('#directorat_id').val(response.data.directorat_id).change();
$('#sub_directorat_id').val(response.data.directorat_id).change();
$('#{{$route[0].'_'.$route[1]}}_id').val(response.data.id);
$('#{{$route[0].'_'.$route[1]}}_name').val(response.data.name);
$('#{{$route[0].'_'.$route[1]}}_email').val(response.data.email);
if(response.data.roles.length > 0){
var role = response.data.roles[0].name;
var _role = role.replace(' ','-').toLowerCase();
$("#role_"+_role).prop('checked', true);
}
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.data.id).append('<input type="hidden" name="_method" value="PUT">');
$('#kt_modal_{{$route[0].'_'.$route[1]}}').modal('show');
}
})
})
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click', '.delete', function (event) {
var form = $(this).closest("form");
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
@ -27,12 +100,17 @@
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
Swal.fire(
'Deleted!',
'User has been deleted.',
'success'
)
$.ajax({
type: "POST",
url: form.attr('action'),
data: form.serialize(), // serializes the form's elements.
success: function(data)
{
toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
}
});
}
})
})
@ -40,7 +118,6 @@
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {

View File

@ -1,29 +0,0 @@
<x-base-layout>
<!--begin::Card-->
<div class="card card-xxl-stretch mb-5 mb-xl-8">
<!--begin::Card body-->
<div class="card-header border-0 pt-5">
<h3 class="card-title align-items-start flex-column">
Add User
</h3>
<div class="card-toolbar" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-trigger="hover" title=""
data-bs-original-title="Click to cancel">
<a href="{{ route('users.index') }}" class="btn btn-sm btn-light-primary">
<!--begin::Svg Icon | path: assets/media/icons/duotune/arrows/arr079.svg-->
<span class="svg-icon svg-icon-muted svg-icon-2hx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path opacity="0.5" d="M14.2657 11.4343L18.45 7.25C18.8642 6.83579 18.8642 6.16421 18.45 5.75C18.0358 5.33579 17.3642 5.33579 16.95 5.75L11.4071 11.2929C11.0166 11.6834 11.0166 12.3166 11.4071 12.7071L16.95 18.25C17.3642 18.6642 18.0358 18.6642 18.45 18.25C18.8642 17.8358 18.8642 17.1642 18.45 16.75L14.2657 12.5657C13.9533 12.2533 13.9533 11.7467 14.2657 11.4343Z" fill="currentColor"/>
<path d="M8.2657 11.4343L12.45 7.25C12.8642 6.83579 12.8642 6.16421 12.45 5.75C12.0358 5.33579 11.3642 5.33579 10.95 5.75L5.40712 11.2929C5.01659 11.6834 5.01659 12.3166 5.40712 12.7071L10.95 18.25C11.3642 18.6642 12.0358 18.6642 12.45 18.25C12.8642 17.8358 12.8642 17.1642 12.45 16.75L8.2657 12.5657C7.95328 12.2533 7.95328 11.7467 8.2657 11.4343Z" fill="currentColor"/>
</svg></span>
<!--end::Svg Icon-->
Cancel
</a>
</div>
</div>
<div class="card-body pt-6">
@include('pages.users._createform')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-base-layout>

View File

@ -1,29 +0,0 @@
<x-base-layout>
<!--begin::Card-->
<div class="card card-xxl-stretch mb-5 mb-xl-8">
<!--begin::Card body-->
<div class="card-header border-0 pt-5">
<h3 class="card-title align-items-start flex-column">
Edit User {{ $user->first_name.' '.$user->last_name }}
</h3>
<div class="card-toolbar" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-trigger="hover" title=""
data-bs-original-title="Click to cancel">
<a href="{{ route('users.index') }}" class="btn btn-sm btn-light-primary">
<!--begin::Svg Icon | path: assets/media/icons/duotune/arrows/arr079.svg-->
<span class="svg-icon svg-icon-muted svg-icon-2hx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path opacity="0.5" d="M14.2657 11.4343L18.45 7.25C18.8642 6.83579 18.8642 6.16421 18.45 5.75C18.0358 5.33579 17.3642 5.33579 16.95 5.75L11.4071 11.2929C11.0166 11.6834 11.0166 12.3166 11.4071 12.7071L16.95 18.25C17.3642 18.6642 18.0358 18.6642 18.45 18.25C18.8642 17.8358 18.8642 17.1642 18.45 16.75L14.2657 12.5657C13.9533 12.2533 13.9533 11.7467 14.2657 11.4343Z" fill="currentColor"/>
<path d="M8.2657 11.4343L12.45 7.25C12.8642 6.83579 12.8642 6.16421 12.45 5.75C12.0358 5.33579 11.3642 5.33579 10.95 5.75L5.40712 11.2929C5.01659 11.6834 5.01659 12.3166 5.40712 12.7071L10.95 18.25C11.3642 18.6642 12.0358 18.6642 12.45 18.25C12.8642 17.8358 12.8642 17.1642 12.45 16.75L8.2657 12.5657C7.95328 12.2533 7.95328 11.7467 8.2657 11.4343Z" fill="currentColor"/>
</svg></span>
<!--end::Svg Icon-->
Cancel
</a>
</div>
</div>
<div class="card-body pt-6">
@include('pages.users._editform')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-base-layout>

View File

@ -1,50 +1,141 @@
<x-base-layout>
@php
$route = explode('.', Route::currentRouteName());
@endphp
<x-default-layout>
<!--begin::Card-->
<div class="card card-xxl-stretch mb-5 mb-xl-8">
<!--begin::Card body-->
<div class="card-header border-0 pt-5">
<h3 class="card-title align-items-start flex-column">
<div class="card-title align-items-start flex-column">
<div class="d-flex align-items-center position-relative my-1">
<!--begin::Svg Icon | path: icons/duotune/general/gen021.svg-->
<span class="svg-icon svg-icon-1 position-absolute ms-6">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546"
height="2" rx="1" transform="rotate(45 17.0365 15.1223)"
fill="currentColor"></rect>
<path
d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z"
fill="currentColor"></path>
</svg>
</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546" height="2" rx="1"
transform="rotate(45 17.0365 15.1223)" fill="currentColor"></rect>
<path
d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z"
fill="currentColor"></path>
</svg>
</span>
<!--end::Svg Icon-->
<input type="text" id="searchbox" class="form-control form-control-solid w-250px ps-15"
placeholder="Search Users">
<input type="text" id="searchbox"
class="form-control form-control-solid border border-gray-300 w-250px ps-15"
placeholder="Search User">
</div>
</h3>
<!--begin::Export buttons-->
<div id="kt_datatable_example_1_export" class="d-none"></div>
<!--end::Export buttons-->
</div>
<div class="card-toolbar">
<!--begin::Export dropdown-->
<button type="button" class="btn btn-light-primary" data-kt-menu-trigger="click"
data-kt-menu-placement="bottom-end">
<i class="ki-duotone ki-exit-down fs-2"><span class="path1"></span><span class="path2"></span></i>
Export Report
</button>
<!--begin::Menu-->
<div id="kt_datatable_example_export_menu"
class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-600 menu-state-bg-light-primary fw-semibold fs-7 w-200px py-4"
data-kt-menu="true">
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-3" data-kt-export="copy">
Copy to clipboard
</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-3" data-kt-export="excel">
Export as Excel
</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-3" data-kt-export="csv">
Export as CSV
</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-3" data-kt-export="pdf">
Export as PDF
</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-3" data-kt-export="print">
Print
</a>
</div>
<!--end::Menu item-->
</div>
<!--begin::Hide default export buttons-->
<div id="kt_datatable_example_buttons" class="d-none"></div>
<!--end::Hide default export buttons-->
@if(Auth::user()->can('user.create'))
<div class="card-toolbar" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-trigger="hover" title=""
data-bs-original-title="Click to add a user">
<a href="{{ route('users.create') }}" class="btn btn-sm btn-light-primary">
<!--begin::Svg Icon | path: /var/www/preview.keenthemes.com/kt-products/metronic/releases/2022-07-14-092914/core/html/src/media/icons/duotune/arrows/arr013.svg-->
<span class="svg-icon svg-icon-muted svg-icon-2hx">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.3" d="M11 13H7C6.4 13 6 12.6 6 12C6 11.4 6.4 11 7 11H11V13ZM17 11H13V13H17C17.6 13 18 12.6 18 12C18 11.4 17.6 11 17 11Z" fill="currentColor"/>
<path d="M22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2C17.5 2 22 6.5 22 12ZM17 11H13V7C13 6.4 12.6 6 12 6C11.4 6 11 6.4 11 7V11H7C6.4 11 6 11.4 6 12C6 12.6 6.4 13 7 13H11V17C11 17.6 11.4 18 12 18C12.6 18 13 17.6 13 17V13H17C17.6 13 18 12.6 18 12C18 11.4 17.6 11 17 11Z" fill="currentColor"/>
</svg>
</span>
<!--end::Svg Icon-->
New User
</a>
</div>
@endif
</div>
<div class="card-body pt-6">
@include('pages.users._table')
@include('pages.users.users._table')
@include('pages.users.users._form')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-base-layout>
@push('customscript')
<script>
$(function () {
$(".form_user_users").submit(function (e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
var form = $(this);
var actionUrl = form.attr('action');
$.ajax({
type: "POST",
url: actionUrl,
data: form.serialize(), // serializes the form's elements.
success: function (data) {
var _data = JSON.parse(data);
toastr.success(_data.message);
form[0].reset();
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
$('#kt_modal_user_users').modal('hide');
},
error: function (data, textStatus, errorThrown) {
var errors = data.responseJSON.errors;
$.each(errors, function (key, value) {
toastr.error(value);
});
}
});
});
$('#kt_modal_user_users').on('hidden.bs.modal', function (e) {
$(".form_user_users")[0].reset();
$("#sub_directorat_id").html("").append("<option value=''>Select Sub Directorat</option>");
$(".form_user_users").attr('action', "{{ route('user.users.store') }}");
$(".form_user_users").find('input[name="_method"]').remove();
$("#title_form").html("Create User");
});
$("#sub_directorat_id").remoteChained({
parents : "#directorat_id",
url : "/sub-directorat"
});
});
</script>
@endpush
</x-default-layout>

View File

@ -10,9 +10,9 @@
<!--end::Avatar-->
<!--begin::Username-->
<div class="d-flex flex-column">
<div class="fw-bold d-flex align-items-center fs-5">Max Smith
<span class="badge badge-light-success fw-bold fs-8 px-2 py-1 ms-2">Pro</span></div>
<a href="#" class="fw-semibold text-muted text-hover-primary fs-7">max@kt.com</a>
<div class="fw-bold d-flex align-items-center fs-5">{{ Auth::user()->name }}
<span class="badge badge-light-success fw-bold fs-8 px-2 py-1 ms-2">{{ Auth::user()->role }}</span></div>
<a href="#" class="fw-semibold text-muted text-hover-primary fs-7">{{ Auth::user()->email }}</a>
</div>
<!--end::Username-->
</div>
@ -26,131 +26,17 @@
<a href="#" class="menu-link px-5">My Profile</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="#" class="menu-link px-5">
<span class="menu-text">My Projects</span>
<span class="menu-badge">
<span class="badge badge-light-danger badge-circle fw-bold fs-7">3</span>
</span>
</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5" data-kt-menu-trigger="{default: 'click', lg: 'hover'}" data-kt-menu-placement="left-start" data-kt-menu-offset="-15px, 0">
<a href="#" class="menu-link px-5">
<span class="menu-title">My Subscription</span>
<span class="menu-arrow"></span>
</a>
<!--begin::Menu sub-->
<div class="menu-sub menu-sub-dropdown w-175px py-4">
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-5">Referrals</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-5">Billing</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link px-5">Payments</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex flex-stack px-5">Statements
<span class="ms-2" data-bs-toggle="tooltip" title="View your statements"></span></a>
</div>
<!--end::Menu item-->
<!--begin::Menu separator-->
<div class="separator my-2"></div>
<!--end::Menu separator-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<div class="menu-content px-3">
<label class="form-check form-switch form-check-custom form-check-solid">
<input class="form-check-input w-30px h-20px" type="checkbox" value="1" checked="checked" name="notifications" />
<span class="form-check-label text-muted fs-7">Notifications</span>
</label>
</div>
</div>
<!--end::Menu item-->
</div>
<!--end::Menu sub-->
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="#" class="menu-link px-5">My Statements</a>
</div>
<!--end::Menu item-->
<!--begin::Menu separator-->
<div class="separator my-2"></div>
<!--end::Menu separator-->
<!--begin::Menu item-->
<div class="menu-item px-5" data-kt-menu-trigger="{default: 'click', lg: 'hover'}" data-kt-menu-placement="left-start" data-kt-menu-offset="-15px, 0">
<a href="#" class="menu-link px-5">
<span class="menu-title position-relative">Language
<span class="fs-8 rounded bg-light px-3 py-2 position-absolute translate-middle-y top-50 end-0">English
<img class="w-15px h-15px rounded-1 ms-2" src="assets/media/flags/united-states.svg" alt="" /></span></span>
</a>
<!--begin::Menu sub-->
<div class="menu-sub menu-sub-dropdown w-175px py-4">
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex px-5 active">
<span class="symbol symbol-20px me-4">
<img class="rounded-1" src="assets/media/flags/united-states.svg" alt="" />
</span>English</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex px-5">
<span class="symbol symbol-20px me-4">
<img class="rounded-1" src="assets/media/flags/spain.svg" alt="" />
</span>Spanish</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex px-5">
<span class="symbol symbol-20px me-4">
<img class="rounded-1" src="assets/media/flags/germany.svg" alt="" />
</span>German</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex px-5">
<span class="symbol symbol-20px me-4">
<img class="rounded-1" src="assets/media/flags/japan.svg" alt="" />
</span>Japanese</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-3">
<a href="#" class="menu-link d-flex px-5">
<span class="symbol symbol-20px me-4">
<img class="rounded-1" src="assets/media/flags/france.svg" alt="" />
</span>French</a>
</div>
<!--end::Menu item-->
</div>
<!--end::Menu sub-->
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5 my-1">
<a href="#" class="menu-link px-5">Account Settings</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="#" class="menu-link px-5">Sign Out</a>
<a href="{{ route('logout') }}" class="menu-link px-5">Sign Out</a>
</div>
<!--end::Menu item-->
</div>

View File

@ -51,6 +51,6 @@ Route::middleware('auth')->group(function () {
Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
Route::get('logout', [AuthenticatedSessionController::class, 'destroy'])
->name('logout');
});