Reformat Codes

This commit is contained in:
daeng.deni@dharma.or.id 2023-05-21 12:37:35 +07:00
parent 514c2d4222
commit 2a2fb1c856
34 changed files with 885 additions and 879 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
return [ return [
'name' => 'Usermanager' 'name' => 'Usermanager'
]; ];

View File

@ -3,15 +3,16 @@
namespace Modules\Usermanager\DataTables; namespace Modules\Usermanager\DataTables;
use Modules\Usermanager\Entities\PermissionGroup; use Modules\Usermanager\Entities\PermissionGroup;
use Yajra\DataTables\Html\Column; use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable; use Yajra\DataTables\Services\DataTable;
class PermissionsDataTable extends DataTable class PermissionsDataTable extends DataTable
{ {
/** /**
* Build DataTable class. * Build DataTable class.
* *
* @param mixed $query Results from query() method. * @param mixed $query Results from query() method.
*
* @return \Yajra\DataTables\DataTableAbstract * @return \Yajra\DataTables\DataTableAbstract
*/ */
public function dataTable($query) public function dataTable($query)
@ -24,13 +25,13 @@
$query->where('name', 'like', "%" . $search['value'] . "%"); $query->where('name', 'like', "%" . $search['value'] . "%");
} }
}) })
->rawColumns(['action','role']) ->rawColumns(['action', 'role'])
->addIndexColumn() ->addIndexColumn()
->addColumn('name', function (PermissionGroup $model) { ->addColumn('name', function (PermissionGroup $model) {
return $model->name; return $model->name;
}) })
->addColumn('role', function (PermissionGroup $model){ ->addColumn('role', function (PermissionGroup $model) {
$role = $model->roles($model); $role = $model->roles($model);
return view('usermanager::users.permissions._checkbox', compact('role')); return view('usermanager::users.permissions._checkbox', compact('role'));
}) })
->addColumn('action', function (PermissionGroup $model) { ->addColumn('action', function (PermissionGroup $model) {
@ -61,7 +62,7 @@
->setTableId('user-permissions-table') ->setTableId('user-permissions-table')
->columns($this->getColumns()) ->columns($this->getColumns())
->minifiedAjax() ->minifiedAjax()
->orderBy(1,'asc') ->orderBy(1, 'asc')
->stateSave(false) ->stateSave(false)
->responsive() ->responsive()
->autoWidth(false) ->autoWidth(false)
@ -94,9 +95,11 @@
/** /**
* Get filename for export * Get filename for export
*
* @return string * @return string
*/ */
protected function filename() : string protected function filename()
: string
{ {
return 'Permissions_' . date('YmdHis'); return 'Permissions_' . date('YmdHis');
} }

View File

@ -2,95 +2,98 @@
namespace Modules\Usermanager\DataTables; namespace Modules\Usermanager\DataTables;
use Spatie\Permission\Models\Role; use Spatie\Permission\Models\Role;
use Yajra\DataTables\Html\Column; use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable; use Yajra\DataTables\Services\DataTable;
class RolesDataTable extends 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) * Build DataTable class.
->rawColumns(['action']) *
->addIndexColumn() * @param mixed $query Results from query() method.
->filter(function ($query) { *
if (request()->has('search')) { * @return \Yajra\DataTables\DataTableAbstract
$search = request()->get('search'); */
$query->where('name', 'like', "%" . $search['value'] . "%"); public function dataTable($query)
} {
}) return datatables()
->addColumn('action', function (Role $model) { ->eloquent($query)
return view('usermanager::users.roles._action', compact('model')); ->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('usermanager::users.roles._action', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param \Spatie\Permission\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');
}
} }
/**
* Get query source of dataTable.
*
* @param \Spatie\Permission\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

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

View File

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

View File

@ -1,37 +1,36 @@
<?php <?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{ /**
/** * Run the migrations.
* Run the migrations. *
* * @return void
* @return void */
*/ public function up()
public function up() {
{ Schema::create('password_resets', function (Blueprint $table) {
Schema::create('password_resets', function (Blueprint $table) { $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->softDeletes();
$table->unsignedBigInteger('created_by')->nullable(); $table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable(); $table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable(); $table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
* *
* @return void * @return void
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('password_resets'); Schema::dropIfExists('password_resets');
} }
}; };

View File

@ -1,41 +1,40 @@
<?php <?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{ /**
/** * Run the migrations.
* Run the migrations. *
* * @return void
* @return void */
*/ public function up()
public function up() {
{ Schema::create('failed_jobs', function (Blueprint $table) {
Schema::create('failed_jobs', function (Blueprint $table) { $table->id();
$table->id(); $table->string('uuid')->unique();
$table->string('uuid')->unique(); $table->text('connection');
$table->text('connection'); $table->text('queue');
$table->text('queue'); $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->softDeletes();
$table->unsignedBigInteger('created_by')->nullable(); $table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable(); $table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable(); $table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
* *
* @return void * @return void
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
} }
}; };

View File

@ -1,42 +1,41 @@
<?php <?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{ /**
/** * Run the migrations.
* Run the migrations. *
* * @return void
* @return void */
*/ public function up()
public function up() {
{ Schema::create('personal_access_tokens', function (Blueprint $table) {
Schema::create('personal_access_tokens', function (Blueprint $table) { $table->id();
$table->id(); $table->morphs('tokenable');
$table->morphs('tokenable'); $table->string('name');
$table->string('name'); $table->string('token', 64)->unique();
$table->string('token', 64)->unique(); $table->text('abilities')->nullable();
$table->text('abilities')->nullable(); $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->softDeletes();
$table->unsignedBigInteger('created_by')->nullable(); $table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable(); $table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable(); $table->unsignedBigInteger('deleted_by')->nullable();
}); });
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
* *
* @return void * @return void
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('personal_access_tokens'); Schema::dropIfExists('personal_access_tokens');
} }
}; };

View File

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

@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
* *

View File

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

View File

@ -1,26 +1,26 @@
<?php <?php
namespace Modules\Usermanager\Database\Seeders; namespace Modules\Usermanager\Database\Seeders;
use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Seeder;
class UserManagerDatabaseSeeder extends Seeder class UserManagerDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{ {
Model::unguard(); /**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call([ $this->call([
PermissionGroupSeeder::class, PermissionGroupSeeder::class,
RolesSeeder::class, RolesSeeder::class,
PermissionsSeeder::class, PermissionsSeeder::class,
UsersSeeder::class UsersSeeder::class
]); ]);
}
} }
}

View File

@ -1,40 +1,40 @@
<?php <?php
namespace Modules\Usermanager\Database\factories; namespace Modules\Usermanager\Database\factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Modules\Usermanager\Entities\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/** /**
* Indicate that the model's email address should be unverified. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\Modules\Usermanager\Entities\User>
*
* @return static
*/ */
public function unverified() class UserFactory extends Factory
{ {
return $this->state(fn (array $attributes) => [ /**
'email_verified_at' => null, * Define the model's default state.
]); *
* @return array<string, mixed>
*/
public function definition()
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified()
{
return $this->state(fn(array $attributes) => [
'email_verified_at' => null,
]);
}
} }
}

View File

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

View File

@ -16,7 +16,8 @@
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function register(Request $request): JsonResponse public function register(Request $request)
: JsonResponse
{ {
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'name' => 'required', 'name' => 'required',
@ -43,7 +44,8 @@
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function login(Request $request): JsonResponse public function login(Request $request)
: JsonResponse
{ {
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
$user = Auth::user(); $user = Auth::user();

View File

@ -39,7 +39,7 @@
// Store the Role... // Store the Role...
if ($validated) { if ($validated) {
try { try {
if(!isset($validated['guard_name'])){ if (!isset($validated['guard_name'])) {
$validated['guard_name'] = 'default'; $validated['guard_name'] = 'default';
} }
@ -53,7 +53,6 @@
} }
return $this->sendResponse($role, 'Role created successfully.'); return $this->sendResponse($role, 'Role created successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return $this->sendError($e->getMessage(), $e->getCode()); return $this->sendError($e->getMessage(), $e->getCode());
@ -72,7 +71,7 @@
// Store the Role... // Store the Role...
if ($validated) { if ($validated) {
try { try {
if(!isset($validated['guard_name'])){ if (!isset($validated['guard_name'])) {
$validated['guard_name'] = 'default'; $validated['guard_name'] = 'default';
} }

View File

@ -38,8 +38,8 @@
addVendor('chained-select'); addVendor('chained-select');
$roles = Role::all(); $roles = Role::all();
return $dataTable->render('usermanager::users.users.index', compact( 'roles')); return $dataTable->render('usermanager::users.users.index', compact('roles'));
} }
/** /**

View File

@ -28,7 +28,7 @@
: array : array
{ {
return [ return [
'name' => 'required|max:100|unique:roles,name', 'name' => 'required|max:100|unique:roles,name',
'guard_name' => 'nullable|max:100|string' 'guard_name' => 'nullable|max:100|string'
]; ];
} }

View File

@ -28,7 +28,7 @@
: array : array
{ {
return [ return [
'name' => 'required|max:100|unique:roles,name,' . $this->role->id, 'name' => 'required|max:100|unique:roles,name,' . $this->role->id,
'guard_name' => 'nullable|max:100|string' 'guard_name' => 'nullable|max:100|string'
]; ];
} }

View File

@ -1,68 +1,68 @@
<?php <?php
namespace Modules\Usermanager\Providers; namespace Modules\Usermanager\Providers;
use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{
/**
* The module namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $moduleNamespace = 'Modules\Usermanager\Http\Controllers';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{ {
parent::boot(); /**
} * The module namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $moduleNamespace = 'Modules\Usermanager\Http\Controllers';
/** /**
* Define the routes for the application. * Called before routes are registered.
* *
* @return void * Register any model bindings or pattern based filters.
*/ *
public function map() * @return void
{ */
$this->mapApiRoutes(); public function boot()
$this->mapWebRoutes(); {
} parent::boot();
}
/** /**
* Define the "web" routes for the application. * Define the routes for the application.
* *
* These routes all receive session state, CSRF protection, etc. * @return void
* */
* @return void public function map()
*/ {
protected function mapWebRoutes() $this->mapApiRoutes();
{ $this->mapWebRoutes();
Route::middleware('web') }
->namespace($this->moduleNamespace)
->group(module_path('Usermanager', '/Routes/web.php'));
}
/** /**
* Define the "api" routes for the application. * Define the "api" routes for the application.
* *
* These routes are typically stateless. * These routes are typically stateless.
* *
* @return void * @return void
*/ */
protected function mapApiRoutes() protected function mapApiRoutes()
{ {
Route::prefix('api') Route::prefix('api')
->middleware('api') ->middleware('api')
->namespace($this->moduleNamespace) ->namespace($this->moduleNamespace)
->group(module_path('Usermanager', '/Routes/api.php')); ->group(module_path('Usermanager', '/Routes/api.php'));
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(module_path('Usermanager', '/Routes/web.php'));
}
} }
}

View File

@ -1,114 +1,116 @@
<?php <?php
namespace Modules\Usermanager\Providers; namespace Modules\Usermanager\Providers;
use Illuminate\Support\ServiceProvider; use Config;
use Illuminate\Database\Eloquent\Factory; use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\ServiceProvider;
class UsermanagerServiceProvider extends ServiceProvider class UsermanagerServiceProvider extends ServiceProvider
{
/**
* @var string $moduleName
*/
protected $moduleName = 'Usermanager';
/**
* @var string $moduleNameLower
*/
protected $moduleNameLower = 'usermanager';
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{ {
$this->registerTranslations(); /**
$this->registerConfig(); * @var string $moduleName
$this->registerViews(); */
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); protected $moduleName = 'Usermanager';
}
/** /**
* Register the service provider. * @var string $moduleNameLower
* */
* @return void protected $moduleNameLower = 'usermanager';
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
/** /**
* Register config. * Boot the application events.
* *
* @return void * @return void
*/ */
protected function registerConfig() public function boot()
{ {
$this->publishes([ $this->registerTranslations();
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), $this->registerConfig();
], 'config'); $this->registerViews();
$this->mergeConfigFrom( $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'Resources/views');
$this->publishes([
$sourcePath => $viewPath
], ['views', $this->moduleNameLower . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'));
} }
}
/** /**
* Get the services provided by the provider. * Register translations.
* *
* @return array * @return void
*/ */
public function provides() public function registerTranslations()
{ {
return []; $langPath = resource_path('lang/modules/' . $this->moduleNameLower);
}
private function getPublishableViewPaths(): array if (is_dir($langPath)) {
{ $this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$paths = []; $this->loadJsonTranslationsFrom($langPath);
foreach (\Config::get('view.paths') as $path) { } else {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
$paths[] = $path . '/modules/' . $this->moduleNameLower; $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'));
} }
} }
return $paths;
/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
], 'config');
$this->mergeConfigFrom(
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'Resources/views');
$this->publishes([
$sourcePath => $viewPath
], ['views', $this->moduleNameLower . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}
private function getPublishableViewPaths()
: array
{
$paths = [];
foreach (Config::get('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}
return $paths;
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
} }
}

View File

@ -2,7 +2,7 @@
<x-auth-card> <x-auth-card>
<x-slot name="logo"> <x-slot name="logo">
<a href="/"> <a href="/">
<x-application-logo class="w-20 h-20 fill-current text-gray-500" /> <x-application-logo class="w-20 h-20 fill-current text-gray-500"/>
</a> </a>
</x-slot> </x-slot>
@ -14,31 +14,31 @@
<!-- Email Address --> <!-- Email Address -->
<div> <div>
<x-input-label for="email" :value="__('Email')" /> <x-input-label for="email" :value="__('Email')"/>
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus /> <x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus/>
<x-input-error :messages="$errors->get('email')" class="mt-2" /> <x-input-error :messages="$errors->get('email')" class="mt-2"/>
</div> </div>
<!-- Password --> <!-- Password -->
<div class="mt-4"> <div class="mt-4">
<x-input-label for="password" :value="__('Password')" /> <x-input-label for="password" :value="__('Password')"/>
<x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required /> <x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required/>
<x-input-error :messages="$errors->get('password')" class="mt-2" /> <x-input-error :messages="$errors->get('password')" class="mt-2"/>
</div> </div>
<!-- Confirm Password --> <!-- Confirm Password -->
<div class="mt-4"> <div class="mt-4">
<x-input-label for="password_confirmation" :value="__('Confirm Password')" /> <x-input-label for="password_confirmation" :value="__('Confirm Password')"/>
<x-text-input id="password_confirmation" class="block mt-1 w-full" <x-text-input id="password_confirmation" class="block mt-1 w-full"
type="password" type="password"
name="password_confirmation" required /> name="password_confirmation" required/>
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" /> <x-input-error :messages="$errors->get('password_confirmation')" class="mt-2"/>
</div> </div>
<div class="flex items-center justify-end mt-4"> <div class="flex items-center justify-end mt-4">

View File

@ -2,12 +2,12 @@
$route = explode('.', Route::currentRouteName()); $route = explode('.', Route::currentRouteName());
@endphp @endphp
<div class="d-flex flex-row flex-center"> <div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.'.$route[1].'.edit',['permission' => $model->id]) }}" <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"> 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") !!} {!! getIcon("pencil", "fs-1 text-info","duotune") !!}
</a> </a>
{!! Form::open(['method' => 'DELETE','route' => [$route[0].'.'.$route[1].'.destroy', $model->id],'class'=>'']) !!} {!! 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::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() !!} {!! Form::close() !!}
</div> </div>

View File

@ -15,7 +15,7 @@
@endphp @endphp
@foreach($role as $row) @foreach($role as $row)
<a href="javascript:;" class="text-capitalize badge {{ $color[$row->id] }} fs-7 m-1">{{ $row->name }}</a> <a href="javascript:" class="text-capitalize badge {{ $color[$row->id] }} fs-7 m-1">{{ $row->name }}</a>
@php $i++ @endphp @php $i++ @endphp
@endforeach @endforeach
</td> </td>

View File

@ -2,31 +2,31 @@
$route = explode('.', Route::currentRouteName()); $route = explode('.', Route::currentRouteName());
@endphp @endphp
<!--begin::Modal - New Target--> <!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_permissions" tabindex="-1" aria-hidden="true"> <div class="modal fade" id="kt_modal_user_permissions" tabindex="-1" aria-hidden="true">
<!--begin::Modal dialog--> <!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered mw-650px"> <div class="modal-dialog modal-dialog-centered mw-650px">
<!--begin::Modal content--> <!--begin::Modal content-->
<div class="modal-content rounded"> <div class="modal-content rounded">
<!--begin::Modal header--> <!--begin::Modal header-->
<div class="modal-header pb-0 border-0 justify-content-end"> <div class="modal-header pb-0 border-0 justify-content-end">
<!--begin::Close--> <!--begin::Close-->
<div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div>
<!--end::Close--> <!--end::Close-->
</div> </div>
<!--begin::Modal header--> <!--begin::Modal header-->
<!--begin::Modal body--> <!--begin::Modal body-->
<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
<!--begin:Form--> <!--begin:Form-->
<form class="form_{{$route[0].'_'.$route[1]}}" method="POST" action="{{ route($route[0].'.'.$route[1].'.store') }}"> <form class="form_{{$route[0].'_'.$route[1]}}" method="POST" action="{{ route($route[0].'.'.$route[1].'.store') }}">
@csrf @csrf
<!--begin::Heading--> <!--begin::Heading-->
<div class="mb-13 text-center"> <div class="mb-13 text-center">
<!--begin::Title--> <!--begin::Title-->
<h1 class="mb-3 text-capitalize" id="title_form">{{ str_replace('-',' ',$route[0].' '.$route[1]) }}</h1> <h1 class="mb-3 text-capitalize" id="title_form">{{ str_replace('-',' ',$route[0].' '.$route[1]) }}</h1>
<!--end::Title--> <!--end::Title-->
</div> </div>
<!--end::Heading--> <!--end::Heading-->
<!--begin::Input group--> <!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row"> <div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label--> <!--begin::Label-->
@ -35,24 +35,24 @@
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span> <span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
</label> </label>
<!--end::Label--> <!--end::Label-->
<input type="hidden" id="user_permissions_id" name="id" /> <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" /> <input type="text" id="user_permissions_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Permission Name" name="name"/>
</div> </div>
<!--end::Input group--> <!--end::Input group-->
<!--begin::Actions--> <!--begin::Actions-->
<div class="text-center"> <div class="text-center">
<button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button> <button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
</div> </div>
<!--end::Actions--> <!--end::Actions-->
</form> </form>
<!--end:Form--> <!--end:Form-->
</div> </div>
<!--end::Modal body--> <!--end::Modal body-->
</div> </div>
<!--end::Modal content--> <!--end::Modal content-->
</div> </div>
<!--end::Modal dialog--> <!--end::Modal dialog-->
</div> </div>
<!--end::Modal - New Target--> <!--end::Modal - New Target-->

View File

@ -59,7 +59,7 @@
}); });
}); });
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click','.kt_edit_form',function(event){ LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click', '.kt_edit_form', function (event) {
event.preventDefault(); event.preventDefault();
$.ajax({ $.ajax({
url: $(this).attr('href'), url: $(this).attr('href'),
@ -93,8 +93,7 @@
type: "POST", type: "POST",
url: form.attr('action'), url: form.attr('action'),
data: form.serialize(), // serializes the form's elements. data: form.serialize(), // serializes the form's elements.
success: function(data) success: function (data) {
{
toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000}); toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload(); LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
} }

View File

@ -2,12 +2,12 @@
$route = explode('.', Route::currentRouteName()); $route = explode('.', Route::currentRouteName());
@endphp @endphp
<div class="d-flex flex-row flex-center"> <div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.'.$route[1].'.edit',['role' => $model->id]) }}" <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"> 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") !!} {!! getIcon("pencil", "fs-1 text-info","duotune") !!}
</a> </a>
{!! Form::open(['method' => 'DELETE','route' => [$route[0].'.'.$route[1].'.destroy', $model->id],'class'=>'']) !!} {!! 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::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() !!} {!! Form::close() !!}
</div> </div>

View File

@ -1,7 +1,7 @@
<form id="kt_modal_add_role_form" method="POST" class="form" action="{{ route('user.roles.update',['role' => $role->id]) }}"> <form id="kt_modal_add_role_form" method="POST" class="form" action="{{ route('user.roles.update',['role' => $role->id]) }}">
@method('PUT') @method('PUT')
{{ csrf_field() }} {{ csrf_field() }}
<!--begin::Scroll--> <!--begin::Scroll-->
<div class="d-flex flex-column flex-row-fluid" id="kt_modal_add_role_scroll" data-kt-scroll="true" <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-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-dependencies="#kt_modal_add_role_header" data-kt-scroll-wrappers="#kt_modal_add_role_scroll"
@ -19,8 +19,8 @@
</div> </div>
@error('name') @error('name')
<div class="text-danger">{{ $message }}</div> <div class="text-danger">{{ $message }}</div>
@enderror @enderror
<!--end::Input--> <!--end::Input-->
</div> </div>
<!--end::Input group--> <!--end::Input group-->
<div class="fv-row"> <div class="fv-row">
@ -36,11 +36,12 @@
<!--begin::Table row--> <!--begin::Table row-->
<tr> <tr>
<td class="text-gray-800">Administrator/Superuser Access <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> <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> <td>
<!--begin::Checkbox--> <!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9"> <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" /> <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> <span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label> </label>
<!--end::Checkbox--> <!--end::Checkbox-->
@ -57,8 +58,8 @@
<td> <td>
<!--begin::Wrapper--> <!--begin::Wrapper-->
<div class="d-flex"> <div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission) @foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox--> <!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20"> <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 }} /> <input class="form-check-input" type="checkbox" id="permission_{{ $permission->id }}" value="{{ $permission->id }}" name="permissions[]" {{ $role->hasPermissionTo($permission->name) ? 'checked' : null }} />
@php @php

View File

@ -2,31 +2,31 @@
$route = explode('.', Route::currentRouteName()); $route = explode('.', Route::currentRouteName());
@endphp @endphp
<!--begin::Modal - New Target--> <!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_user_roles" tabindex="-1" aria-hidden="true"> <div class="modal fade" id="kt_modal_user_roles" tabindex="-1" aria-hidden="true">
<!--begin::Modal dialog--> <!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered modal-fullscreen"> <div class="modal-dialog modal-dialog-centered modal-fullscreen">
<!--begin::Modal content--> <!--begin::Modal content-->
<div class="modal-content rounded"> <div class="modal-content rounded">
<!--begin::Modal header--> <!--begin::Modal header-->
<div class="modal-header pb-0 border-0 justify-content-end"> <div class="modal-header pb-0 border-0 justify-content-end">
<!--begin::Close--> <!--begin::Close-->
<div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div>
<!--end::Close--> <!--end::Close-->
</div> </div>
<!--begin::Modal header--> <!--begin::Modal header-->
<!--begin::Modal body--> <!--begin::Modal body-->
<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
<!--begin:Form--> <!--begin:Form-->
<form id="form_{{$route[0].'_'.$route[1]}}" class="form_{{$route[0].'_'.$route[1]}}" method="POST" action="{{ route($route[0].'.'.$route[1].'.store') }}"> <form id="form_{{$route[0].'_'.$route[1]}}" class="form_{{$route[0].'_'.$route[1]}}" method="POST" action="{{ route($route[0].'.'.$route[1].'.store') }}">
@csrf @csrf
<!--begin::Heading--> <!--begin::Heading-->
<div class="mb-13 text-center"> <div class="mb-13 text-center">
<!--begin::Title--> <!--begin::Title-->
<h1 class="mb-3 text-capitalize" id="title_form">{{ str_replace('-',' ',$route[0].' '.$route[1]) }}</h1> <h1 class="mb-3 text-capitalize" id="title_form">{{ str_replace('-',' ',$route[0].' '.$route[1]) }}</h1>
<!--end::Title--> <!--end::Title-->
</div> </div>
<!--end::Heading--> <!--end::Heading-->
<!--begin::Input group--> <!--begin::Input group-->
<div class="d-flex flex-column mb-8 fv-row"> <div class="d-flex flex-column mb-8 fv-row">
<!--begin::Label--> <!--begin::Label-->
@ -35,8 +35,8 @@
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span> <span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
</label> </label>
<!--end::Label--> <!--end::Label-->
<input type="hidden" id="user_roles_id" name="id" /> <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" /> <input type="text" id="user_roles_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Role Name" name="name"/>
</div> </div>
<!--end::Input group--> <!--end::Input group-->
@ -54,11 +54,12 @@
<!--begin::Table row--> <!--begin::Table row-->
<tr> <tr>
<td class="text-gray-800">Administrator/Superuser Access <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> <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> <td>
<!--begin::Checkbox--> <!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-9"> <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" /> <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> <span class="form-check-label" for="kt_roles_select_all">Select all</span>
</label> </label>
<!--end::Checkbox--> <!--end::Checkbox-->
@ -78,7 +79,7 @@
@foreach($group->getpermissionsByGroupId($group->id) as $permission) @foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox--> <!--begin::Checkbox-->
<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-20"> <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[]" /> <input class="form-check-input" id="permission_{{ $permission->id }}" type="checkbox" value="{{ $permission->id }}" name="permissions[]"/>
@php @php
$permission_name = explode('.',$permission->name); $permission_name = explode('.',$permission->name);
@endphp @endphp
@ -102,20 +103,20 @@
</div> </div>
<!--end::Permissions--> <!--end::Permissions-->
<!--begin::Actions--> <!--begin::Actions-->
<div class="text-center"> <div class="text-center">
<button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button> <button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
</div> </div>
<!--end::Actions--> <!--end::Actions-->
</form> </form>
<!--end:Form--> <!--end:Form-->
</div> </div>
<!--end::Modal body--> <!--end::Modal body-->
</div> </div>
<!--end::Modal content--> <!--end::Modal content-->
</div> </div>
<!--end::Modal dialog--> <!--end::Modal dialog-->
</div> </div>
<!--end::Modal - New Target--> <!--end::Modal - New Target-->

View File

@ -76,8 +76,7 @@
type: "POST", type: "POST",
url: form.attr('action'), url: form.attr('action'),
data: form.serialize(), // serializes the form's elements. data: form.serialize(), // serializes the form's elements.
success: function(data) success: function (data) {
{
toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000}); toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload(); LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
} }

View File

@ -2,12 +2,12 @@
$route = explode('.', Route::currentRouteName()); $route = explode('.', Route::currentRouteName());
@endphp @endphp
<div class="d-flex flex-row flex-center"> <div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.'.$route[1].'.edit',['user' => $model->id]) }}" <a href="{{ route($route[0].'.'.$route[1].'.edit',['user' => $model->id]) }}"
class="kt_edit_form btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1"> 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") !!} {!! getIcon("pencil", "fs-1 text-info","duotune") !!}
</a> </a>
{!! Form::open(['method' => 'DELETE','route' => [$route[0].'.'.$route[1].'.destroy', $model->id],'class'=>'']) !!} {!! 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::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() !!} {!! Form::close() !!}
</div> </div>

View File

@ -59,7 +59,7 @@
}); });
}); });
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click','.kt_edit_form',function(event){ LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].on('click', '.kt_edit_form', function (event) {
event.preventDefault(); event.preventDefault();
$.ajax({ $.ajax({
url: $(this).attr('href'), url: $(this).attr('href'),
@ -72,11 +72,11 @@
$('#{{$route[0].'_'.$route[1]}}_name').val(response.data.name); $('#{{$route[0].'_'.$route[1]}}_name').val(response.data.name);
$('#{{$route[0].'_'.$route[1]}}_email').val(response.data.email); $('#{{$route[0].'_'.$route[1]}}_email').val(response.data.email);
if(response.data.roles.length > 0){ if (response.data.roles.length > 0) {
var role = response.data.roles[0].name; var role = response.data.roles[0].name;
var _role = role.replace(' ','-').toLowerCase(); var _role = role.replace(' ', '-').toLowerCase();
$("#role_"+_role).prop('checked', true); $("#role_" + _role).prop('checked', true);
} }
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.data.id).append('<input type="hidden" name="_method" value="PUT">'); $('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.data.id).append('<input type="hidden" name="_method" value="PUT">');
@ -102,8 +102,7 @@
type: "POST", type: "POST",
url: form.attr('action'), url: form.attr('action'),
data: form.serialize(), // serializes the form's elements. data: form.serialize(), // serializes the form's elements.
success: function(data) success: function (data) {
{
toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000}); toastr.success('{{ucfirst($route[0].' '.$route[1])}} has been deleted.', 'Success!', {timeOut: 5000});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload(); LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
} }

View File

@ -1,56 +1,56 @@
<?php <?php
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Modules\Usermanager\Http\Controllers\Auth\AuthenticatedSessionController; use Modules\Usermanager\Http\Controllers\Auth\AuthenticatedSessionController;
use Modules\Usermanager\Http\Controllers\Auth\ConfirmablePasswordController; use Modules\Usermanager\Http\Controllers\Auth\ConfirmablePasswordController;
use Modules\Usermanager\Http\Controllers\Auth\EmailVerificationNotificationController; use Modules\Usermanager\Http\Controllers\Auth\EmailVerificationNotificationController;
use Modules\Usermanager\Http\Controllers\Auth\EmailVerificationPromptController; use Modules\Usermanager\Http\Controllers\Auth\EmailVerificationPromptController;
use Modules\Usermanager\Http\Controllers\Auth\NewPasswordController; use Modules\Usermanager\Http\Controllers\Auth\NewPasswordController;
use Modules\Usermanager\Http\Controllers\Auth\PasswordResetLinkController; use Modules\Usermanager\Http\Controllers\Auth\PasswordResetLinkController;
use Modules\Usermanager\Http\Controllers\Auth\RegisteredUserController; use Modules\Usermanager\Http\Controllers\Auth\RegisteredUserController;
use Modules\Usermanager\Http\Controllers\Auth\VerifyEmailController; use Modules\Usermanager\Http\Controllers\Auth\VerifyEmailController;
Route::middleware('guest')->group(function () { Route::middleware('guest')->group(function () {
Route::get('register', [RegisteredUserController::class, 'create']) Route::get('register', [RegisteredUserController::class, 'create'])
->name('register'); ->name('register');
Route::post('register', [RegisteredUserController::class, 'store']); Route::post('register', [RegisteredUserController::class, 'store']);
Route::get('login', [AuthenticatedSessionController::class, 'create']) Route::get('login', [AuthenticatedSessionController::class, 'create'])
->name('login'); ->name('login');
Route::post('login', [AuthenticatedSessionController::class, 'store']); Route::post('login', [AuthenticatedSessionController::class, 'store']);
Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
->name('password.request'); ->name('password.request');
Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
->name('password.email'); ->name('password.email');
Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
->name('password.reset'); ->name('password.reset');
Route::post('reset-password', [NewPasswordController::class, 'store']) Route::post('reset-password', [NewPasswordController::class, 'store'])
->name('password.update'); ->name('password.update');
}); });
Route::middleware('auth')->group(function () { Route::middleware('auth')->group(function () {
Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke']) Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke'])
->name('verification.notice'); ->name('verification.notice');
Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke']) Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
->middleware(['signed', 'throttle:6,1']) ->middleware(['signed', 'throttle:6,1'])
->name('verification.verify'); ->name('verification.verify');
Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
->middleware('throttle:6,1') ->middleware('throttle:6,1')
->name('verification.send'); ->name('verification.send');
Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
->name('password.confirm'); ->name('password.confirm');
Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
Route::get('logout', [AuthenticatedSessionController::class, 'destroy']) Route::get('logout', [AuthenticatedSessionController::class, 'destroy'])
->name('logout'); ->name('logout');
}); });

View File

@ -12,7 +12,6 @@
"laravel": { "laravel": {
"providers": [], "providers": [],
"aliases": { "aliases": {
} }
} }
}, },