Add Module System & Audit Log and Module User Management

This commit is contained in:
daeng.deni@dharma.or.id 2023-04-17 09:22:49 +07:00
parent 162bd13cd8
commit 54ed252e3f
72 changed files with 4144 additions and 132 deletions

View File

@ -0,0 +1,120 @@
<?php
namespace App\DataTables\Logs;
use Spatie\Activitylog\Models\Activity;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class AuditLogsDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
*
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
return datatables()
->eloquent($query)
->rawColumns(['description', 'properties', 'action'])
->editColumn('id', function (Activity $model) {
return $model->id;
})
->editColumn('subject_id', function (Activity $model) {
if (!isset($model->subject)) {
return '';
}
if (isset($model->subject->name)) {
return $model->subject->name;
}
return $model->subject->user()->first()->name;
})
->editColumn('causer_id', function (Activity $model) {
return $model->causer ? $model->causer->name : __('System');
})
->editColumn('properties', function (Activity $model) {
$content = $model->properties;
return view('pages.log.audit._details', compact('content'));
})
->editColumn('created_at', function (Activity $model) {
return $model->created_at->format('d M, Y H:i:s');
})
->addColumn('action', function (Activity $model) {
return view('pages.log.audit._action-menu', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param Activity $model
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(Activity $model)
{
return $model->newQuery();
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('audit-log-table')
->columns($this->getColumns())
->minifiedAjax()
->stateSave(true)
->orderBy(6)
->responsive()
->autoWidth(false)
->parameters([
'scrollX' => true,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
Column::make('id')->title('Log ID'),
Column::make('log_name')->title(__('Location')),
Column::make('description'),
Column::make('subject_type'),
Column::make('subject_id')->title(__('Subject')),
Column::make('causer_id')->title(__('Causer')),
Column::make('created_at'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
Column::make('properties')->addClass('none'),
];
}
/**
* Get filename for export.
*
* @return string
*/
protected function filename() : string
{
return 'DataLogs_'.date('YmdHis');
}
}

View File

@ -0,0 +1,143 @@
<?php
namespace App\DataTables\Logs;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Jackiedo\LogReader\Exceptions\UnableToRetrieveLogFilesException;
use Jackiedo\LogReader\LogReader;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class SystemLogsDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
*
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
return datatables()
->collection($query)
->rawColumns(['action', 'level'])
->editColumn('id', function (Collection $model) {
return Str::limit($model->get('id'), 5, '');
})
->editColumn('file_path', function (Collection $model) {
return Str::limit($model->get('file_path'));
})
->editColumn('message', function (Collection $model) {
return Str::limit($model->get('context')->message, 95);
})
->editColumn('date', function (Collection $model) {
return $model->get('date')->format('d M, Y H:i:s');
})
->editColumn('level', function (Collection $model) {
$styles = [
'emergency' => 'danger',
'alert' => 'warning',
'critical' => 'danger',
'error' => 'danger',
'warning' => 'warning',
'notice' => 'success',
'info' => 'info',
'debug' => 'primary',
];
$style = 'info';
if (isset($styles[$model->get('level')])) {
$style = $styles[$model->get('level')];
}
$value = $model->get('level');
return '<div class="badge badge-light-'.$style.' fw-bolder">'.$value.'</div>';
})
->editColumn('context', function (Collection $model) {
$content = $model->get('context');
return view('pages.log.system._details', compact('content'));
})
->addColumn('action', function (Collection $model) {
return view('pages.log.system._action-menu', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param LogReader $model
*
* @return Collection
*/
public function query(LogReader $model)
{
$data = collect();
$model->setLogPath(storage_path('logs'));
try {
$data = $model->get()->merge($data);
} catch (UnableToRetrieveLogFilesException $exception) {
}
$data = $data->map(function ($a) {
return (collect($a))->only(['id', 'date', 'environment', 'level', 'file_path', 'context']);
});
return $data;
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('system-log-table')
->columns($this->getColumns())
->minifiedAjax()
->stateSave(true)
->orderBy(3)
->responsive()
->autoWidth(false)
->parameters(['scrollX' => true])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
Column::make('id')->title('Log ID')->width(50),
Column::make('message'),
Column::make('level'),
Column::make('date')->width(130),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
Column::make('environment')->addClass('none'),
Column::make('file_path')->title(__('Log Path'))->addClass('none'),
Column::make('context')->addClass('none'),
];
}
/**
* Get filename for export.
*
* @return string
*/
protected function filename() : string
{
return 'SystemLogs_'.date('YmdHis');
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace App\DataTables\Users;
use App\Models\PermissionGroup;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class PermissionsDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
return datatables()
->eloquent($query)
->filter(function ($query) {
if (request()->has('search')) {
$search = request()->get('search');
$query->where('name', 'like', "%" . $search['value'] . "%");
}
})
->rawColumns(['action','role'])
->addIndexColumn()
->addColumn('name', function (PermissionGroup $model) {
return $model->name;
})
->addColumn('role', function (PermissionGroup $model){
$role = $model->roles($model);
return view('pages.users.permissions._checkbox', compact('role'));
})
->addColumn('action', function (PermissionGroup $model) {
return view('pages.users.permissions._action', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param \App\Models\PermissionGroup $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(PermissionGroup $model)
{
return $model->newQuery();
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('user-permissions-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(1,'asc')
->stateSave(false)
->responsive()
->autoWidth(false)
->parameters([
'scrollX' => true,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('name')->title('Name'),
Column::make('role')->title('Assign To'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
];
}
/**
* Get filename for export
* @return string
*/
protected function filename() : string
{
return 'Permissions_' . date('YmdHis');
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace App\DataTables\Users;
use Spatie\Permission\Models\Role;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class RolesDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
return datatables()
->eloquent($query)
->rawColumns(['action'])
->addIndexColumn()
->filter(function ($query) {
if (request()->has('search')) {
$search = request()->get('search');
$query->where('name', 'like', "%" . $search['value'] . "%");
}
})
->addColumn('action', function (Role $model) {
return view('pages.users.roles._action', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param \App\Models\Role $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(Role $model)
{
return $model->newQuery();
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('user-roles-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(1,'asc')
->stateSave(false)
->responsive()
->autoWidth(false)
->parameters([
'scrollX' => true,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('name'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
];
}
/**
* Get filename for export.
*
* @return string
*/
protected function filename() : string
{
return 'Roles_' . date('YmdHis');
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\DataTables\Users;
use App\Models\User;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class UsersDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
return datatables()
->eloquent($query)
->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'] . "%");
}
})
->rawColumns(['first_name','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'));
});
}
/**
* Get query source of dataTable.
*
* @param \App\Models\User $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(User $model)
{
return $model->newQuery();
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('users-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(1,'asc')
->stateSave(false)
->responsive()
->autoWidth(false)
->parameters([
'scrollX' => true,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('first_name')->title(__('Name')),
Column::make('email'),
Column::make('phone'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
];
}
/**
* Get filename for export.
*
* @return string
*/
protected function filename() : string
{
return 'Users_' . date('YmdHis');
}
}

View File

@ -7,6 +7,7 @@ use App\Http\Requests\StoreDirectoratRequest;
use App\Http\Requests\UpdateDirectoratRequest; use App\Http\Requests\UpdateDirectoratRequest;
use App\Models\Directorat; use App\Models\Directorat;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Spatie\Activitylog\Facades\CauserResolver;
class DirectoratController extends Controller class DirectoratController extends Controller
{ {
@ -18,6 +19,8 @@ class DirectoratController extends Controller
//$this->user = Auth::guard('web')->user(); //$this->user = Auth::guard('web')->user();
return $next($request); return $next($request);
}); });
//CauserResolver::setCauser($this->user);
} }
/** /**
@ -96,7 +99,9 @@ class DirectoratController extends Controller
// Update the Directorat... // Update the Directorat...
if($validated){ if($validated){
try{ try{
CauserResolver::setCauser($this->user);
$directorat->update($validated); $directorat->update($validated);
//return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.'); //return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.');
echo json_encode(['status' => 'success', 'message' => 'Directorat updated successfully.']); echo json_encode(['status' => 'success', 'message' => 'Directorat updated successfully.']);
}catch(\Exception $e){ }catch(\Exception $e){
@ -114,6 +119,5 @@ class DirectoratController extends Controller
public function destroy(Directorat $directorat){ public function destroy(Directorat $directorat){
$directorat->delete(); $directorat->delete();
echo json_encode(['status' => 'success', 'message' => 'Directorat deleted successfully.']); echo json_encode(['status' => 'success', 'message' => 'Directorat deleted successfully.']);
//return redirect()->route('directorat.index')->with('success', 'Directorat deleted successfully.');
} }
} }

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers\Logs;
use App\DataTables\Logs\AuditLogsDataTable;
use App\Http\Controllers\Controller;
use Spatie\Activitylog\Models\Activity;
class AuditLogsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(AuditLogsDataTable $dataTable)
{
return $dataTable->render('pages.log.audit.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$activity = Activity::find($id);
// Delete from db
$activity->delete();
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Logs;
use App\DataTables\Logs\SystemLogsDataTable;
use App\Http\Controllers\Controller;
use Jackiedo\LogReader\LogReader;
class SystemLogsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(SystemLogsDataTable $dataTable)
{
return $dataTable->render('pages.log.system.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id, LogReader $logReader)
{
return $logReader->find($id)->delete();
}
}

View File

@ -0,0 +1,203 @@
<?php
namespace App\Http\Controllers\Users;
use App\DataTables\Users\PermissionsDataTable;
use App\Http\Controllers\Controller;
use App\Models\PermissionGroup;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Permission;
class PermissionsController extends Controller
{
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(PermissionsDataTable $dataTable)
{
/* if (is_null($this->user) || !$this->user->can('permission.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any permission !');
}*/
return $dataTable->render('pages.users.permissions.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
}
/**
* 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('permission.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any permission !');
}*/
// Validation Data
$validate = $request->validate([
'name' => 'required|max:100|unique:permission_groups'
], [
'name.requried' => 'Please give a permission name'
]);
if($validate){
try{
// Process Data
$group = PermissionGroup::create(['name' => $request->name]);
$group_name = strtolower($request->name);
$data = [
$group_name.'.create',
$group_name.'.read',
$group_name.'.update',
$group_name.'.delete',
$group_name.'.authorize',
$group_name.'.report'
];
foreach($data as $permission){
Permission::create([
'name' => $permission,
'guard_name' => 'web',
'permission_group_id' => $group->id
]);
}
echo json_encode(['status' => 'success', 'message' => 'Permission created successfully.']);
}catch(\Exception $e){
echo json_encode(['status' => 'error', 'message' => 'Permission created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* 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('permission.update')) {
abort(403, 'Sorry !! You are Unauthorized to edit any permission !');
}*/
$permission = PermissionGroup::find($id);
echo json_encode($permission);
}
/**
* 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('permission.update')) {
abort(403, 'Sorry !! You are Unauthorized to edit any permission !');
}*/
// Validation Data
$validated = $request->validate([
'name' => 'required|max:100|unique:permission_groups,name,' . $id
], [
'name.requried' => 'Please give a permission name'
]);
if ($validated) {
try {
// Process Data
$group = PermissionGroup::find($id);
$group->name = $request->name;
if($group->save()){
$permissions = Permission::where('permission_group_id', $group->id)->get();
$data = [
$group_name . '.create',
$group_name . '.read',
$group_name . '.update',
$group_name . '.delete',
$group_name . '.authorize',
$group_name . '.report'
];
$i = 0;
foreach($permissions as $permission){
$permission->name = $data[$i];
$permission->save();
$i++;
}
}
echo json_encode(['status' => 'success', 'message' => 'Permission updated successfully.']);
} catch (\Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Permission updated failed.']);
}
}
return false;
}
/**
* 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('permission.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any role !');
}*/
$permission = PermissionGroup::find($id);
if (!is_null($permission)) {
if($permission->delete()){
Permission::where('permission_group_id',$id)->delete();
}
}
echo json_encode(['status' => 'success', 'message' => 'Permission deleted successfully.']);
}
}

View File

@ -0,0 +1,190 @@
<?php
namespace App\Http\Controllers\Users;
use App\DataTables\Users\RolesDataTable;
use App\Http\Controllers\Controller;
use App\Models\PermissionGroup;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
use App\Models\Permission;
class RolesController extends Controller
{
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(RolesDataTable $dataTable)
{
/*if (is_null($this->user) || !$this->user->can('role.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any role !');
}*/
$permissiongroups = PermissionGroup::all();
return $dataTable->render('pages.users.roles.index', compact('permissiongroups'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
}
/**
* 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('role.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any role !');
}*/
// Validation Data
$validated = $request->validate([
'name' => 'required|max:100|unique:roles'
], [
'name.requried' => 'Please give a role name'
]);
if($validated){
try {
// Process Data
$role = Role::create(['name' => $request->name, 'guard_name' => 'web']);
$permissions = $request->input('permissions');
if (!empty($permissions)) {
$role = Role::find($role->id);
$role->syncPermissions($permissions);
}
echo json_encode(['status' => 'success', 'message' => 'Role Created Successfully']);
} catch (\Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Role Created Failed']);
}
}
return false;
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* 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('role.update')) {
abort(403, 'Sorry !! You are Unauthorized to edit any role !');
}*/
$role = Role::findById($id, 'web');
$permissions = Permission::all();
$permissiongroups = PermissionGroup::all();
$_array = [
'role' => $role,
'permissions' => $permissions,
'permissiongroups' => $permissiongroups
];
setcookie('role', json_encode($role), time() + (86400 * 30), "/");
setcookie('perissions', json_encode($permissions), time() + (86400 * 30), "/");
echo json_encode($_array);
}
/**
* 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('role.update')) {
abort(403, 'Sorry !! You are Unauthorized to edit any role !');
}*/
// Validation Data
$request->validate([
'name' => 'required|max:100|unique:roles,name,' . $id
], [
'name.requried' => 'Please give a role name'
]);
$role = Role::findById($id, 'web');
$permissions = $request->input('permissions');
$role->name = $request->name;
$role->save();
if (!empty($permissions)) {
$role->syncPermissions($permissions);
}
session()->flash('success', 'Role has been updated !!');
return redirect()->route('user.roles.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('role.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any role !');
}*/
$role = Role::findById($id, 'web');
if (!is_null($role)) {
$role->delete();
}
session()->flash('success', 'Role has been deleted !!');
return redirect()->route('user.roles.index');
}
}

View File

@ -0,0 +1,211 @@
<?php
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;
class UsersController extends Controller
{
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');
}
}

View File

@ -7,10 +7,11 @@ use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
class Directorat extends Model class Directorat extends Model
{ {
use LogsActivity, HasFactory, SoftDeletes; use LogsActivity, HasFactory, SoftDeletes, Userstamps;
protected $fillable = [ protected $fillable = [
'kode', 'kode',
@ -20,7 +21,7 @@ class Directorat extends Model
public function getActivitylogOptions(): LogOptions public function getActivitylogOptions(): LogOptions
{ {
return LogOptions::defaults()->logAll() return LogOptions::defaults()->logAll()
->useLogName('system'); ->useLogName('master data');
} }
public function subDirectorat() public function subDirectorat()

23
app/Models/Permission.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Permission\Models\Permission as SpatiePermission;
class Permission extends SpatiePermission
{
use LogsActivity;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
public function group()
{
return $this->hasOne(PermissionGroup::class);
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Permission\Models\Role;
class PermissionGroup extends Model
{
use LogsActivity;
protected $fillable = [
'name'
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
public function permission(){
return $this->hasMany(Permission::class);
}
public function roles($group){
$permission = Permission::where('permission_group_id', $group->id)->first();
$data = [];
$roles = Role::all();
foreach($roles as $role){
if($role->hasPermissionTo($permission->name)){
array_push($data,$role);
}
}
return $data;
}
public static function getpermissionsByGroupId($id)
{
$permissions = DB::table('permissions')
->select('name', 'id')
->where('permission_group_id', $id)
->get();
return $permissions;
}
}

View File

@ -7,12 +7,15 @@
"require": { "require": {
"php": "^8.0.2", "php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"jackiedo/log-reader": "2.*",
"laracasts/flash": "^3.2", "laracasts/flash": "^3.2",
"laravel/framework": "^10.0", "laravel/framework": "^10.0",
"laravel/sanctum": "^3.0", "laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7", "laravel/tinker": "^2.7",
"laravelcollective/html": "^6.4", "laravelcollective/html": "^6.4",
"spatie/laravel-activitylog": "^4.7", "spatie/laravel-activitylog": "^4.7",
"spatie/laravel-permission": "^5.10",
"wildside/userstamps": "^2.3",
"yajra/laravel-datatables": "^10.0", "yajra/laravel-datatables": "^10.0",
"yajra/laravel-datatables-oracle": "^10.3.1" "yajra/laravel-datatables-oracle": "^10.3.1"
}, },

294
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "b9f7e562d6d509796b8064720f017880", "content-hash": "9e90063b659e638d19ae81dade0a7fc4",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@ -1041,6 +1041,72 @@
], ],
"time": "2021-10-07T12:57:01+00:00" "time": "2021-10-07T12:57:01+00:00"
}, },
{
"name": "jackiedo/log-reader",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/JackieDo/Laravel-Log-Reader.git",
"reference": "c5bfb0f361383089934cd4059d7a37b9c2640609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JackieDo/Laravel-Log-Reader/zipball/c5bfb0f361383089934cd4059d7a37b9c2640609",
"reference": "c5bfb0f361383089934cd4059d7a37b9c2640609",
"shasum": ""
},
"require": {
"illuminate/cache": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"illuminate/config": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"illuminate/console": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"illuminate/http": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"illuminate/pagination": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"illuminate/support": "^9.0|^8.0|^7.0|^6.0|5.*|^10.0",
"nesbot/carbon": "^2.0|~1.20"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Jackiedo\\LogReader\\LogReaderServiceProvider"
],
"aliases": {
"LogReader": "Jackiedo\\LogReader\\Facades\\LogReader"
}
}
},
"autoload": {
"psr-4": {
"Jackiedo\\LogReader\\": "src/Jackiedo/LogReader"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jackie Do",
"email": "anhvudo@gmail.com"
}
],
"description": "An easy log reader and management tool for Laravel",
"keywords": [
"Viewer",
"laravel",
"log",
"log-manager",
"log-reader",
"log-viewer",
"logs",
"reader"
],
"support": {
"issues": "https://github.com/JackieDo/Laravel-Log-Reader/issues",
"source": "https://github.com/JackieDo/Laravel-Log-Reader/tree/2.3.0"
},
"time": "2023-02-18T21:01:57+00:00"
},
{ {
"name": "laracasts/flash", "name": "laracasts/flash",
"version": "3.2.2", "version": "3.2.2",
@ -3869,6 +3935,88 @@
], ],
"time": "2023-03-14T16:41:21+00:00" "time": "2023-03-14T16:41:21+00:00"
}, },
{
"name": "spatie/laravel-permission",
"version": "5.10.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-permission.git",
"reference": "d08b3ffc5870cce4a47a39f22174947b33c191ae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/d08b3ffc5870cce4a47a39f22174947b33c191ae",
"reference": "d08b3ffc5870cce4a47a39f22174947b33c191ae",
"shasum": ""
},
"require": {
"illuminate/auth": "^7.0|^8.0|^9.0|^10.0",
"illuminate/container": "^7.0|^8.0|^9.0|^10.0",
"illuminate/contracts": "^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
"php": "^7.3|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^9.4",
"predis/predis": "^1.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "5.x-dev",
"dev-master": "5.x-dev"
},
"laravel": {
"providers": [
"Spatie\\Permission\\PermissionServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\Permission\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Permission handling for Laravel 6.0 and up",
"homepage": "https://github.com/spatie/laravel-permission",
"keywords": [
"acl",
"laravel",
"permission",
"permissions",
"rbac",
"roles",
"security",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-permission/issues",
"source": "https://github.com/spatie/laravel-permission/tree/5.10.1"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2023-04-12T17:08:32+00:00"
},
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v6.2.8", "version": "v6.2.8",
@ -4099,16 +4247,16 @@
}, },
{ {
"name": "symfony/error-handler", "name": "symfony/error-handler",
"version": "v6.2.7", "version": "v6.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/error-handler.git", "url": "https://github.com/symfony/error-handler.git",
"reference": "61e90f94eb014054000bc902257d2763fac09166" "reference": "e95f1273b3953c3b5e5341172dae838bacee11ee"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/61e90f94eb014054000bc902257d2763fac09166", "url": "https://api.github.com/repos/symfony/error-handler/zipball/e95f1273b3953c3b5e5341172dae838bacee11ee",
"reference": "61e90f94eb014054000bc902257d2763fac09166", "reference": "e95f1273b3953c3b5e5341172dae838bacee11ee",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4150,7 +4298,7 @@
"description": "Provides tools to manage errors and ease debugging PHP code", "description": "Provides tools to manage errors and ease debugging PHP code",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/error-handler/tree/v6.2.7" "source": "https://github.com/symfony/error-handler/tree/v6.2.9"
}, },
"funding": [ "funding": [
{ {
@ -4166,7 +4314,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-02-14T08:44:56+00:00" "time": "2023-04-11T16:03:19+00:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
@ -4474,16 +4622,16 @@
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v6.2.8", "version": "v6.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "9563229e56076070d92ca30c089e801e8a4629a3" "reference": "02246510cf7031726f7237138d61b796b95799b3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/9563229e56076070d92ca30c089e801e8a4629a3", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/02246510cf7031726f7237138d61b796b95799b3",
"reference": "9563229e56076070d92ca30c089e801e8a4629a3", "reference": "02246510cf7031726f7237138d61b796b95799b3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4565,7 +4713,7 @@
"description": "Provides a structured process for converting a Request into a Response", "description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/http-kernel/tree/v6.2.8" "source": "https://github.com/symfony/http-kernel/tree/v6.2.9"
}, },
"funding": [ "funding": [
{ {
@ -4581,7 +4729,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-03-31T12:00:10+00:00" "time": "2023-04-13T16:41:43+00:00"
}, },
{ {
"name": "symfony/mailer", "name": "symfony/mailer",
@ -6333,6 +6481,61 @@
}, },
"time": "2022-06-03T18:03:27+00:00" "time": "2022-06-03T18:03:27+00:00"
}, },
{
"name": "wildside/userstamps",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/WildsideUK/Laravel-Userstamps.git",
"reference": "371cfbf5fda1872cc487888c6a8ac01e3e8249aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WildsideUK/Laravel-Userstamps/zipball/371cfbf5fda1872cc487888c6a8ac01e3e8249aa",
"reference": "371cfbf5fda1872cc487888c6a8ac01e3e8249aa",
"shasum": ""
},
"require": {
"illuminate/support": "^5.2|^6.0|^7.0|^8.0|^9.0|^10.0",
"php": ">=5.5.9"
},
"require-dev": {
"illuminate/database": "^5.2|^6.0|^7.0|^8.0|^9.0|^10.0",
"orchestra/testbench": "^3.1|^4.0|^5.0|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^5.0|^6.0|^7.0|^8.4|^9.0|^10.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Wildside\\Userstamps\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "WILDSIDE",
"email": "hello@wildside.uk",
"homepage": "https://wildside.uk"
}
],
"description": "Laravel Userstamps provides an Eloquent trait which automatically maintains `created_by` and `updated_by` columns on your model, populated by the currently authenticated user in your application.",
"keywords": [
"created_by",
"deleted_by",
"eloquent",
"laravel",
"updated_by",
"userstamps"
],
"support": {
"issues": "https://github.com/WildsideUK/Laravel-Userstamps/issues",
"source": "https://github.com/WildsideUK/Laravel-Userstamps/tree/2.3.0"
},
"time": "2023-02-15T09:35:24+00:00"
},
{ {
"name": "yajra/laravel-datatables", "name": "yajra/laravel-datatables",
"version": "v10.1.0", "version": "v10.1.0",
@ -7362,40 +7565,40 @@
}, },
{ {
"name": "nunomaduro/collision", "name": "nunomaduro/collision",
"version": "v7.4.0", "version": "v7.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nunomaduro/collision.git", "url": "https://github.com/nunomaduro/collision.git",
"reference": "42bab217d4913d6610f341d0468cec860aae165e" "reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/42bab217d4913d6610f341d0468cec860aae165e", "url": "https://api.github.com/repos/nunomaduro/collision/zipball/bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e",
"reference": "42bab217d4913d6610f341d0468cec860aae165e", "reference": "bbbc6fb9c1ee88f8aa38e47abd15c465f946f85e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"filp/whoops": "^2.15.1", "filp/whoops": "^2.15.2",
"nunomaduro/termwind": "^1.15.1", "nunomaduro/termwind": "^1.15.1",
"php": "^8.1.0", "php": "^8.1.0",
"symfony/console": "^6.2.7" "symfony/console": "^6.2.8"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<10.0.17" "phpunit/phpunit": "<10.1.0"
}, },
"require-dev": { "require-dev": {
"brianium/paratest": "^7.1.2", "brianium/paratest": "^7.1.3",
"laravel/framework": "^10.5.1", "laravel/framework": "^10.7.1",
"laravel/pint": "^1.7.0", "laravel/pint": "^1.8.0",
"laravel/sail": "^1.21.3", "laravel/sail": "^1.21.4",
"laravel/sanctum": "^3.2.1", "laravel/sanctum": "^3.2.1",
"laravel/tinker": "^2.8.1", "laravel/tinker": "^2.8.1",
"nunomaduro/larastan": "^2.5.1", "nunomaduro/larastan": "^2.5.1",
"orchestra/testbench-core": "^8.2.0", "orchestra/testbench-core": "^8.4.2",
"pestphp/pest": "^2.3.0", "pestphp/pest": "^2.5.0",
"phpunit/phpunit": "^10.0.19", "phpunit/phpunit": "^10.1.0",
"sebastian/environment": "^6.0.0", "sebastian/environment": "^6.0.1",
"spatie/laravel-ignition": "^2.0.0" "spatie/laravel-ignition": "^2.1.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -7454,7 +7657,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2023-03-31T08:17:12+00:00" "time": "2023-04-14T10:39:16+00:00"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
@ -7569,16 +7772,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "10.0.2", "version": "10.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4" "reference": "fc4f5ee614fa82d50ecf9014b51af0a9561f3df8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/20800e84296ea4732f9a125e08ce86b4004ae3e4", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fc4f5ee614fa82d50ecf9014b51af0a9561f3df8",
"reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4", "reference": "fc4f5ee614fa82d50ecf9014b51af0a9561f3df8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7606,7 +7809,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "10.0-dev" "dev-main": "10.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -7634,7 +7837,8 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.0.2" "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.0"
}, },
"funding": [ "funding": [
{ {
@ -7642,7 +7846,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-03-06T13:00:19+00:00" "time": "2023-04-13T07:08:27+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -7887,16 +8091,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "10.0.19", "version": "10.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "20c23e85c86e5c06d63538ba464e8054f4744e62" "reference": "5a477aea03e61329132935689ae2d73f418f5e25"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/20c23e85c86e5c06d63538ba464e8054f4744e62", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5a477aea03e61329132935689ae2d73f418f5e25",
"reference": "20c23e85c86e5c06d63538ba464e8054f4744e62", "reference": "5a477aea03e61329132935689ae2d73f418f5e25",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7910,7 +8114,7 @@
"phar-io/manifest": "^2.0.3", "phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2", "phar-io/version": "^3.0.2",
"php": ">=8.1", "php": ">=8.1",
"phpunit/php-code-coverage": "^10.0", "phpunit/php-code-coverage": "^10.1",
"phpunit/php-file-iterator": "^4.0", "phpunit/php-file-iterator": "^4.0",
"phpunit/php-invoker": "^4.0", "phpunit/php-invoker": "^4.0",
"phpunit/php-text-template": "^3.0", "phpunit/php-text-template": "^3.0",
@ -7936,7 +8140,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "10.0-dev" "dev-main": "10.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -7968,7 +8172,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.0.19" "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.0"
}, },
"funding": [ "funding": [
{ {
@ -7984,7 +8188,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-03-27T11:46:33+00:00" "time": "2023-04-14T05:15:09+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",

View File

@ -196,6 +196,9 @@ return [
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
Yajra\DataTables\DataTablesServiceProvider::class, Yajra\DataTables\DataTablesServiceProvider::class,
Jackiedo\LogReader\LogReaderServiceProvider::class,
Spatie\Permission\PermissionServiceProvider::class,
], ],
@ -212,6 +215,7 @@ return [
'aliases' => Facade::defaultAliases()->merge([ 'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class, // 'ExampleClass' => App\Example\ExampleClass::class,
'LogReader' => Jackiedo\LogReader\Facades\LogReader::class,
])->toArray(), ])->toArray(),
]; ];

91
config/log-reader.php Normal file
View File

@ -0,0 +1,91 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Path to directory for storing log files
|--------------------------------------------------------------------------
|
| This is path to directory storing your log files
|
*/
'path' => storage_path('logs'),
/*
|--------------------------------------------------------------------------
| Default log filename
|--------------------------------------------------------------------------
|
| This is default log filename that you want read from
| automatically. In Laravel, normally this name is 'laravel.log'.
| This string is compatible with format string in sprintf()
| function in PHP, it's mean you can set '*.*' to read all log
| files
|
*/
'filename' => null,
/*
|--------------------------------------------------------------------------
| Environment's log to read
|--------------------------------------------------------------------------
|
| This is information to limit reading logs entry on specify
| environment. Example: local, product... You can set null if want
| read from all environment
|
*/
'environment' => null,
/*
|--------------------------------------------------------------------------
| Level's log to read
|--------------------------------------------------------------------------
|
| This array is information to limit reading logs entry from
| specify levels. Example: ['error', 'warning']. You can set null
| if want read from all levels.
|
*/
'level' => null,
/*
|--------------------------------------------------------------------------
| Default sort field
|--------------------------------------------------------------------------
|
| This is default field to sort by when reading
|
*/
'order_by_field' => 'date',
/*
|--------------------------------------------------------------------------
| Default sort direction
|--------------------------------------------------------------------------
|
| This is default direction to sort by when reading
|
*/
'order_by_direction' => 'asc',
/*
|--------------------------------------------------------------------------
| Default log parser
|--------------------------------------------------------------------------
|
| This is the default class used to parse log entries.
|
| If this setting is not set, the 'Jackiedo\LogReader\LogParser' class will
| be used.
|
*/
'default_log_parser' => null,
];

161
config/permission.php Normal file
View File

@ -0,0 +1,161 @@
<?php
return [
'models' => [
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission' => Spatie\Permission\Models\Permission::class,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role' => Spatie\Permission\Models\Role::class,
],
'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles' => 'roles',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions' => 'permissions',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions' => 'model_has_permissions',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles' => 'model_has_roles',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions' => 'role_has_permissions',
],
'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/
'role_pivot_key' => null, //default 'role_id',
'permission_pivot_key' => null, //default 'permission_id',
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key' => 'model_id',
/*
* Change this if you want to use the teams feature and your related model's
* foreign key is other than `team_id`.
*/
'team_foreign_key' => 'team_id',
],
/*
* When set to true, the method for checking permissions will be registered on the gate.
* Set this to false, if you want to implement custom logic for checking permissions.
*/
'register_permission_check_method' => true,
/*
* When set to true the package implements teams using the 'team_foreign_key'. If you want
* the migrations to register the 'team_foreign_key', you must set this to true
* before doing the migration. If you already did the migration then you must make a new
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
* 'model_has_permissions'(view the latest version of package's migration file)
*/
'teams' => false,
/*
* When set to true, the required permission names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_permission_in_exception' => false,
/*
* When set to true, the required role names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_role_in_exception' => false,
/*
* By default wildcard permission lookups are disabled.
*/
'enable_wildcard_permission' => false,
'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store all permissions.
*/
'key' => 'spatie.permission.cache',
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store' => 'default',
],
];

View File

@ -21,6 +21,11 @@ return new class extends Migration
$table->string('password'); $table->string('password');
$table->rememberToken(); $table->rememberToken();
$table->timestamps(); $table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -17,6 +17,11 @@ return new class extends Migration
$table->string('email')->index(); $table->string('email')->index();
$table->string('token'); $table->string('token');
$table->timestamp('created_at')->nullable(); $table->timestamp('created_at')->nullable();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -21,6 +21,11 @@ return new class extends Migration
$table->longText('payload'); $table->longText('payload');
$table->longText('exception'); $table->longText('exception');
$table->timestamp('failed_at')->useCurrent(); $table->timestamp('failed_at')->useCurrent();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -22,6 +22,11 @@ return new class extends Migration
$table->timestamp('last_used_at')->nullable(); $table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable(); $table->timestamp('expires_at')->nullable();
$table->timestamps(); $table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -17,6 +17,10 @@ return new class extends Migration
$table->string('name',50); $table->string('name',50);
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -18,6 +18,10 @@ return new class extends Migration
$table->string('name',50); $table->string('name',50);
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -19,6 +19,10 @@ return new class extends Migration
$table->string('name',50); $table->string('name',50);
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -20,6 +20,10 @@ return new class extends Migration
$table->string('name',50); $table->string('name',50);
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -17,6 +17,10 @@ class CreateActivityLogTable extends Migration
$table->json('properties')->nullable(); $table->json('properties')->nullable();
$table->timestamps(); $table->timestamps();
$table->index('log_name'); $table->index('log_name');
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -21,6 +21,10 @@ return new class extends Migration
$table->string('name'); $table->string('name');
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }

View File

@ -0,0 +1,141 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$teams = config('permission.teams');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('permission_groups', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('permission_groups');
}
};

View File

@ -0,0 +1,28 @@
<?php
use App\Models\PermissionGroup;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('permissions', function($table) {
$table->foreignIdFor(PermissionGroup::class);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropForeignKey('permission_group_id');
Schema::dropColumn('permission_group_id');
}
};

View File

@ -6,6 +6,7 @@ use App\Models\Directorat;
use App\Models\Job; use App\Models\Job;
use App\Models\SubDirectorat; use App\Models\SubDirectorat;
use App\Models\SubJob; use App\Models\SubJob;
use App\Models\SubSubJob;
use Faker\Generator; use Faker\Generator;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;

View File

@ -5,13 +5,20 @@
@endphp @endphp
<!--begin::Title--> <!--begin::Title-->
<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0 text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</h1> <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')
{{ $route[1] }}
@endif
@endif
{{ ucfirst(str_replace('-',' ',$route[0])) }}
</h1>
<!--end::Title--> <!--end::Title-->
<!--begin::Breadcrumb--> <!--begin::Breadcrumb-->
<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1"> <ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
<!--begin::Item--> <!--begin::Item-->
<li class="breadcrumb-item text-muted"> <li class="breadcrumb-item text-muted">
<a href="{{ route('dashboard') }}" class="text-muted text-hover-primary">Home</a> <a href="{{ route('dashboard') }}" class="text-muted text-hover-primary">Dashboard</a>
</li> </li>
<!--end::Item--> <!--end::Item-->
<!--begin::Item--> <!--begin::Item-->
@ -19,9 +26,27 @@
<span class="bullet bg-gray-400 w-5px h-2px"></span> <span class="bullet bg-gray-400 w-5px h-2px"></span>
</li> </li>
<!--end::Item--> <!--end::Item-->
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</li> @if(count($route) > 1)
<!--end::Item--> @if($route[1] !== 'index')
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</li>
<!--end::Item-->
<!--begin::Item-->
<li class="breadcrumb-item">
<span class="bullet bg-gray-400 w-5px h-2px"></span>
</li>
<!--end::Item-->
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[1])).' '.ucfirst(str_replace('-',' ',$route[0]))}}</li>
<!--end::Item-->
@endif
@else
<!--begin::Item-->
<li class="breadcrumb-item text-muted text-capitalize">{{ ucfirst(str_replace('-',' ',$route[0])) }}</li>
<!--end::Item-->
@endif
</ul> </ul>
<!--end::Breadcrumb--> <!--end::Breadcrumb-->
</div> </div>

