Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Oct 15, 2023
1 parent 85da185 commit e4a155f
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 53 deletions.
21 changes: 8 additions & 13 deletions app/Filament/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Igaster\LaravelTheme\Facades\Theme;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class Settings extends Page
Expand Down Expand Up @@ -112,7 +111,7 @@ public function getSavedNotification(): ?Notification
public function getFormActions()
{
return [
Action::make('save')->label('Save')->submit('save')->keyBindings(['mod+s'])
Action::make('save')->label('Save')->submit('save')->keyBindings(['mod+s']),
];
}

Expand All @@ -134,7 +133,6 @@ protected function getForms(): array
];
}


protected function getFormSchema(): array
{
$schema = [];
Expand All @@ -145,23 +143,21 @@ protected function getFormSchema(): array
$settings->map(function ($setting) {
if ($setting->type === 'date') {
return DatePicker::make($setting->key)->label($setting->name)->helperText($setting->description)->format('Y-m-d');
} else if ($setting->type === 'boolean' || $setting->type === 'bool') {
} elseif ($setting->type === 'boolean' || $setting->type === 'bool') {
return Toggle::make($setting->key)->label($setting->name)->helperText($setting->description)->offIcon('heroicon-m-x-circle')->offColor('danger')->onIcon('heroicon-m-check-circle')->onColor('success');
} else if ($setting->type === 'int') {
} elseif ($setting->type === 'int') {
return TextInput::make($setting->key)->label($setting->name)->helperText($setting->description)->integer();
} else if ($setting->type === 'number') {
} elseif ($setting->type === 'number') {
return TextInput::make($setting->key)->label($setting->name)->helperText($setting->description)->numeric()->step(0.01);
} else if ($setting->type === 'select') {
} elseif ($setting->type === 'select') {
if ($setting->id === 'general_theme') {
return Select::make($setting->key)->label($setting->name)->helperText($setting->description)->options(list_to_assoc($this->getThemes()));
} else if ($setting->id === 'units_currency') {
} elseif ($setting->id === 'units_currency') {
return Select::make($setting->key)->label($setting->name)->helperText($setting->description)->options(list_to_assoc($this->getCurrencyList()));
} else {
return Select::make($setting->key)->label($setting->name)->helperText($setting->description)->options(list_to_assoc(explode(',', $setting->options)));
}
} else {
return TextInput::make($setting->key)->label($setting->name)->helperText($setting->description)->string();
return Select::make($setting->key)->label($setting->name)->helperText($setting->description)->options(list_to_assoc(explode(',', $setting->options)));
}
return TextInput::make($setting->key)->label($setting->name)->helperText($setting->description)->string();
})->toArray()
);
}
Expand Down Expand Up @@ -199,5 +195,4 @@ private function getCurrencyList(): array

return $curr;
}

}
7 changes: 3 additions & 4 deletions app/Filament/Resources/AwardResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static function form(Form $form): Form
$awards[$class_ref] = $award->name;
}


return $form
->schema([
Forms\Components\Section::make('Award Information')
Expand All @@ -47,7 +46,7 @@ public static function form(Form $form): Form
Forms\Components\TextInput::make('ref_model_params')->label('Award Class parammeters')->string(),
])->columnSpan(1),
Forms\Components\Toggle::make('active')->offIcon('heroicon-m-x-circle')->offColor('danger')->onIcon('heroicon-m-check-circle')->onColor('success')->default(true),
])->columns(2)
])->columns(2),
]);
}

Expand Down Expand Up @@ -89,9 +88,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListAwards::route('/'),
'index' => Pages\ListAwards::route('/'),
'create' => Pages\CreateAward::route('/create'),
'edit' => Pages\EditAward::route('/{record}/edit'),
'edit' => Pages\EditAward::route('/{record}/edit'),
];
}

Expand Down
1 change: 0 additions & 1 deletion app/Filament/Resources/AwardResource/Pages/CreateAward.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\AwardResource\Pages;

use App\Filament\Resources\AwardResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateAward extends CreateRecord
Expand Down
8 changes: 3 additions & 5 deletions app/Filament/Resources/ModuleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;

