chore: code styling via pint

This commit is contained in:
idevakk
2025-11-14 01:51:35 -08:00
parent 3892c48ef2
commit 90ab79b3a2
121 changed files with 1003 additions and 892 deletions

View File

@@ -2,35 +2,39 @@
namespace App\Filament\Pages;
use Illuminate\Database\Eloquent\Builder;
use Filament\Actions\BulkAction;
use App\Models\ActivationKey;
use App\Models\Plan;
use Filament\Actions\BulkAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Tables\Columns\BooleanColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Response;
use Str;
use Filament\Notifications\Notification;
class GenerateActivationKeys extends Page implements HasForms, HasTable
{
use InteractsWithForms, InteractsWithTable;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-key';
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-key';
protected string $view = 'filament.pages.generate-activation-keys';
protected static string | \UnitEnum | null $navigationGroup = 'Admin';
protected static string|\UnitEnum|null $navigationGroup = 'Admin';
protected static ?string $title = 'Activation Keys';
public $plan_id;
public $quantity = 1;
public function mount(): void
@@ -97,10 +101,10 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
->label('Interval')
->getStateUsing(function ($record) {
$isMonthly = Plan::where('pricing_id', $record->price_id)->value('monthly_billing');
return $isMonthly ? 'Monthly' : 'Yearly';
}),
TextColumn::make('created_at')
->dateTime(),
];
@@ -136,12 +140,12 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
{
$text = $records->pluck('activation_key')->implode("\n");
$filename = 'activation_keys_' . now()->timestamp . '.txt';
$filename = 'activation_keys_'.now()->timestamp.'.txt';
// Store the file in the 'public' directory or a subdirectory within 'public'
$path = public_path("activation/{$filename}");
// Make sure the 'activation' folder exists, create it if it doesn't
if (!file_exists(public_path('activation'))) {
if (! file_exists(public_path('activation'))) {
mkdir(public_path('activation'), 0777, true);
}
@@ -151,5 +155,4 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
// Return the response that allows users to download the file directly
return response()->download($path)->deleteFileAfterSend(true);
}
}

View File