View File

@ -15,6 +15,14 @@
<!--end::Primary button--> <!--end::Primary button-->
</div> </div>
<!--end::Actions--> <!--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-->
@endif @endif
</div> </div>
<!--end::Toolbar container--> <!--end::Toolbar container-->

View File

@ -141,7 +141,7 @@
</div> </div>
<!--end:Menu item--> <!--end:Menu item-->
<!--begin:Menu item--> <!--begin:Menu item-->
<div data-kt-menu-trigger="click" class="menu-item menu-accordion"> <div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'user' ? 'show' : '' }}">
<!--begin:Menu link--> <!--begin:Menu link-->
<span class="menu-link"> <span class="menu-link">
<span class="menu-icon">{!! getIcon('people', 'fs-2') !!}</span> <span class="menu-icon">{!! getIcon('people', 'fs-2') !!}</span>
@ -152,91 +152,35 @@
<!--begin:Menu sub--> <!--begin:Menu sub-->
<div class="menu-sub menu-sub-accordion"> <div class="menu-sub menu-sub-accordion">
<!--begin:Menu item--> <!--begin:Menu item-->
<div data-kt-menu-trigger="click" class="menu-item menu-accordion mb-1"> <div class="menu-item ">
<!--begin:Menu link--> <!--begin:Menu link-->
<span class="menu-link"> <a class="menu-link {{ isset($route[1]) && $route[1] == 'users' ? 'active' : '' }}" href="{{ route('user.users.index') }}">
<span class="menu-bullet"> <span class="menu-bullet">
<span class="bullet bullet-dot"></span> <span class="bullet bullet-dot"></span>
</span> </span>
<span class="menu-title">Users</span> <span class="menu-title">Users</span>
<span class="menu-arrow"></span> </a>
</span>
<!--end:Menu link--> <!--end:Menu link-->
<!--begin:Menu sub-->
<div class="menu-sub menu-sub-accordion">
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link" href="/">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Users List</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link" href="/">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">View User</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
</div>
<!--end:Menu sub-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div data-kt-menu-trigger="click" class="menu-item menu-accordion">
<!--begin:Menu link-->
<span class="menu-link">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Roles</span>
<span class="menu-arrow"></span>
</span>
<!--end:Menu link-->
<!--begin:Menu sub-->
<div class="menu-sub menu-sub-accordion">
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link" href="/">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Roles List</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link" href="/">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">View Role</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
</div>
<!--end:Menu sub-->
</div> </div>
<!--end:Menu item--> <!--end:Menu item-->
<!--begin:Menu item--> <!--begin:Menu item-->
<div class="menu-item"> <div class="menu-item">
<!--begin:Menu link--> <!--begin:Menu link-->
<a class="menu-link" href="/"> <a class="menu-link {{ isset($route[1]) && $route[1] == 'roles' ? 'active' : '' }}" href="{{ route('user.roles.index') }}">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Roles</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link {{ isset($route[1]) && $route[1] == 'permissions' ? 'active' : '' }}" href="{{ route('user.permissions.index') }}">
<span class="menu-bullet"> <span class="menu-bullet">
<span class="bullet bullet-dot"></span> <span class="bullet bullet-dot"></span>
</span> </span>
@ -254,7 +198,7 @@
<div class="menu-item {{ $route[0] == "document" ? "here" : "" }}"> <div class="menu-item {{ $route[0] == "document" ? "here" : "" }}">
<!--begin:Menu link--> <!--begin:Menu link-->
<a class="menu-link {{ $route[0] == "document" ? "active" : "" }}" href="/"> <a class="menu-link {{ $route[0] == "document" ? "active" : "" }}" href="/">
<span class="menu-icon">{!! getIcon('some-files', 'fs-2') !!}</span> <span class="menu-icon">{!! getIcon('some-files', 'fs-2','duotone') !!}</span>
<span class="menu-title">Documents Management</span> <span class="menu-title">Documents Management</span>
</a> </a>
<!--end:Menu link--> <!--end:Menu link-->
@ -275,7 +219,7 @@
<div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'directorat' || $route[0] == 'sub-directorat' || $route[0] == 'job' || $route[0] == 'sub-job' || $route[0] == 'sub-sub-job' ? 'show' : '' }}"> <div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'directorat' || $route[0] == 'sub-directorat' || $route[0] == 'job' || $route[0] == 'sub-job' || $route[0] == 'sub-sub-job' ? 'show' : '' }}">
<!--begin:Menu link--> <!--begin:Menu link-->
<span class="menu-link"> <span class="menu-link">
<span class="menu-icon">{!! getIcon('abstract-28', 'fs-2') !!}</span> <span class="menu-icon">{!! getIcon('abstract-28', 'fs-2','duotone') !!}</span>
<span class="menu-title">Masters</span> <span class="menu-title">Masters</span>
<span class="menu-arrow"></span> <span class="menu-arrow"></span>
</span> </span>
@ -347,7 +291,56 @@
</div> </div>
<!--end:Menu item--> <!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item pt-5">
<!--begin:Menu content-->
<div class="menu-content">
<span class="menu-heading fw-bold text-uppercase fs-7">System</span>
</div>
<!--end:Menu content-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'log' ? 'show' : '' }}">
<!--begin:Menu link-->
<span class="menu-link">
<span class="menu-icon">{!! getIcon('element-equal', 'fs-2','duotone') !!}</span>
<span class="menu-title">Logs</span>
<span class="menu-arrow"></span>
</span>
<!--end:Menu link-->
<!--begin:Menu sub-->
<div class="menu-sub menu-sub-accordion">
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link {{ isset($route[1]) && $route[1] == 'system' ? 'active' : '' }}" href="{{ route('log.system.index') }}">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">System Logs</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link {{ isset($route[1]) && $route[1] == 'audit' ? 'active' : '' }}" href="{{ route('log.audit.index') }}">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Audit Logs</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
</div>
<!--end:Menu sub-->
</div>
<!--end:Menu item-->
</div> </div>
<!--end::Menu--> <!--end::Menu-->
</div> </div>

