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
return [
'name' => 'Usermanager'
];
return [
'name' => 'Usermanager'
];

View File

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

View File

@ -2,95 +2,98 @@
namespace Modules\Usermanager\DataTables;
use Spatie\Permission\Models\Role;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
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)
class RolesDataTable extends DataTable
{
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('usermanager::users.roles._action', compact('model'));
});
/**
* 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('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;
use Modules\Usermanager\Entities\User;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
use Modules\Usermanager\Entities\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)
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('name', 'like', "%" . $search['value'] . "%")
->orWhere('email', 'like', "%" . $search['value'] . "%");
}
})
->rawColumns(['action'])
->addIndexColumn()
->addColumn('action', function (User $model) {
return view('usermanager::users.users._action', compact('model'));
});
}
return datatables()
->eloquent($query)
->filter(function ($query) {
$search = request()->get('search');
if ($search['value'] !== "") {
$query->where('name', 'like', "%" . $search['value'] . "%")
->orWhere('email', 'like', "%" . $search['value'] . "%");
}
})
->rawColumns(['action'])
->addIndexColumn()
->addColumn('action', function (User $model) {
return view('usermanager::users.users._action', compact('model'));
});
}
/**
* Get query source of dataTable.
*
* @param \Modules\Usermanager\Entities\User $model
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query(User $model)
{
return $model->newQuery();
}
/**
* Get query source of dataTable.
*
* @param \Modules\Usermanager\Entities\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('user-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');
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->builder()
->setTableId('user-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('name')->title(__('Name')),
Column::make('email'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center')
->responsivePriority(-1),
];
}
/**
* 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('email'),
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');
/**
* Get filename for export.
*
* @return string
*/
protected function filename()
: string
{
return 'Users_' . date('YmdHis');
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

@ -1,26 +1,26 @@
<?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
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
class UserManagerDatabaseSeeder extends Seeder
{
Model::unguard();
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call([
PermissionGroupSeeder::class,
RolesSeeder::class,
PermissionsSeeder::class,
UsersSeeder::class
]);
$this->call([
PermissionGroupSeeder::class,
RolesSeeder::class,
PermissionsSeeder::class,
UsersSeeder::class
]);
}
}
}

View File

@ -1,40 +1,40 @@
<?php
namespace Modules\Usermanager\Database\factories;
namespace Modules\Usermanager\Database\factories;
use Illuminate\Database\Eloquent\Factories\Factory;
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),
];
}
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* Indicate that the model's email address should be unverified.
*
* @return static
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Modules\Usermanager\Entities\User>
*/
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
namespace Modules\Usermanager\Entities;
namespace Modules\Usermanager\Entities;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Permission\Models\Permission as SpatiePermission;
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
class Permission extends SpatiePermission
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
use LogsActivity;
public function group()
{
return $this->hasOne(PermissionGroup::class);
public function getActivitylogOptions()
: LogOptions
{
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
*/
public function register(Request $request): JsonResponse
public function register(Request $request)
: JsonResponse
{
$validator = Validator::make($request->all(), [
'name' => 'required',
@ -43,7 +44,8 @@
*
* @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])) {
$user = Auth::user();

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@
: array
{
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'
];
}

View File

@ -1,68 +1,68 @@
<?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
{
/**
* 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()
class RouteServiceProvider extends ServiceProvider
{
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.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{
parent::boot();
}
/**
* 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'));
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(module_path('Usermanager', '/Routes/api.php'));
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->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
namespace Modules\Usermanager\Providers;
namespace Modules\Usermanager\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Config;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\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()
class UsermanagerServiceProvider extends ServiceProvider
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
}
/**
* @var string $moduleName
*/
protected $moduleName = 'Usermanager';
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
/**
* @var string $moduleNameLower
*/
protected $moduleNameLower = 'usermanager';
/**
* 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);
}
/**
* 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'));
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $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;
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'));
}
}
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-slot name="logo">
<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>
</x-slot>
@ -14,31 +14,31 @@
<!-- Email Address -->
<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>
<!-- Password -->
<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>
<!-- Confirm Password -->
<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"
type="password"
name="password_confirmation" required />
type="password"
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 class="flex items-center justify-end mt-4">

View File

@ -2,12 +2,12 @@
$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>
<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() !!}
{!! 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

@ -15,7 +15,7 @@
@endphp
@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
@endforeach
</td>

View File

@ -2,31 +2,31 @@
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<!--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') }}">
<!--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::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-->
@ -35,24 +35,24 @@
<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" />
<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-->
<!--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

@ -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();
$.ajax({
url: $(this).attr('href'),
@ -93,8 +93,7 @@
type: "POST",
url: form.attr('action'),
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});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
}

View File

@ -2,12 +2,12 @@
$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>
<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() !!}
{!! 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

@ -1,7 +1,7 @@
<form id="kt_modal_add_role_form" method="POST" class="form" action="{{ route('user.roles.update',['role' => $role->id]) }}">
@method('PUT')
{{ csrf_field() }}
<!--begin::Scroll-->
@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"
@ -19,8 +19,8 @@
</div>
@error('name')
<div class="text-danger">{{ $message }}</div>
@enderror
<!--end::Input-->
@enderror
<!--end::Input-->
</div>
<!--end::Input group-->
<div class="fv-row">
@ -36,11 +36,12 @@
<!--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>
<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" />
<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-->
@ -57,8 +58,8 @@
<td>
<!--begin::Wrapper-->
<div class="d-flex">
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
<!--begin::Checkbox-->
@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

View File

@ -2,31 +2,31 @@
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<!--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') }}">
<!--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::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-->
@ -35,8 +35,8 @@
<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" />
<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-->
@ -54,11 +54,12 @@
<!--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>
<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" />
<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-->
@ -78,7 +79,7 @@
@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[]" />
<input class="form-check-input" id="permission_{{ $permission->id }}" type="checkbox" value="{{ $permission->id }}" name="permissions[]"/>
@php
$permission_name = explode('.',$permission->name);
@endphp
@ -102,20 +103,20 @@
</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-->
<!--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

@ -76,8 +76,7 @@
type: "POST",
url: form.attr('action'),
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});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
}

View File

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

@ -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();
$.ajax({
url: $(this).attr('href'),
@ -72,11 +72,11 @@
$('#{{$route[0].'_'.$route[1]}}_name').val(response.data.name);
$('#{{$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 = 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">');
@ -102,8 +102,7 @@
type: "POST",
url: form.attr('action'),
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});
LaravelDataTables["{{$route[0].'-'.$route[1]}}-table"].ajax.reload();
}

View File

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

View File

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