@@ -2,13 +2,10 @@
namespace App\Filament\Pages;
use Filament\Schemas\Schema;
use Filament\Schemas\Components\Section;
use Exception;
use App\Models\Setting;
use App\Models\ZEmail;
use Artisan;
use Ddeboer\Imap\Server;
use Exception;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\KeyValue;
use Filament\Forms\Components\Repeater;
@@ -19,6 +16,8 @@ use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class Settings extends Page implements HasForms
{
@@ -26,11 +25,11 @@ class Settings extends Page implements HasForms
public ?array $data = [];
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cog-6-tooth';
protected string $view = 'filament.pages.settings';
protected static string | \UnitEnum | null $navigationGroup = 'Web Master';
protected static string|\UnitEnum|null $navigationGroup = 'Web Master';
public function mount(): void
{
@@ -51,7 +50,7 @@ class Settings extends Page implements HasForms
]);
$this->applyDefaults($configurationSettings, [
'cron_password' => fn() => $this->generateRandomString(20),
'cron_password' => fn () => $this->generateRandomString(20),
'date_format' => 'd M Y h:i A',
'after_last_email_delete' => 'redirect_to_homepage',
]);
@@ -92,7 +91,6 @@ class Settings extends Page implements HasForms
'ads_settings' => $adsSettings,
]);
} else {
$this->form->fill([
'app_admin' => $auth_email,
@@ -142,13 +140,12 @@ class Settings extends Page implements HasForms
->collapsed()
->schema([
Repeater::make('app_social')
->statePath('app_social')
->schema([
TextInput::make('icon')->label('Icon')->required()->maxLength(100),
TextInput::make('url')->label('URL')->url()->required()->maxLength(255),
])
]),
]),
@@ -161,7 +158,7 @@ class Settings extends Page implements HasForms
Select::make('imap_settings.encryption')->options([
'none' => 'None',
'ssl' => 'SSL',
'tls' => 'TLS'
'tls' => 'TLS',
]),
Checkbox::make('imap_settings.validate_cert')->label('Validate Encryption Certificate')->default(false),
TextInput::make('imap_settings.username')->label('Username')->required(),
@@ -180,7 +177,7 @@ class Settings extends Page implements HasForms
Select::make('imap_settings.premium_encryption')->options([
'none' => 'None',
'ssl' => 'SSL',
'tls' => 'TLS'
'tls' => 'TLS',
]),
Checkbox::make('imap_settings.premium_validate_cert')->label('Validate Encryption Certificate')->default(false),
TextInput::make('imap_settings.premium_username')->label('Username')->required(),
@@ -197,64 +194,64 @@ class Settings extends Page implements HasForms
Section::make('General Configuration')
->columns(2)
->schema([
Checkbox::make('configuration_settings.enable_masking_external_link')
->label('Enable URL Masking of External URL')
->default(false)
->columnSpan(1)
->helperText('If you enable this, then we will use href.li to remove your site footprint being passed-on to external link.'),
Checkbox::make('configuration_settings.disable_mailbox_slug')
->label('Disable Mailbox Slug')
->default(false)
->columnSpan(1)
->helperText('If you enable this, then we will disable mailbox slug.'),
Checkbox::make('configuration_settings.enable_create_from_url')
->label('Enable Mail ID Creation from URL')
->default(true)
->columnSpan(1)
->helperText('If you enable this, then users will be able to create email ID from URL.'),
Checkbox::make('configuration_settings.enable_ad_block_detector')
->label('Enable Ad Block Detector')
->default(true)
->columnSpan(1)
->helperText('If you enable this, then we block all the users from using when that have Ad Blocker enabled.'),
KeyValue::make('configuration_settings.font_family')
->label('Font Family')
->columnSpan(2)
->helperText('Use Google Fonts with exact name.')
]),
Checkbox::make('configuration_settings.enable_masking_external_link')
->label('Enable URL Masking of External URL')
->default(false)
->columnSpan(1)
->helperText('If you enable this, then we will use href.li to remove your site footprint being passed-on to external link.'),
Checkbox::make('configuration_settings.disable_mailbox_slug')
->label('Disable Mailbox Slug')
->default(false)
->columnSpan(1)
->helperText('If you enable this, then we will disable mailbox slug.'),
Checkbox::make('configuration_settings.enable_create_from_url')
->label('Enable Mail ID Creation from URL')
->default(true)
->columnSpan(1)
->helperText('If you enable this, then users will be able to create email ID from URL.'),
Checkbox::make('configuration_settings.enable_ad_block_detector')
->label('Enable Ad Block Detector')
->default(true)
->columnSpan(1)
->helperText('If you enable this, then we block all the users from using when that have Ad Blocker enabled.'),
KeyValue::make('configuration_settings.font_family')
->label('Font Family')
->columnSpan(2)
->helperText('Use Google Fonts with exact name.'),
]),
Select::make('configuration_settings.default_language')->options([
'ar' => 'Arabic',
'de' => 'German',
'en' => 'English',
'fr' => 'French',
'hi' => 'Hindi',
'pl' => 'Polish',
'ru' => 'Russian',
'es' => 'Spanish',
'vi' => 'Viet',
'tr' => 'Turkish',
'no' => 'Norwegian',
'id' => 'Indonesian',
'ar' => 'Arabic',
'de' => 'German',
'en' => 'English',
'fr' => 'French',
'hi' => 'Hindi',
'pl' => 'Polish',
'ru' => 'Russian',
'es' => 'Spanish',
'vi' => 'Viet',
'tr' => 'Turkish',
'no' => 'Norwegian',
'id' => 'Indonesian',
]),
Section::make('Domains & Gmail Usernames')
->collapsed()
->columns(2)
->schema([
Repeater::make('configuration_settings.domains')
->statePath('configuration_settings.domains')
->columnSpan(1)
->schema([
TextInput::make('domain')->label('Domain')->required()->maxLength(30),
]),
Repeater::make('configuration_settings.gmailUsernames')
->statePath('configuration_settings.gmailUsernames')
->columnSpan(1)
->schema([
TextInput::make('gmailUsername')->label('Gmail Username')->required()->maxLength(30),
]),
]),
Repeater::make('configuration_settings.domains')
->statePath('configuration_settings.domains')
->columnSpan(1)
->schema([
TextInput::make('domain')->label('Domain')->required()->maxLength(30),
]),
Repeater::make('configuration_settings.gmailUsernames')
->statePath('configuration_settings.gmailUsernames')
->columnSpan(1)
->schema([
TextInput::make('gmailUsername')->label('Gmail Username')->required()->maxLength(30),
]),
]),
Section::make('Premium Domains & Gmail Usernames')
->collapsed()
@@ -356,7 +353,6 @@ class Settings extends Page implements HasForms
->statePath('data');
}
public function flushCache(): void
{
try {
@@ -378,7 +374,7 @@ class Settings extends Page implements HasForms
try {
$data = $this->form->getState();
if (!$this->testIMAP($data['imap_settings'])) {
if (! $this->testIMAP($data['imap_settings'])) {
return;
} else {
Notification::make()
@@ -389,9 +385,9 @@ class Settings extends Page implements HasForms
foreach ([
'protocol' => 'imap',
'default_account' => 'default',
'premium_protocol' => 'imap',
'premium_default_account' => 'default',
] as $key => $default) {
'premium_protocol' => 'imap',
'premium_default_account' => 'default',
] as $key => $default) {
$data['imap_settings'][$key] ??= $default;
}
@@ -403,7 +399,7 @@ class Settings extends Page implements HasForms
'outlookUsernames' => 'outlookUsername',
'premium_outlookUsernames' => 'premium_outlookUsername',
'forbidden_ids' => 'forbidden_id',
'blocked_domains' => 'blocked_domain'
'blocked_domains' => 'blocked_domain',
];
foreach ($pluckMap as $key => $subKey) {
@@ -423,13 +419,13 @@ class Settings extends Page implements HasForms
$app_admin = $setting->app_admin;
if ($app_admin == $auth_email) {
$update_res = $setting->update($data);
if($update_res) {
if ($update_res) {
Notification::make()
->title('Saved successfully')
->success()
->send();
}
} else {
} else {
Notification::make()
->title('Please Login With Administrator Credentials')
->danger()
@@ -453,7 +449,7 @@ class Settings extends Page implements HasForms
];
$create_res = Setting::create(array_merge($data));
if($create_res) {
if ($create_res) {
Notification::make()
->title('Saved successfully')
->success()
@@ -476,10 +472,12 @@ class Settings extends Page implements HasForms
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
private function applyDefaults(array &$target, array $defaults): void {
private function applyDefaults(array &$target, array $defaults): void
{
foreach ($defaults as $key => $value) {
$target[$key] ??= is_callable($value) ? $value() : $value;
}
@@ -489,16 +487,18 @@ class Settings extends Page implements HasForms
{
try {
// First check if IMAP extension is available
if (!function_exists('imap_open')) {
if (! function_exists('imap_open')) {
Notification::make()
->title('IMAP Extension Not Available')
->body('The PHP IMAP extension is not loaded in your web server. Please check your Herd PHP configuration or restart your server.')
->danger()
->send();
return false;
}
ZEmail::connectMailBox($imap);
return true;
} catch (Exception $exception) {
$errorMessage = $exception->getMessage();
@@ -509,9 +509,10 @@ class Settings extends Page implements HasForms
}
Notification::make()
->title('IMAP Error: ' . $errorMessage)
->title('IMAP Error: '.$errorMessage)
->danger()
->send();
return false;
}
}