View File

@ -0,0 +1,7 @@
<!--begin::Action--->
<td class="text-end">
<button data-destroy="{{ route('log.audit.destroy', $model->id) }}" class="btn btn-sm btn-light btn-active-light-primary">
Delete
</button>
</td>
<!--end::Action--->

View File

@ -0,0 +1,3 @@
<textarea readonly cols="130" rows="10">
{!! json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) !!}
</textarea>

View File

@ -0,0 +1,8 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection

View File

@ -0,0 +1,13 @@
<x-default-layout>
<!--begin::Card-->
<div class="card">
<!--begin::Card body-->
<div class="card-body pt-6">
@include('pages.log.audit._table')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -0,0 +1,7 @@
<!--begin::Action--->
<td class="text-end">
<button data-destroy="{{ route('log.system.destroy', $model->get('id')) }}" class="btn btn-sm btn-light btn-active-light-primary">
Delete
</button>
</td>
<!--end::Action--->

View File

@ -0,0 +1,3 @@
<textarea readonly cols="130" rows="10">
{!! json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) !!}
</textarea>

View File

@ -0,0 +1,8 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection

View File

@ -0,0 +1,13 @@
<x-default-layout>
<!--begin::Card-->
<div class="card">
<!--begin::Card body-->
<div class="card-body pt-6">
@include('pages.log.system._table')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -0,0 +1,13 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.'.$route[1].'.edit',['permission' => $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>
{!! 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() !!}
</div>