Expand All @@ -32,7 +30,7 @@ public static function form(Form $form): Form
->schema([
// Edit Only (we are not using default create action)
Forms\Components\Toggle::make('enabled')->offIcon('heroicon-m-x-circle')->offColor('danger')->onIcon('heroicon-m-check-circle')->onColor('success')->hiddenOn('create'),
Forms\Components\Hidden::make('name')->hiddenOn('create')
Forms\Components\Hidden::make('name')->hiddenOn('create'),
]);
}

Expand All @@ -54,7 +52,7 @@ public static function table(Table $table): Table
}),
Tables\Actions\DeleteAction::make()->before(function (Module $record) {
try {
File::deleteDirectory(base_path() . '/modules/' . $record->name);
File::deleteDirectory(base_path().'/modules/'.$record->name);
} catch (\Exception $e) {
Log::error('Folder Deleted Manually for Module : '.$record->name);
}
Expand All @@ -65,7 +63,7 @@ public static function table(Table $table): Table
Tables\Actions\DeleteBulkAction::make()->before(function (Collection $records) {
$records->each(function (Module $record) {
try {
File::deleteDirectory(base_path() . '/modules/' . $record->name);
File::deleteDirectory(base_path().'/modules/'.$record->name);
} catch (\Exception $e) {
Log::error('Folder Deleted Manually for Module : '.$record->name);
}
Expand Down
15 changes: 7 additions & 8 deletions app/Filament/Resources/ModuleResource/Pages/ManageModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,27 @@ protected function getHeaderActions(): array
->description('If you choose to upload a module zip file it will be installed and enabled automatically. Please not that module folder must be on top level of the zip and the zip name must be EXACTLY equal to the name of the module folder inside. If you choose to enable an already uploaded module, you have to upload it in the modules folder')
->schema([
Forms\Components\Radio::make('method')->options([
'upload' => 'Upload module zip file',
'upload' => 'Upload module zip file',
'autodiscover' => 'Enable new module (already uploaded in modules folder)',
])->default('upload')->required()->live()->inline(),
Forms\Components\FileUpload::make('moduleZip')->required(fn(Forms\Get $get): bool => $get('method') == 'upload')->visible(fn(Forms\Get $get): bool => $get('method') == 'upload')->disk('local')->directory('modules')->preserveFilenames(),
Forms\Components\Select::make('moduleId')->required(fn(Forms\Get $get): bool => $get('method') == 'autodiscover')->visible(fn(Forms\Get $get): bool => $get('method') == 'autodiscover')->label('Name')->options(app(ModuleService::class)->scan()),
Forms\Components\FileUpload::make('moduleZip')->required(fn (Forms\Get $get): bool => $get('method') == 'upload')->visible(fn (Forms\Get $get): bool => $get('method') == 'upload')->disk('local')->directory('modules')->preserveFilenames(),
Forms\Components\Select::make('moduleId')->required(fn (Forms\Get $get): bool => $get('method') == 'autodiscover')->visible(fn (Forms\Get $get): bool => $get('method') == 'autodiscover')->label('Name')->options(app(ModuleService::class)->scan()),

])
]),
])
->action(function (array $data) {
$moduleSvc = app(ModuleService::class);
if ($data['method'] == 'autodiscover') {
$moduleName = $moduleSvc->scan()[(int)$data['moduleId']];
$moduleName = $moduleSvc->scan()[(int) $data['moduleId']];
$moduleSvc->addModule($moduleName);
} else {
$moduleSvc->installModule(new UploadedFile(
storage_path('app/' . $data['moduleZip']),
storage_path('app/'.$data['moduleZip']),
explode('/', $data['moduleZip'])[array_key_last(explode('/', $data['moduleZip']))]
));

Storage::delete(storage_path('app/' . $data['moduleZip']));
Storage::delete(storage_path('app/'.$data['moduleZip']));
}

}),
];
}
Expand Down
12 changes: 5 additions & 7 deletions app/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class PageResource extends Resource
{
Expand All @@ -32,7 +30,7 @@ public static function form(Form $form): Form
Forms\Components\Grid::make('')->schema([
Forms\Components\TextInput::make('name')->label('Page Name')->required()->string()->maxLength(191),
Forms\Components\TextInput::make('icon')->string()->maxLength(191),
Forms\Components\Select::make('type')->label('Page Type')->options(PageType::select())->default(PageType::PAGE)->required()->live()
Forms\Components\Select::make('type')->label('Page Type')->options(PageType::select())->default(PageType::PAGE)->required()->live(),
])->columns(3),
Forms\Components\Grid::make('')->schema([
Forms\Components\Toggle::make('public')->offIcon('heroicon-m-x-circle')->offColor('danger')->onIcon('heroicon-m-check-circle')->onColor('success'),
Expand All @@ -53,8 +51,8 @@ public static function table(Table $table): Table
->columns([
Tables\Columns\TextColumn::make('name')->searchable(),
Tables\Columns\TextColumn::make('type')->formatStateUsing(fn ($state): string => PageType::label($state)),
Tables\Columns\IconColumn::make('public')->color(fn($state) => $state ? 'success' : 'danger')->icon(fn($state) => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle'),
Tables\Columns\IconColumn::make('enabled')->color(fn($state) => $state ? 'success' : 'danger')->icon(fn($state) => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle'),
Tables\Columns\IconColumn::make('public')->color(fn ($state) => $state ? 'success' : 'danger')->icon(fn ($state) => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle'),
Tables\Columns\IconColumn::make('enabled')->color(fn ($state) => $state ? 'success' : 'danger')->icon(fn ($state) => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle'),
])
->filters([
//
Expand Down Expand Up @@ -83,9 +81,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListPages::route('/'),
'index' => Pages\ListPages::route('/'),
'create' => Pages\CreatePage::route('/create'),
'edit' => Pages\EditPage::route('/{record}/edit'),
'edit' => Pages\EditPage::route('/{record}/edit'),
];
}
}
1 change: 0 additions & 1 deletion app/Filament/Resources/PageResource/Pages/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\PageResource\Pages;

use App\Filament\Resources\PageResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreatePage extends CreateRecord
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/PageResource/Pages/ListPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ListPages extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()->label('Add Page')->icon('heroicon-o-plus-circle')
Actions\CreateAction::make()->label('Add Page')->icon('heroicon-o-plus-circle'),
];
}
}
6 changes: 2 additions & 4 deletions app/Filament/Resources/RankResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

use App\Filament\Resources\RankResource\Pages;
use App\Filament\Resources\RankResource\RelationManagers;
use App\Models\Fare;
use App\Models\Rank;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
Expand Down Expand Up @@ -86,9 +84,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListRanks::route('/'),
'index' => Pages\ListRanks::route('/'),
'create' => Pages\CreateRank::route('/create'),
'edit' => Pages\EditRank::route('/{record}/edit'),
'edit' => Pages\EditRank::route('/{record}/edit'),
];
}

Expand Down
1 change: 0 additions & 1 deletion app/Filament/Resources/RankResource/Pages/CreateRank.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\RankResource\Pages;

use App\Filament\Resources\RankResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateRank extends CreateRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace App\Filament\Resources\RankResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class SubfleetsRelationManager extends RelationManager
{
Expand All @@ -30,7 +27,7 @@ public function table(Table $table): Table
Tables\Columns\TextColumn::make('airline.name')->label('Airline'),
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextInputColumn::make('acars_pay')->placeholder('inherited')->rules(['nullable', 'numeric', 'min:0']),
Tables\Columns\TextInputColumn::make('manual_pay')->placeholder('inherited')->rules(['nullable', 'numeric', 'min:0'])
Tables\Columns\TextInputColumn::make('manual_pay')->placeholder('inherited')->rules(['nullable', 'numeric', 'min:0']),
])
->filters([
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace App\Filament\Resources\TypeRatingResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class SubfleetsRelationManager extends RelationManager
{
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/TyperatingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function form(Form $form): Form
Forms\Components\TextInput::make('description')->label('Description'),
Forms\Components\TextInput::make('image_url')->label('Image URL'),
Forms\Components\Toggle::make('active')->offIcon('heroicon-m-x-circle')->offColor('danger')->onIcon('heroicon-m-check-circle')->onColor('success')->default(true),
])->columns(2)
])->columns(2),
]);
}

Expand Down

0 comments on commit e4a155f

Please sign in to comment.