Skip to content

Commit

Permalink
Use Laravel Pint to improve code style consistency (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
HabuTheTiger authored Nov 20, 2024
2 parents dd61d18 + b36979e commit d46561b
Show file tree
Hide file tree
Showing 166 changed files with 1,515 additions and 1,410 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,3 @@ jobs:
command: diff
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}



12 changes: 10 additions & 2 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ on:

jobs:
laravel-tests:

runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
Expand Down Expand Up @@ -44,3 +42,13 @@ jobs:
DB_USERNAME: root
DB_PASSWORD: ""
run: vendor/bin/pest

laravel-pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "laravel-pint"
uses: aglipanci/laravel-pint-action@latest
with:
testMode: true
pintVersion: 1.18.1
3 changes: 2 additions & 1 deletion app/Console/Commands/User/UserChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public function handle(): void
{
$email = $this->argument('email');
$user = User::where('email', $email)->first();
if (!$user) {
if (! $user) {
$this->error('User not found');

return;
}
$password = $this->secret('New Password');
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Console\Commands\appsSyncCommand;
use App\Console\Commands\ClearUnverifiedCommand;
use App\Console\Commands\GenerateRulesCommand;
use App\Console\Commands\User\UserChangePasswordCommand;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
Expand Down Expand Up @@ -42,7 +41,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
5 changes: 1 addition & 4 deletions app/Events/AppLoginEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ class AppLoginEvent
{
use Dispatchable;

public function __construct(readonly public string $clientId, readonly public string $userId)
{

}
public function __construct(readonly public string $clientId, readonly public string $userId) {}
}
1 change: 1 addition & 0 deletions app/Events/NewProfilePhotoEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class NewProfilePhotoEvent
use Dispatchable;

public User $user;

public string $path;

public function __construct(User $user, string $path)
Expand Down
3 changes: 1 addition & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function render(
return $response;
}


if (!in_array($status, [401, 402, 403, 404, 405, 500, 503])) {
if (! in_array($status, [401, 402, 403, 404, 405, 500, 503])) {
return $response;
}

Expand Down
11 changes: 6 additions & 5 deletions app/Filament/Resources/ActivityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Filament\Resources\ActivityResource\Pages;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Filament\Tables\Columns\Column;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Models\Activity;

Expand All @@ -24,15 +24,16 @@ public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('description')->formatStateUsing(fn(string $state) => __("activity." . $state)),
TextColumn::make('causer.name')->description(fn(Activity $record): string => ($record->causer_type ?? "")),
TextColumn::make('description')->formatStateUsing(fn (string $state) => __('activity.' . $state)),
TextColumn::make('causer.name')->description(fn (Activity $record): string => ($record->causer_type ?? '')),
TextColumn::make('subject.name')
->formatStateUsing(static function (Column $column, $state): ?string {
$record = $column->getRecord();
$record->load('subject', 'causer');
return $record->subject->name ?? $record->subject->data['client_name'] ?? $record->subject->id ?? "";

return $record->subject->name ?? $record->subject->data['client_name'] ?? $record->subject->id ?? '';
})
->description(fn(Activity $record): string => ($record->subject_type ?? "")),
->description(fn (Activity $record): string => ($record->subject_type ?? '')),

// TextColumn::make('changes'),
TextColumn::make('created_at')->label('Date')->dateTime()->description(function (Activity $record) {
Expand Down
54 changes: 27 additions & 27 deletions app/Filament/Resources/AppResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,37 @@ public static function form(Form $form): Form
Tabs\Tab::make('Login')->icon('heroicon-o-arrow-left-on-rectangle')->schema([
TagsInput::make('data.redirect_uris')->columnSpan(2),
Select::make('data.subject_type')->options([
"public" => "public",
"pairwise" => "pairwise",
'public' => 'public',
'pairwise' => 'pairwise',
])->columnSpan(2),
Select::make('data.grant_types')->multiple()->options([
"authorization_code" => "authorization_code",
"refresh_token" => "refresh_token",
"implicit" => "implicit",
"client_credentials" => "client_credentials",
'authorization_code' => 'authorization_code',
'refresh_token' => 'refresh_token',
'implicit' => 'implicit',
'client_credentials' => 'client_credentials',
])->columnSpan(2),
Select::make('data.response_types')->multiple()->options([
"code" => "code",
"id_token" => "id_token",
"token" => "token",
'code' => 'code',
'id_token' => 'id_token',
'token' => 'token',
])->columnSpan(2),
]),
Tabs\Tab::make('Token')->icon('heroicon-o-lock-closed')->schema([
Select::make('data.token_endpoint_auth_method')->options([
"client_secret_post" => "client_secret_post",
"client_secret_basic" => "client_secret_basic",
"private_key_jwt" => "private_key_jwt",
"none" => "none",
'client_secret_post' => 'client_secret_post',
'client_secret_basic' => 'client_secret_basic',
'private_key_jwt' => 'private_key_jwt',
'none' => 'none',
]),
TextInput::make('data.jwks_uri')
->helperText('When authenticating with a signed jwks key against the token endpoint, you may enter a path to a keys.json containing the public keys of your app here.')
->url(),

CheckboxList::make('data.scope')->options(static function () {
return collect((new Client())->getScopes())->mapWithKeys(fn($v) => [$v => $v]);
return collect((new Client())->getScopes())->mapWithKeys(fn ($v) => [$v => $v]);
})->afterStateHydrated(function (CheckboxList $component, $state) {
if (!is_array($state)) {
$state = explode(" ", $state);
if (! is_array($state)) {
$state = explode(' ', $state);
}
$component->state($state);
}),
Expand Down Expand Up @@ -122,9 +122,9 @@ public static function form(Form $form): Form
Tabs\Tab::make('Request')->icon('heroicon-o-signal')->schema([
TagsInput::make('data.request_uris')->columnSpan(2),
Select::make('data.request_object_signing_alg')->options([
"none" => "none",
"RS256" => "RS256",
"ES256" => "ES256",
'none' => 'none',
'RS256' => 'RS256',
'ES256' => 'ES256',
])->columnSpan(2),
]),

Expand Down Expand Up @@ -160,22 +160,22 @@ public static function form(Form $form): Form
TextInput::make('description')->required(),
Select::make('icon')->options(function () {
return collect(scandir(resource_path('js/Components/Icons')))
->filter(fn($icon) => !in_array($icon, ['.', '..']))
->map(fn($icon) => str_replace('.vue', '', $icon))
->filter(fn ($icon) => ! in_array($icon, ['.', '..']))
->map(fn ($icon) => str_replace('.vue', '', $icon))
->values()
->keyBy(fn($icon) => $icon)
->keyBy(fn ($icon) => $icon)
->toArray();
})->hint('Request new Icons @ Thiritin')->required(),
TextInput::make('url')->url(),
]),
Card::make()->schema([
Placeholder::make('created_at')
->label("Created At")
->content(fn(?App $record): string => $record?->created_at?->diffForHumans() ?? '-'),
->label('Created At')
->content(fn (?App $record): string => $record?->created_at?->diffForHumans() ?? '-'),

Placeholder::make('updated_at')
->label("Updated At")
->content(fn(?App $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
->label('Updated At')
->content(fn (?App $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
]),

]),
Expand Down Expand Up @@ -211,7 +211,7 @@ public static function getRelations(): array
public static function getGloballySearchableAttributes(): array
{
return [
"name",
'name',
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Table;
use Filament\Tables;
use Filament\Tables\Table;

class GroupsRelationManager extends RelationManager
{
Expand Down
27 changes: 13 additions & 14 deletions app/Filament/Resources/GroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class GroupResource extends Resource
{

protected static ?string $model = Group::class;

protected static ?string $slug = 'groups';

protected static ?string $recordTitleAttribute = 'name';

protected static ?string $navigationIcon = "heroicon-o-users";
protected static ?string $navigationIcon = 'heroicon-o-users';

public static function form(Form $form): Form
{
Expand All @@ -38,23 +37,23 @@ public static function form(Form $form): Form
FilamentGroup::make()->columns()->schema([
Placeholder::make('id')
->label('Internal ID')
->content(fn(?Group $record): string => $record?->id ?? '-'),
->content(fn (?Group $record): string => $record?->id ?? '-'),
Placeholder::make('hashid')
->label('Public ID')
->content(fn(?Group $record): string => $record?->hashid() ?? '-'),
->content(fn (?Group $record): string => $record?->hashid() ?? '-'),
]),
TextInput::make('system_name')
->label('System Name')
->hint('Unique system name, should be left empty in most cases.')
->unique('groups', 'system_name', ignoreRecord: true)
->disabled(fn(?Group $record) => $record?->exists),
->disabled(fn (?Group $record) => $record?->exists),
TextInput::make('name')
->required(),
TextInput::make('nextcloud_folder_name')
->label('Nextcloud Folder Name')
->hiddenOn('create')
->required(fn(Group|null $record
) => $record !== null && !empty($record->nextcloud_folder_id))
->required(fn (?Group $record
) => $record !== null && ! empty($record->nextcloud_folder_id))
->hint('Leave empty if the group should not be allowed to access Nextcloud.')
->unique('groups', 'nextcloud_folder_name', ignoreRecord: true),
Textarea::make('description')->rows(5),
Expand All @@ -65,19 +64,19 @@ public static function form(Form $form): Form
Section::make()->schema([

Select::make('type')->options([
GroupTypeEnum::Default->value => "Default",
GroupTypeEnum::Automated->value => "Automated",
GroupTypeEnum::Department->value => "Department",
GroupTypeEnum::Default->value => 'Default',
GroupTypeEnum::Automated->value => 'Automated',
GroupTypeEnum::Department->value => 'Department',
])->required(),
]),

Placeholder::make('created_at')
->label('Created Date')
->content(fn(?Group $record): string => $record?->created_at?->diffForHumans() ?? '-'),
->content(fn (?Group $record): string => $record?->created_at?->diffForHumans() ?? '-'),

Placeholder::make('updated_at')
->label('Last Modified Date')
->content(fn(?Group $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
->content(fn (?Group $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
]),
])->columns(3);
}
Expand All @@ -91,7 +90,7 @@ public static function table(Table $table): Table
->sortable(),
TextColumn::make('type')
->sortable()
->formatStateUsing(fn($state) => ucfirst($state->value)),
->formatStateUsing(fn ($state) => ucfirst($state->value)),
])
->actions([
EditAction::make(),
Expand Down
2 changes: 0 additions & 2 deletions app/Filament/Resources/GroupResource/Pages/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace App\Filament\Resources\GroupResource\Pages;

use App\Filament\Resources\GroupResource;
use Filament\Pages\Actions\LocaleSwitcher;
use Filament\Resources\Pages\CreateRecord;
use Filament\Resources\Pages\CreateRecord\Concerns\Translatable;

class CreateGroup extends CreateRecord
{
Expand Down
2 changes: 0 additions & 2 deletions app/Filament/Resources/GroupResource/Pages/EditGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use App\Filament\Resources\GroupResource;
use Filament\Pages\Actions\DeleteAction;
use Filament\Pages\Actions\LocaleSwitcher;
use Filament\Resources\Pages\EditRecord;
use Filament\Resources\Pages\EditRecord\Concerns\Translatable;

class EditGroup extends EditRecord
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Table;
use Filament\Tables;
use Filament\Tables\Actions\AttachAction;
use Filament\Tables\Table;

class UsersRelationManager extends RelationManager
{
Expand All @@ -30,7 +30,7 @@ public function table(Table $table): Table
//
])
->headerActions([
AttachAction::make()->form(fn(AttachAction $action): array => [
AttachAction::make()->form(fn (AttachAction $action): array => [
$action->getRecordSelect(),
Forms\Components\Select::make('level')->required()
->options(GroupUserLevel::class),
Expand Down
7 changes: 4 additions & 3 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class UserResource extends Resource
protected static ?string $slug = 'users';

protected static ?string $recordTitleAttribute = 'name';
protected static ?string $navigationIcon = "heroicon-o-user";

protected static ?string $navigationIcon = 'heroicon-o-user';

public static function form(Form $form): Form
{
Expand All @@ -50,11 +51,11 @@ public static function form(Form $form): Form

Placeholder::make('created_at')
->label('Created Date')
->content(fn(?User $record): string => $record?->created_at?->diffForHumans() ?? '-'),
->content(fn (?User $record): string => $record?->created_at?->diffForHumans() ?? '-'),

Placeholder::make('updated_at')
->label('Last Modified Date')
->content(fn(?User $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
->content(fn (?User $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
]);
}

Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ protected function getHeaderActions(): array
->label('Reset 2FA')
->requiresConfirmation()
->color('danger')
->visible(fn(User $record) => $record->twoFactors()->exists())
->visible(fn (User $record) => $record->twoFactors()->exists())
->action(function () {
$this->record->resetTwoFactorAuth();
}),
$this->record->resetTwoFactorAuth();
}),
];
}
}
Loading

0 comments on commit d46561b

Please sign in to comment.