View File

@ -0,0 +1,21 @@
<td>
@php
$color = [
'badge-white',
'badge-light-primary',#
'badge-light-dark',#
'badge-secondary',
'badge-light-success',#
'badge-light-info',#
'badge-light-warning',#
'badge-light-danger'#
];
$i = 1;
@endphp
@foreach($role as $row)
<a href="javascript:;" class="text-capitalize badge {{ $color[$row->id] }} fs-7 m-1">{{ $row->name }}</a>
@php $i++ @endphp
@endforeach
</td>

View File

@ -0,0 +1,58 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_permissions" 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_permissions_id" name="id" />
<input type="text" id="user_permissions_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Permission Name" name="name" />
</div>
<!--end::Input group-->
<!--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

@ -0,0 +1,116 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection
@push('customscript')
@php
$route = explode('.', Route::currentRouteName());
@endphp
<script>
$("#searchbox").on("keyup search input paste cut", function () {
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].search(this.value).draw();
});
$(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])) }}');
$('#{{$route[0].'_'.$route[1]}}_id').val(response.id);
$('#{{$route[0].'_'.$route[1]}}_name').val(response.name);
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.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?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.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();
}
});
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,135 @@
@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">
<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>
<!--end::Svg Icon-->
<input type="text" id="searchbox"
class="form-control form-control-solid border border-gray-300 w-250px ps-15"
placeholder="Search Permission">
</div>
<!--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-->
</div>
</div>
<div class="card-body pt-6">
@include('pages.users.permissions._table')
@include('pages.users.permissions._form')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
@push('customscript')
<script>
$(function () {
$(".form_user_permissions").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_permissions').modal('hide');
},
error: function (data, textStatus, errorThrown) {
var errors = data.responseJSON.errors;
$.each(errors, function (key, value) {
toastr.error(value);
});
}
});
});
$('#kt_modal_user_permissions').on('hidden.bs.modal', function (e) {
$(".form_user_permissions")[0].reset();
$(".form_user_permissions").attr('action', "{{ route('user.permissions.store') }}");
$(".form_user_permissions").find('input[name="_method"]').remove();
$("#title_form").html("Create Permission");
})
});
</script>
@endpush
</x-default-layout>

