Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed May 19, 2024
1 parent 46e8b68 commit bfa1d5f
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 65 deletions.
4 changes: 4 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"self_accessor": false,
"phpdoc_separation": false,
"phpdoc_align": false,
"function_declaration": {
"closure_function_spacing": "none",
"closure_fn_spacing": "none"
},
"no_trailing_comma_in_singleline": false,
"single_space_around_construct": false,
"phpdoc_trim_consecutive_blank_line_separation": true,
Expand Down
12 changes: 6 additions & 6 deletions src/Auth/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@ public function boot()

protected function configureAuthGuards()
{
Auth::resolved(function ($auth) {
$auth->extend('igniter-admin', function ($app, $name, array $config) use ($auth) {
Auth::resolved(function($auth) {
$auth->extend('igniter-admin', function($app, $name, array $config) use ($auth) {
return $this->createGuard(UserGuard::class, $name, $config, $auth);
});
});

Auth::resolved(function ($auth) {
$auth->extend('igniter-customer', function ($app, $name, array $config) use ($auth) {
Auth::resolved(function($auth) {
$auth->extend('igniter-customer', function($app, $name, array $config) use ($auth) {
return $this->createGuard(CustomerGuard::class, $name, $config, $auth);
});
});
}

protected function configureAuthProvider()
{
Auth::provider('igniter', function ($app, $config) {
Auth::provider('igniter', function($app, $config) {
return new UserProvider($config);
});
}

protected function configureGateCallback()
{
Gate::after(function ($user, $ability) {
Gate::after(function($user, $ability) {
if (Igniter::isAdminUser($user)) {
return $user->hasAnyPermission($ability) === true ? true : null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/PermissionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function listPermissions()
$this->registerPermissions($owner, $permissionBundle);
}

usort($this->permissions, function ($a, $b) {
usort($this->permissions, function($a, $b) {
if ($a->priority == $b->priority) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/RouteRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function all()
->middleware(config('igniter-routes.middleware', []))
->domain(config('igniter-routes.adminDomain'))
->prefix(Igniter::adminUri())
->group(function (Router $router) {
->group(function(Router $router) {
$router->any('/', [Login::class, 'index'])->name('igniter.admin');
$router->any('/login', [Login::class, 'index'])->name('igniter.admin.login');
$router->any('/login/reset/{slug?}', [Login::class, 'reset'])->name('igniter.admin.reset');
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/AllocatorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function handle(): void

AssignableLog::getUnAssignedQueue($availableSlotCount)
->lazy()
->each(fn ($assignableLog) => AllocateAssignable::dispatch($assignableLog));
->each(fn($assignableLog) => AllocateAssignable::dispatch($assignableLog));
}

public static function addSlot($slot)
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/ClearUserStateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function handle(): void
->where('value->status', UserState::CUSTOM_STATUS)
->where('value->clearAfterMinutes', '!=', 0)
->get()
->each(function ($preference) {
->each(function($preference) {
$state = json_decode($preference->value);
if (!$state->clearAfterMinutes) {
return true;
Expand Down
28 changes: 14 additions & 14 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ public function boot()
$this->defineRoutes();
$this->configureRateLimiting();

Event::listen('igniter.user.register', function (Customer $customer, array $data) {
Event::listen('igniter.user.register', function(Customer $customer, array $data) {
Notifications\CustomerRegisteredNotification::make()->subject($customer)->broadcast();
});

$this->registerAdminUserPanel();

Location::extend(function ($model) {
Location::extend(function($model) {
$model->relation['morphedByMany']['users'] = [User::class, 'name' => 'locationable'];
});

Template::registerHook('endBody', function () {
Template::registerHook('endBody', function() {
return view('igniter.user::_partials.impersonate_banner');
});
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public function registerNavigation(): array

public function registerSystemSettings()
{
Settings::registerCallback(function (Settings $manager) {
Settings::registerCallback(function(Settings $manager) {
$manager->registerSettingItems('core', [
'user' => [
'label' => 'lang:igniter.user::default.text_tab_user',
Expand Down Expand Up @@ -211,7 +211,7 @@ public function registerFormWidgets(): array
protected function registerEventGlobalParams()
{
if (class_exists(\Igniter\Automation\Classes\EventManager::class)) {
resolve(\Igniter\Automation\Classes\EventManager::class)->registerCallback(function ($manager) {
resolve(\Igniter\Automation\Classes\EventManager::class)->registerCallback(function($manager) {
$manager->registerGlobalParams([
'customer' => Auth::customer(),
]);
Expand All @@ -221,8 +221,8 @@ protected function registerEventGlobalParams()

protected function registerRequestRebindHandler()
{
$this->app->rebinding('request', function ($app, $request) {
$request->setUserResolver(function () use ($app) {
$this->app->rebinding('request', function($app, $request) {
$request->setUserResolver(function() use ($app) {
if (!Igniter::runningInAdmin()) {
return $app['admin.auth']->getUser();
}
Expand All @@ -234,7 +234,7 @@ protected function registerRequestRebindHandler()

protected function configureRateLimiting()
{
RateLimiter::for('web', function (\Illuminate\Http\Request $request) {
RateLimiter::for('web', function(\Illuminate\Http\Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->getKey() ?: $request->ip());
});

Expand All @@ -245,7 +245,7 @@ protected function configureRateLimiting()
$this->app->make(\Illuminate\Contracts\Http\Kernel::class)
->appendMiddlewareToGroup('web', \Igniter\User\Http\Middleware\ThrottleRequests::class);

Event::listen('igniter.user.beforeThrottleRequest', function ($request, $params) {
Event::listen('igniter.user.beforeThrottleRequest', function($request, $params) {
$handler = str_after($request->header('x-igniter-request-handler'), '::');
if (in_array($handler, [
'onLogin',
Expand All @@ -264,18 +264,18 @@ protected function configureRateLimiting()

protected function registerBladeDirectives()
{
$this->callAfterResolving('blade.compiler', function ($compiler, $app) {
$this->callAfterResolving('blade.compiler', function($compiler, $app) {
(new BladeExtension())->register();
});
}

protected function registerGuards(): void
{
$this->app->singleton('main.auth', function () {
$this->app->singleton('main.auth', function() {
return resolve('auth')->guard(config('igniter-auth.guards.web', 'web'));
});

$this->app->singleton('admin.auth', function () {
$this->app->singleton('admin.auth', function() {
return resolve('auth')->guard(config('igniter-auth.guards.admin', 'web'));
});
}
Expand All @@ -286,7 +286,7 @@ protected function registerAdminUserPanel()
return;
}

AdminMenu::registerCallback(function (Navigation $manager) {
AdminMenu::registerCallback(function(Navigation $manager) {
$manager->registerMainItems([
MainMenuItem::widget('notifications', \Igniter\User\MainMenuWidgets\NotificationList::class)
->priority(15)
Expand Down Expand Up @@ -320,7 +320,7 @@ protected function defineRoutes()
return;
}

Route::group([], function ($router) {
Route::group([], function($router) {
(new Classes\RouteRegistrar($router))->all();
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Actions/AssigneeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($controller)
'assigneeApplyScope',
]);

$this->controller->bindEvent('controller.beforeRemap', function () {
$this->controller->bindEvent('controller.beforeRemap', function() {
if (!$this->controller->getUser()) {
return;
}
Expand Down Expand Up @@ -78,7 +78,7 @@ protected function assigneeBindToolbarEvents()
if (isset($this->controller->widgets['toolbar'])) {
$toolbarWidget = $this->controller->widgets['toolbar'];
if ($toolbarWidget instanceof Toolbar) {
$toolbarWidget->bindEvent('toolbar.extendButtons', function () use ($toolbarWidget) {
$toolbarWidget->bindEvent('toolbar.extendButtons', function() use ($toolbarWidget) {
$toolbarWidget->removeButton('delete');
});
}
Expand All @@ -88,15 +88,15 @@ protected function assigneeBindToolbarEvents()
protected function assigneeBindListsEvents()
{
if ($this->controller->isClassExtendedWith(\Igniter\Admin\Http\Actions\ListController::class)) {
Event::listen('admin.list.extendQuery', function ($listWidget, $query) {
Event::listen('admin.list.extendQuery', function($listWidget, $query) {
if (!(bool)$this->getConfig('applyScopeOnListQuery', true)) {
return;
}

$this->assigneeApplyScope($query);
});

Event::listen('admin.filter.extendScopesBefore', function ($widget) {
Event::listen('admin.filter.extendScopesBefore', function($widget) {
if (!$this->controller->getUser()->hasRestrictedAssignableScope()) {
return;
}
Expand All @@ -109,15 +109,15 @@ protected function assigneeBindListsEvents()
protected function assigneeBindFormEvents()
{
if ($this->controller->isClassExtendedWith(\Igniter\Admin\Http\Actions\FormController::class)) {
$this->controller->bindEvent('admin.controller.extendFormQuery', function ($query) {
$this->controller->bindEvent('admin.controller.extendFormQuery', function($query) {
if (!(bool)$this->getConfig('applyScopeOnFormQuery', true)) {
return;
}

$this->assigneeApplyScope($query);
});

Event::listen('admin.form.extendFields', function (Form $widget) {
Event::listen('admin.form.extendFields', function(Form $widget) {
if (!is_a($widget->getController(), get_class($this->controller))) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/LogUserLastSeen.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function handle($request, Closure $next)
if ($authService->check()) {
$cacheKey = 'is-online-'.str_replace('.', '-', $authAlias).'-user-'.$authService->getId();
$expireAt = Carbon::now()->addMinutes(2);
Cache::remember($cacheKey, $expireAt, function () use ($authService) {
Cache::remember($cacheKey, $expireAt, function() use ($authService) {
return $authService->user()->updateLastSeen(Carbon::now());
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/MainMenuWidgets/UserPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function listMenuLinks()
NavigationExtendUserMenuLinksEvent::dispatch($items);

return $items
->mapWithKeys(function ($item, $code) {
->mapWithKeys(function($item, $code) {
$item = array_merge([
'priority' => 999,
'label' => null,
Expand All @@ -108,7 +108,7 @@ protected function listMenuLinks()
$code => (object)$item,
];
})
->filter(function ($item) {
->filter(function($item) {
return !($permission = array_get($item, 'permission')) || $this->user->hasPermission($permission);
})
->sortBy('priority');
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public function forceDelete()
{
$this->forceDeleting = true;

return tap($this->delete(), function ($deleted) {
return tap($this->delete(), function($deleted) {
$this->forceDeleting = false;
});
}

protected function performDeleteOnModel()
{
if ($this->forceDeleting) {
return tap($this->setKeysForSaveQuery($this->newModelQuery())->forceDelete(), function () {
return tap($this->setKeysForSaveQuery($this->newModelQuery())->forceDelete(), function() {
$this->exists = false;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AssignableLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function scopeWhereInAssignToGroup($query, array $assigneeGroupIds)
*/
public function scopeWhereHasAutoAssignGroup($query)
{
return $query->whereHas('assignee_group', function (Builder $query) {
return $query->whereHas('assignee_group', function(Builder $query) {
$query->where('auto_assign', 1);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Concerns/Assignable.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait Assignable
{
public static function bootAssignable()
{
static::extend(function (self $model) {
static::extend(function(self $model) {
$model->relation['belongsTo']['assignee'] = [\Igniter\User\Models\User::class];
$model->relation['belongsTo']['assignee_group'] = [\Igniter\User\Models\UserGroup::class];
$model->relation['morphMany']['assignable_logs'] = [
Expand All @@ -26,7 +26,7 @@ public static function bootAssignable()
]);
});

self::saved(function (self $model) {
self::saved(function(self $model) {
$model->performOnAssignableAssigned();
});
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public function scopeWhereInAssignToGroup($query, array $assigneeGroupIds)
*/
public function scopeWhereHasAutoAssignGroup($query)
{
return $query->whereHas('assignee_group', function (Builder $query) {
return $query->whereHas('assignee_group', function(Builder $query) {
$query->where('auto_assign', 1);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Concerns/HasCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function scopeApplyCustomer(Builder $query, $customerId): Builder
return $query->where($qualifiedColumnName, $customerId);
}

return $query->whereHas($this->getCustomerRelationName(), function (Builder $query) use ($qualifiedColumnName, $customerId) {
return $query->whereHas($this->getCustomerRelationName(), function(Builder $query) use ($qualifiedColumnName, $customerId) {
return $query->where($qualifiedColumnName, $customerId);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Concerns/SendsInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ trait SendsInvite
{
public static function bootSendsInvite()
{
static::extend(function (Model $model) {
static::extend(function(Model $model) {
$model->addPurgeable(['send_invite']);
});

static::saved(function (Model $model) {
static::saved(function(Model $model) {
$model->restorePurgedValues();
if ($model->send_invite) {
$model->sendInvite();
Expand All @@ -38,7 +38,7 @@ public function sendInvite()
'invited_at' => now(),
]);

$this->bindEventOnce('model.mailGetData', function ($view, $recipientType) use ($templateCode, $inviteCode) {
$this->bindEventOnce('model.mailGetData', function($view, $recipientType) use ($templateCode, $inviteCode) {
if ($view === $templateCode) {
return ['invite_code' => $inviteCode];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getCustomerName()

public function listAddresses()
{
return $this->addresses()->get()->groupBy(function ($address) {
return $this->addresses()->get()->groupBy(function($address) {
return $address->getKey();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Notification extends DatabaseNotification

protected static function booted(): void
{
static::created(function (self $model) {
static::created(function(self $model) {
if (is_subclass_of($model->type, CriticalNotification::class)) {
$model->notifiable->notifications()
->where('type', $model->type)
Expand Down
Loading

0 comments on commit bfa1d5f

Please sign in to comment.