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

@ -12,6 +12,7 @@
* 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)
@ -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

@ -12,6 +12,7 @@ class RolesDataTable 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)
@ -35,6 +36,7 @@ class RolesDataTable extends DataTable
* Get query source of dataTable. * Get query source of dataTable.
* *
* @param \Spatie\Permission\Models\Role $model * @param \Spatie\Permission\Models\Role $model
*
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
public function query(Role $model) public function query(Role $model)
@ -89,7 +91,8 @@ class RolesDataTable extends DataTable
* *
* @return string * @return string
*/ */
protected function filename() : string protected function filename()
: string
{ {
return 'Roles_' . date('YmdHis'); return 'Roles_' . date('YmdHis');
} }

View File

@ -12,6 +12,7 @@ class UsersDataTable 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)
@ -91,7 +92,8 @@ class UsersDataTable extends DataTable
* *
* @return string * @return string
*/ */
protected function filename() : string protected function filename()
: string
{ {
return 'Users_' . date('YmdHis'); return 'Users_' . date('YmdHis');
} }

View File

@ -4,8 +4,7 @@ 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.
* *

View File

@ -4,8 +4,7 @@ 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.
* *

View File

@ -4,8 +4,7 @@ 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.
* *

View File

@ -4,8 +4,7 @@ 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.
* *

View File

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Spatie\Permission\PermissionRegistrar; use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration class CreatePermissionTables extends Migration
@ -19,10 +19,10 @@ class CreatePermissionTables extends Migration
$teams = config('permission.teams'); $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)) { 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.'); 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) { Schema::create($tableNames['permissions'], function (Blueprint $table) {
@ -129,7 +129,7 @@ class CreatePermissionTables extends Migration
$tableNames = config('permission.table_names'); $tableNames = config('permission.table_names');
if (empty($tableNames)) { 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.'); 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['role_has_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

@ -4,12 +4,12 @@
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(): void public function up()
: void
{ {
Schema::table('permissions', function ($table) { Schema::table('permissions', function ($table) {
$table->foreignIdFor(PermissionGroup::class); $table->foreignIdFor(PermissionGroup::class);
@ -19,7 +19,8 @@
/** /**
* Reverse the migrations. * Reverse the migrations.
*/ */
public function down(): void public function down()
: void
{ {
Schema::dropForeignKey('permission_group_id'); Schema::dropForeignKey('permission_group_id');
Schema::dropColumn('permission_group_id'); Schema::dropColumn('permission_group_id');

View File

@ -2,8 +2,8 @@
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
{ {

View File

@ -10,7 +10,8 @@ class Permission extends SpatiePermission
{ {
use LogsActivity; use LogsActivity;
public function getActivitylogOptions(): LogOptions public function getActivitylogOptions()
: LogOptions
{ {
return LogOptions::defaults()->logAll() return LogOptions::defaults()->logAll()
->useLogName('master data'); ->useLogName('master data');

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

@ -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());

View File

@ -2,8 +2,8 @@
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
{ {
@ -37,20 +37,6 @@ class RouteServiceProvider extends ServiceProvider
$this->mapWebRoutes(); $this->mapWebRoutes();
} }
/**
* 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 "api" routes for the application. * Define the "api" routes for the application.
* *
@ -65,4 +51,18 @@ class RouteServiceProvider extends ServiceProvider
->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

@ -2,8 +2,9 @@
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
{ {
@ -31,13 +32,21 @@ class UsermanagerServiceProvider extends ServiceProvider
} }
/** /**
* Register the service provider. * Register translations.
* *
* @return void * @return void
*/ */
public function register() public function registerTranslations()
{ {
$this->app->register(RouteServiceProvider::class); $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'));
}
} }
/** /**
@ -73,22 +82,26 @@ class UsermanagerServiceProvider extends ServiceProvider
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); $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 translations. * Register the service provider.
* *
* @return void * @return void
*/ */
public function registerTranslations() public function register()
{ {
$langPath = resource_path('lang/modules/' . $this->moduleNameLower); $this->app->register(RouteServiceProvider::class);
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'));
}
} }
/** /**
@ -100,15 +113,4 @@ class UsermanagerServiceProvider extends ServiceProvider
{ {
return []; return [];
} }
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;
}
} }

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

@ -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

@ -36,7 +36,8 @@
<!--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">

View File

@ -54,7 +54,8 @@
<!--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">

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

@ -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

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