View File

@ -0,0 +1,14 @@
<div class="d-flex flex-row flex-center">
@if(Auth::user()->can('role.update'))
<a href="{{ route('roles.edit',['role' => $model->id]) }}"
class="btn btn-bg-light btn-active-light-primary btn-sm me-1" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-dark" data-bs-placement="top" title="Edit">
{!! theme()->getSvgIcon("icons/duotune/art/art005.svg", "svg-icon-3") !!} Edit
</a>
@endif
@if($model->id > 5 && Auth::user()->can('role.delete'))
{!! Form::open(['method' => 'DELETE','route' => ['roles.destroy', $model->id],'class'=>'']) !!}
{{ Form::button(theme()->getSvgIcon("icons/duotune/general/gen027.svg", "svg-icon-3")." Delete", ['type' => 'submit', 'class' => 'delete btn btn-bg-light btn-active-light-danger btn-sm', 'data-bs-toggle' => "tooltip", 'data-bs-custom-class' => "tooltip-dark", 'data-bs-placement'=>"top", 'title'=>"Delete"] ) }}
{!! Form::close() !!}
@endif
</div>

View File

@ -0,0 +1,5 @@
<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

@ -0,0 +1,132 @@
<form id="kt_modal_add_role_form" method="POST" class="form" action="{{ route('roles.store') }}">
{{ csrf_field() }}
<!--begin::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_role_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_role_header" data-kt-scroll-wrappers="#kt_modal_add_role_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Role Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="name" class="form-control form-control-solid mb-3 mb-lg-0 @error('name') is-invalid @enderror" placeholder="Role name" value="" />
</div>
@error('name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<div class="fv-row">
<!--begin::Label-->
<label class="fs-5 fw-bolder form-label mb-2">Role Permissions</label>
<!--end::Label-->
<!--begin::Table wrapper-->
<div class="table-responsive">
<!--begin::Table-->
<table class="table align-middle table-row-dashed fs-6 gy-5">
<!--begin::Table body-->
<tbody class="text-gray-600 fw-bold">
<!--begin::Table row-->
<tr>
<td class="text-gray-800">Administrator/Superuser Access
<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Allows a full access to the system"></i></td>
<td>
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9">
<input class="form-check-input" type="checkbox" value="" id="kt_roles_select_all" />
<span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label>
<!--end::Checkbox-->
</td>
</tr>
<!--end::Table row-->
@foreach($permissiongroups as $group)
<!--begin::Table row-->
<tr>
<!--begin::Label-->
<td class="text-gray-800">{{ $group->name }}</td>
<!--end::Label-->
<!--begin::Input group-->
<td>
<!--begin::Wrapper-->
<div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20">
<input class="form-check-input" type="checkbox" value="{{ $permission->id }}" name="permissions[]" />
@php
$permission_name = explode('.',$permission->name);
@endphp
<span class="form-check-label text-capitalize">{{ $permission_name[1] }}</span>
</label>
<!--end::Checkbox-->
@endforeach
</div>
<!--end::Wrapper-->
</td>
<!--end::Input group-->
</tr>
<!--end::Table row-->
@endforeach
</tbody>
<!--end::Table body-->
</table>
<!--end::Table-->
</div>
<!--end::Table wrapper-->
</div>
<!--end::Permissions-->
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-kt-roles-modal-action="cancel">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-roles-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>
@push('customscript')
<script>
"use strict";
// Class definition
var Roles = function () {
// Shared variables
const form = document.getElementById('kt_modal_add_role_form');
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
Roles.init();
});
</script>
@endpush

View File

@ -0,0 +1,140 @@
<form id="kt_modal_add_role_form" method="POST" class="form" action="{{ route('roles.update',['role' => $role->id]) }}">
@method('PUT')
{{ csrf_field() }}
<!--begin::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_role_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_role_header" data-kt-scroll-wrappers="#kt_modal_add_role_scroll"
data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Role Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="name"
class="form-control form-control-solid mb-3 mb-lg-0 @error('name') is-invalid @enderror"
placeholder="Role name" value="{{ $role->name ?? '' }}"/>
</div>
@error('name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<div class="fv-row">
<!--begin::Label-->
<label class="fs-5 fw-bolder form-label mb-2">Role Permissions</label>
<!--end::Label-->
<!--begin::Table wrapper-->
<div class="table-responsive">
<!--begin::Table-->
<table class="table align-middle table-row-dashed fs-6 gy-5">
<!--begin::Table body-->
<tbody class="text-gray-600 fw-bold">
<!--begin::Table row-->
<tr>
<td class="text-gray-800">Administrator/Superuser Access
<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Allows a full access to the system"></i></td>
<td>
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9">
<input class="form-check-input" type="checkbox" value="" id="kt_roles_select_all" />
<span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label>
<!--end::Checkbox-->
</td>
</tr>
<!--end::Table row-->
@foreach($permissiongroups as $group)
<!--begin::Table row-->
<tr>
<!--begin::Label-->
<td class="text-gray-800">{{ $group->name }}</td>
<!--end::Label-->
<!--begin::Input group-->
<td>
<!--begin::Wrapper-->
<div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20">
<input class="form-check-input" type="checkbox" id="permission_{{ $permission->id }}" value="{{ $permission->id }}" name="permissions[]" {{ $role->hasPermissionTo($permission->name) ? 'checked' : null }} />
@php
$permission_name = explode('.',$permission->name);
@endphp
<span class="form-check-label text-capitalize">{{ $permission_name[1] }}</span>
</label>
<!--end::Checkbox-->
@endforeach
</div>
<!--end::Wrapper-->
</td>
<!--end::Input group-->
</tr>
<!--end::Table row-->
@endforeach
</tbody>
<!--end::Table body-->
</table>
<!--end::Table-->
</div>
<!--end::Table wrapper-->
</div>
<!--end::Permissions-->
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-kt-roles-modal-action="cancel">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-roles-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>
@push('customscript')
<script>
"use strict";
// Class definition
var Roles = function () {
// Shared variables
const form = document.getElementById('kt_modal_add_role_form');
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
Roles.init();
});
</script>
@endpush

View File

@ -0,0 +1,164 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_roles" 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::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_role_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_role_header" data-kt-scroll-wrappers="#kt_modal_add_role_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Role Name</label>
<!--end::Label-->
<!--begin::Input-->
<div class="input-group input-group-solid has-validation mb-3">
<input type="text" name="name" class="form-control form-control-solid mb-3 mb-lg-0 @error('name') is-invalid @enderror" placeholder="Role name" value="" />
</div>
@error('name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<div class="fv-row">
<!--begin::Label-->
<label class="fs-5 fw-bolder form-label mb-2">Role Permissions</label>
<!--end::Label-->
<!--begin::Table wrapper-->
<div class="table-responsive">
<!--begin::Table-->
<table class="table align-middle table-row-dashed fs-6 gy-5">
<!--begin::Table body-->
<tbody class="text-gray-600 fw-bold">
<!--begin::Table row-->
<tr>
<td class="text-gray-800">Administrator/Superuser Access
<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Allows a full access to the system"></i></td>
<td>
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9">
<input class="form-check-input" type="checkbox" value="" id="kt_roles_select_all" />
<span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label>
<!--end::Checkbox-->
</td>
</tr>
<!--end::Table row-->
@foreach($permissiongroups as $group)
<!--begin::Table row-->
<tr>
<!--begin::Label-->
<td class="text-gray-800">{{ $group->name }}</td>
<!--end::Label-->
<!--begin::Input group-->
<td>
<!--begin::Wrapper-->
<div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20">
<input class="form-check-input" type="checkbox" value="{{ $permission->id }}" name="permissions[]" />
@php
$permission_name = explode('.',$permission->name);
@endphp
<span class="form-check-label text-capitalize">{{ $permission_name[1] }}</span>
</label>
<!--end::Checkbox-->
@endforeach
</div>
<!--end::Wrapper-->
</td>
<!--end::Input group-->
</tr>
<!--end::Table row-->
@endforeach
</tbody>
<!--end::Table body-->
</table>
<!--end::Table-->
</div>
<!--end::Table wrapper-->
</div>
<!--end::Permissions-->
</div>
<!--end::Scroll-->
<!--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-->
@push('customscript')
<script>
"use strict";
// Class definition
var Roles = function () {
// Shared variables
const form = document.getElementById('kt_modal_add_role_form');
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
Roles.init();
});
</script>
@endpush

View File

@ -0,0 +1,50 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection
@push('customscript')
<script>
$("#searchbox").on("keyup search input paste cut", function() {
LaravelDataTables["roles-table"].search(this.value).draw();
});
$(function(){
LaravelDataTables["roles-table"].on('click','.delete',function(event){
var form = $(this).closest("form");
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,29 @@
<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">
Add Role
</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('roles.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.roles._createform')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -0,0 +1,29 @@
<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">
Edit Role {{ $role->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('roles.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.roles._editform')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -0,0 +1,52 @@
<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="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>
<!--end::Svg Icon-->
<input type="text" id="searchbox" class="form-control form-control-solid w-250px ps-15"
placeholder="Search Roles">
</div>
</h3>
@if(Auth::user()->can('role.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 role">
<a href="{{ route('roles.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 Role
</a>
</div>
@endif
</div>
<div class="card-body pt-6">
@include('pages.users.roles._table')
@include('pages.users.roles._form')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -0,0 +1,13 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.'.$route[1].'.edit',['role' => $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>
{!! 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() !!}
</div>

View File

@ -0,0 +1,160 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_roles" tabindex="-1" aria-hidden="true">
<!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered modal-fullscreen">
<!--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 id="form_{{$route[0].'_'.$route[1]}}" 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_roles_id" name="id" />
<input type="text" id="user_roles_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Role Name" name="name" />
</div>
<!--end::Input group-->
<!--end::Input group-->
<div class="fv-row">
<!--begin::Label-->
<label class="fs-5 fw-bolder form-label mb-2">Role Permissions</label>
<!--end::Label-->
<!--begin::Table wrapper-->
<div class="table-responsive">
<!--begin::Table-->
<table class="table align-middle table-row-dashed fs-6 gy-5">
<!--begin::Table body-->
<tbody class="text-gray-600 fw-bold">
<!--begin::Table row-->
<tr>
<td class="text-gray-800">Administrator/Superuser Access
<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Allows a full access to the system"></i></td>
<td>
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9">
<input class="form-check-input" type="checkbox" value="" id="kt_roles_select_all" />
<span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label>
<!--end::Checkbox-->
</td>
</tr>
<!--end::Table row-->
@foreach($permissiongroups as $group)
<!--begin::Table row-->
<tr>
<!--begin::Label-->
<td class="text-gray-800">{{ $group->name }}</td>
<!--end::Label-->
<!--begin::Input group-->
<td>
<!--begin::Wrapper-->
<div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20">
<input class="form-check-input" id="permission_{{ $permission->id }}" type="checkbox" value="{{ $permission->id }}" name="permissions[]" />
@php
$permission_name = explode('.',$permission->name);
@endphp
<span class="form-check-label text-capitalize">{{ $permission_name[1] }}</span>
</label>
<!--end::Checkbox-->
@endforeach
</div>
<!--end::Wrapper-->
</td>
<!--end::Input group-->
</tr>
<!--end::Table row-->
@endforeach
</tbody>
<!--end::Table body-->
</table>
<!--end::Table-->
</div>
<!--end::Table wrapper-->
</div>
<!--end::Permissions-->
<!--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-->
@push('customscript')
<script>
"use strict";
// Class definition
var Roles = function () {
// Shared variables
const form = document.getElementById('form_{{$route[0].'_'.$route[1]}}');
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
Roles.init();
});
</script>
@endpush

View File

@ -0,0 +1,115 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection
@push('customscript')
@php
$route = explode('.', Route::currentRouteName());
@endphp
<script>
$("#searchbox").on("keyup search input paste cut", function () {
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].search(this.value).draw();
});
$(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) {
$('#title_form').text('Edit {{ ucfirst(str_replace('-',' ',$route[0].' '.$route[1])) }}');
$('#{{$route[0].'_'.$route[1]}}_id').val(response.role.id);
$('#{{$route[0].'_'.$route[1]}}_name').val(response.role.name);
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.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?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.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();
}
});
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,135 @@
@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">
<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>
<!--end::Svg Icon-->
<input type="text" id="searchbox"
class="form-control form-control-solid border border-gray-300 w-250px ps-15"
placeholder="Search Role">
</div>
<!--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-->
</div>
</div>
<div class="card-body pt-6">
@include('pages.users.roles._table')
@include('pages.users.roles._form')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
@push('customscript')
<script>
$(function () {
$(".form_user_roles").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_roles').modal('hide');
},
error: function (data, textStatus, errorThrown) {
var errors = data.responseJSON.errors;
$.each(errors, function (key, value) {
toastr.error(value);
});
}
});
});
$('#kt_modal_user_roles').on('hidden.bs.modal', function (e) {
$(".form_user_roles")[0].reset();
$(".form_user_roles").attr('action', "{{ route('user.roles.store') }}");
$(".form_user_roles").find('input[name="_method"]').remove();
$("#title_form").html("Create Role");
})
});
</script>
@endpush
</x-default-layout>

View File

@ -0,0 +1,14 @@
<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>
@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::close() !!}
@endif
</div>

View File

@ -0,0 +1,9 @@
<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

@ -0,0 +1,5 @@
<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

@ -0,0 +1,154 @@
<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

@ -0,0 +1,140 @@
<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,50 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection
@push('customscript')
<script>
$("#searchbox").on("keyup search input paste cut", function() {
LaravelDataTables["users-table"].search(this.value).draw();
});
$(function(){
LaravelDataTables["users-table"].on('click','.delete',function(event){
var form = $(this).closest("form");
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
Swal.fire(
'Deleted!',
'User has been deleted.',
'success'
)
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,29 @@
<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

@ -0,0 +1,29 @@
<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

@ -0,0 +1,50 @@
<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">
<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>
<!--end::Svg Icon-->
<input type="text" id="searchbox" class="form-control form-control-solid w-250px ps-15"
placeholder="Search Users">
</div>
</h3>
@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')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-base-layout>

View File

@ -3,10 +3,15 @@
use App\Http\Controllers\DashboardController; use App\Http\Controllers\DashboardController;
use App\Http\Controllers\DirectoratController; use App\Http\Controllers\DirectoratController;
use App\Http\Controllers\JobController; use App\Http\Controllers\JobController;
use App\Http\Controllers\Logs\AuditLogsController;
use App\Http\Controllers\Logs\SystemLogsController;
use App\Http\Controllers\SubDirectoratController; use App\Http\Controllers\SubDirectoratController;
use App\Http\Controllers\SubJobController; use App\Http\Controllers\SubJobController;
use App\Http\Controllers\SubSubJobController; use App\Http\Controllers\SubSubJobController;
use Illuminate\Support\Facades\Route; use App\Http\Controllers\Users\PermissionsController;
use App\Http\Controllers\Users\RolesController;
use App\Http\Controllers\Users\UsersController;
use Illuminate\Support\Facades\Route;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -22,11 +27,31 @@ use Illuminate\Support\Facades\Route;
Route::group(['middleware' => ['auth', 'verified']], function () { Route::group(['middleware' => ['auth', 'verified']], function () {
Route::get('/', [DashboardController::class, 'index'])->middleware(['auth', 'verified']); Route::get('/', [DashboardController::class, 'index'])->middleware(['auth', 'verified']);
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard'); Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
// Master Data Cetak Label
Route::prefix('master')->name('master.')->group(function(){
});
Route::resource('directorat', DirectoratController::class); Route::resource('directorat', DirectoratController::class);
Route::resource('sub-directorat', SubDirectoratController::class); Route::resource('sub-directorat', SubDirectoratController::class);
Route::resource('job', JobController::class); Route::resource('job', JobController::class);
Route::resource('sub-job', SubJobController::class); Route::resource('sub-job', SubJobController::class);
Route::resource('sub-sub-job', SubSubJobController::class); Route::resource('sub-sub-job', SubSubJobController::class);
// Users Management
Route::prefix('user')->name('user.')->group(function(){
Route::resource('roles', RolesController::class);
Route::resource('permissions', PermissionsController::class);
Route::resource('users', UsersController::class);
});
// Logs pages
Route::prefix('log')->name('log.')->group(function () {
Route::resource('system', SystemLogsController::class)->only(['index', 'destroy']);
Route::resource('audit', AuditLogsController::class)->only(['index', 'destroy']);
});
}); });