From 90ab79b3a277a0f7d31efc0a08dc39b802044fcf Mon Sep 17 00:00:00 2001 From: idevakk <219866223+idevakk@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:51:35 -0800 Subject: [PATCH] chore: code styling via pint --- app/ColorPicker.php | 54 ++--- app/Filament/Pages/GenerateActivationKeys.php | 21 +- app/Filament/Pages/Settings.php | 149 ++++++------- app/Filament/Resources/BlogResource.php | 40 ++-- .../BlogResource/Pages/CreateBlog.php | 1 - .../Resources/BlogResource/Pages/EditBlog.php | 4 +- .../BlogResource/Pages/ListBlogs.php | 3 +- app/Filament/Resources/CategoryResource.php | 34 ++- .../CategoryResource/Pages/CreateCategory.php | 1 - .../CategoryResource/Pages/EditCategory.php | 3 +- .../CategoryResource/Pages/ListCategories.php | 3 +- app/Filament/Resources/MenuResource.php | 27 +-- .../MenuResource/Pages/CreateMenu.php | 1 - .../Resources/MenuResource/Pages/EditMenu.php | 4 +- .../MenuResource/Pages/ListMenus.php | 3 +- app/Filament/Resources/PageResource.php | 43 ++-- .../PageResource/Pages/CreatePage.php | 1 - .../Resources/PageResource/Pages/EditPage.php | 4 +- .../PageResource/Pages/ListPages.php | 3 +- app/Filament/Resources/PlanResource.php | 35 ++- .../PlanResource/Pages/CreatePlan.php | 1 - .../Resources/PlanResource/Pages/EditPlan.php | 4 +- .../PlanResource/Pages/ListPlans.php | 3 +- app/Filament/Resources/TicketResource.php | 50 ++--- .../TicketResource/Pages/CreateTicket.php | 1 - .../TicketResource/Pages/EditTicket.php | 3 +- .../TicketResource/Pages/ListTickets.php | 3 +- .../ResponsesRelationManager.php | 13 +- app/Filament/Resources/UserResource.php | 34 ++- .../UserResource/Pages/CreateUser.php | 1 - .../Resources/UserResource/Pages/EditUser.php | 5 +- .../UserResource/Pages/ListUsers.php | 3 +- .../RelationManagers/LogsRelationManager.php | 15 +- .../UsageLogsRelationManager.php | 14 +- app/Filament/Widgets/StatsOverview.php | 6 + app/Http/Controllers/AppController.php | 58 +++-- .../Auth/VerifyEmailController.php | 2 +- app/Http/Controllers/WebhookController.php | 36 ++-- app/Http/Middleware/CheckPageSlug.php | 5 +- app/Http/Middleware/CheckUserBanned.php | 3 +- app/Http/Middleware/Locale.php | 5 +- app/Listeners/StripeEventListener.php | 19 +- app/Livewire/AddOn.php | 155 ++++++------- app/Livewire/Auth/Register.php | 3 +- app/Livewire/Blog.php | 4 +- app/Livewire/Dashboard/Bulk.php | 66 +++--- app/Livewire/Dashboard/BulkGmail.php | 16 +- app/Livewire/Dashboard/Dashboard.php | 32 +-- app/Livewire/Dashboard/Mailbox/Inbox.php | 122 +++++++---- app/Livewire/Dashboard/Pricing.php | 12 +- app/Livewire/Dashboard/Support.php | 31 ++- app/Livewire/Frontend/Action.php | 72 +++++-- app/Livewire/Frontend/Email.php | 9 +- app/Livewire/Frontend/Mailbox.php | 40 ++-- app/Livewire/Home.php | 1 + app/Livewire/Page.php | 4 +- app/Livewire/Settings/Appearance.php | 1 + app/Livewire/Settings/DeleteUserForm.php | 1 + app/Livewire/Settings/Password.php | 1 + app/Mail/TicketResponseNotification.php | 8 +- app/Models/Category.php | 5 +- app/Models/Email.php | 8 +- app/Models/Menu.php | 2 +- app/Models/Message.php | 6 +- app/Models/Meta.php | 23 +- app/Models/Page.php | 2 +- app/Models/Premium.php | 203 +++++++++++------- app/Models/RemoteEmail.php | 5 +- app/Models/Setting.php | 1 - app/Models/Ticket.php | 7 +- app/Models/TicketResponse.php | 2 +- app/NotifyMe.php | 16 +- app/Providers/AppServiceProvider.php | 2 +- app/Providers/Filament/DashPanelProvider.php | 7 +- cleanCron.php | 6 +- closeTicket.php | 6 +- config/debugbar.php | 86 ++++---- config/services.php | 2 +- database/factories/MetaFactory.php | 2 +- database/factories/RemoteEmailFactory.php | 4 +- ...251_add_oxa_pay_details_to_plans_table.php | 3 +- database/seeders/AdminSeeder.php | 1 - database/seeders/MetaSeeder.php | 5 +- database/seeders/UpdatePlansTableSeeder.php | 1 - dropattach.php | 9 +- dropattachP.php | 9 +- dropmail.php | 23 +- dropmailP.php | 16 +- inCron.php | 6 +- indisposableCron.php | 6 +- routes/console.php | 16 +- routes/web.php | 20 +- tests/Concerns/LoadsApplicationData.php | 6 +- .../Controllers/WebhookControllerTest.php | 6 +- tests/Feature/ExampleTest.php | 2 +- tests/Feature/Filament/ResourcesTest.php | 9 +- tests/Feature/Filament/UserResourceTest.php | 8 +- tests/Feature/Livewire/Auth/LoginTest.php | 6 +- tests/Feature/Livewire/Auth/RegisterTest.php | 2 +- tests/Feature/Livewire/DashboardTest.php | 2 +- tests/Feature/Livewire/FrontendTest.php | 2 +- tests/Unit/ColorPickerTest.php | 2 +- tests/Unit/Models/ActivationKeyTest.php | 2 +- tests/Unit/Models/BlogTest.php | 2 +- tests/Unit/Models/CategoryTest.php | 2 +- tests/Unit/Models/EmailTest.php | 8 +- tests/Unit/Models/LogTest.php | 2 +- tests/Unit/Models/MenuTest.php | 2 +- tests/Unit/Models/MessageTest.php | 2 +- tests/Unit/Models/MetaTest.php | 2 +- tests/Unit/Models/PageTest.php | 2 +- tests/Unit/Models/PlanTest.php | 2 +- tests/Unit/Models/PremiumEmailTest.php | 2 +- tests/Unit/Models/RemoteEmailTest.php | 2 +- tests/Unit/Models/SettingTest.php | 2 +- tests/Unit/Models/TicketResponseTest.php | 2 +- tests/Unit/Models/TicketTest.php | 2 +- tests/Unit/Models/UsageLogTest.php | 2 +- tests/Unit/Models/UserTest.php | 2 +- tests/Unit/Models/ZEmailTest.php | 2 +- tests/Unit/NotifyMeTest.php | 2 +- 121 files changed, 1003 insertions(+), 892 deletions(-) diff --git a/app/ColorPicker.php b/app/ColorPicker.php index e6a1bb8..c80c1de 100644 --- a/app/ColorPicker.php +++ b/app/ColorPicker.php @@ -7,32 +7,32 @@ trait ColorPicker public static function chooseColor($letter): array { $colorReferences = [ - "A" => ["dark" => "dark:bg-amber-500", "light" => "bg-amber-800"], - "B" => ["dark" => "dark:bg-blue-500", "light" => "bg-blue-800"], - "C" => ["dark" => "dark:bg-cyan-500", "light" => "bg-cyan-800"], - "D" => ["dark" => "dark:bg-emerald-500", "light" => "bg-emerald-800"], - "E" => ["dark" => "dark:bg-fuchsia-500", "light" => "bg-fuchsia-800"], - "F" => ["dark" => "dark:bg-gray-500", "light" => "bg-gray-800"], - "G" => ["dark" => "dark:bg-green-500", "light" => "bg-green-800"], - "H" => ["dark" => "dark:bg-indigo-500", "light" => "bg-indigo-800"], - "I" => ["dark" => "dark:bg-lime-500", "light" => "bg-lime-800"], - "J" => ["dark" => "dark:bg-neutral-500", "light" => "bg-neutral-800"], - "K" => ["dark" => "dark:bg-orange-500", "light" => "bg-orange-800"], - "L" => ["dark" => "dark:bg-pink-500", "light" => "bg-pink-800"], - "M" => ["dark" => "dark:bg-purple-500", "light" => "bg-purple-800"], - "N" => ["dark" => "dark:bg-red-500", "light" => "bg-red-800"], - "O" => ["dark" => "dark:bg-rose-500", "light" => "bg-rose-800"], - "P" => ["dark" => "dark:bg-sky-500", "light" => "bg-sky-800"], - "Q" => ["dark" => "dark:bg-slate-500", "light" => "bg-slate-800"], - "R" => ["dark" => "dark:bg-stone-500", "light" => "bg-stone-800"], - "S" => ["dark" => "dark:bg-teal-500", "light" => "bg-teal-800"], - "T" => ["dark" => "dark:bg-violet-500", "light" => "bg-violet-800"], - "U" => ["dark" => "dark:bg-yellow-500", "light" => "bg-yellow-800"], - "V" => ["dark" => "dark:bg-zinc-500", "light" => "bg-zinc-800"], - "W" => ["dark" => "dark:bg-neutral-500", "light" => "bg-neutral-800"], - "X" => ["dark" => "dark:bg-slate-500", "light" => "bg-slate-800"], - "Y" => ["dark" => "dark:bg-stone-500", "light" => "bg-stone-800"], - "Z" => ["dark" => "dark:bg-teal-500", "light" => "bg-teal-800"] + 'A' => ['dark' => 'dark:bg-amber-500', 'light' => 'bg-amber-800'], + 'B' => ['dark' => 'dark:bg-blue-500', 'light' => 'bg-blue-800'], + 'C' => ['dark' => 'dark:bg-cyan-500', 'light' => 'bg-cyan-800'], + 'D' => ['dark' => 'dark:bg-emerald-500', 'light' => 'bg-emerald-800'], + 'E' => ['dark' => 'dark:bg-fuchsia-500', 'light' => 'bg-fuchsia-800'], + 'F' => ['dark' => 'dark:bg-gray-500', 'light' => 'bg-gray-800'], + 'G' => ['dark' => 'dark:bg-green-500', 'light' => 'bg-green-800'], + 'H' => ['dark' => 'dark:bg-indigo-500', 'light' => 'bg-indigo-800'], + 'I' => ['dark' => 'dark:bg-lime-500', 'light' => 'bg-lime-800'], + 'J' => ['dark' => 'dark:bg-neutral-500', 'light' => 'bg-neutral-800'], + 'K' => ['dark' => 'dark:bg-orange-500', 'light' => 'bg-orange-800'], + 'L' => ['dark' => 'dark:bg-pink-500', 'light' => 'bg-pink-800'], + 'M' => ['dark' => 'dark:bg-purple-500', 'light' => 'bg-purple-800'], + 'N' => ['dark' => 'dark:bg-red-500', 'light' => 'bg-red-800'], + 'O' => ['dark' => 'dark:bg-rose-500', 'light' => 'bg-rose-800'], + 'P' => ['dark' => 'dark:bg-sky-500', 'light' => 'bg-sky-800'], + 'Q' => ['dark' => 'dark:bg-slate-500', 'light' => 'bg-slate-800'], + 'R' => ['dark' => 'dark:bg-stone-500', 'light' => 'bg-stone-800'], + 'S' => ['dark' => 'dark:bg-teal-500', 'light' => 'bg-teal-800'], + 'T' => ['dark' => 'dark:bg-violet-500', 'light' => 'bg-violet-800'], + 'U' => ['dark' => 'dark:bg-yellow-500', 'light' => 'bg-yellow-800'], + 'V' => ['dark' => 'dark:bg-zinc-500', 'light' => 'bg-zinc-800'], + 'W' => ['dark' => 'dark:bg-neutral-500', 'light' => 'bg-neutral-800'], + 'X' => ['dark' => 'dark:bg-slate-500', 'light' => 'bg-slate-800'], + 'Y' => ['dark' => 'dark:bg-stone-500', 'light' => 'bg-stone-800'], + 'Z' => ['dark' => 'dark:bg-teal-500', 'light' => 'bg-teal-800'], ]; $letter = strtoupper($letter); @@ -41,7 +41,7 @@ trait ColorPicker return $colorReferences[$letter]; } - return ["dark" => "dark:bg-gray-500", "light" => "bg-gray-800"]; + return ['dark' => 'dark:bg-gray-500', 'light' => 'bg-gray-800']; } } diff --git a/app/Filament/Pages/GenerateActivationKeys.php b/app/Filament/Pages/GenerateActivationKeys.php index 5a7e689..7af2327 100644 --- a/app/Filament/Pages/GenerateActivationKeys.php +++ b/app/Filament/Pages/GenerateActivationKeys.php @@ -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); } - } diff --git a/app/Filament/Pages/Settings.php b/app/Filament/Pages/Settings.php index 491f75c..95a8a74 100644 --- a/app/Filament/Pages/Settings.php +++ b/app/Filament/Pages/Settings.php @@ -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; } } diff --git a/app/Filament/Resources/BlogResource.php b/app/Filament/Resources/BlogResource.php index f336644..9dc5111 100644 --- a/app/Filament/Resources/BlogResource.php +++ b/app/Filament/Resources/BlogResource.php @@ -2,52 +2,45 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Schemas\Components\Section; -use Filament\Schemas\Components\Utilities\Set; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\Action; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use App\Filament\Resources\BlogResource\Pages\ListBlogs; use App\Filament\Resources\BlogResource\Pages\CreateBlog; use App\Filament\Resources\BlogResource\Pages\EditBlog; -use App\Filament\Resources\BlogResource\Pages; -use App\Filament\Resources\BlogResource\RelationManagers; +use App\Filament\Resources\BlogResource\Pages\ListBlogs; use App\Models\Blog; use App\Models\Category; -use Filament\Forms; +use Filament\Actions\Action; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\KeyValue; -use Filament\Forms\Components\Repeater; use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; -use Filament\Resources\RelationManagers\RelationManager; use Filament\Resources\Resource; -use Filament\Tables; -use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; +use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\Utilities\Set; +use Filament\Schemas\Schema; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; +use Filament\Tables\Table; use Illuminate\Support\Str; class BlogResource extends Resource { protected static ?string $model = Blog::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-m-newspaper'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-m-newspaper'; - protected static string | \UnitEnum | null $navigationGroup = 'Content'; + protected static string|\UnitEnum|null $navigationGroup = 'Content'; public static function form(Schema $schema): Schema { $categories = Category::pluck('name', 'id')->toArray(); + return $schema ->components([ Section::make('Post Information') @@ -74,7 +67,7 @@ class BlogResource extends Resource Select::make('is_published') ->options([ 0 => 'Draft', - 1 => 'Published' + 1 => 'Published', ]) ->searchable() ->default(1) @@ -107,7 +100,6 @@ class BlogResource extends Resource ->valuePlaceholder('Content'), Textarea::make('custom_header')->rows(6)->label('Custom Header (Optional)'), - ]), ]); @@ -141,7 +133,7 @@ class BlogResource extends Resource ->label('Toggle Published') ->icon('heroicon-o-eye') ->action(function (Blog $record) { - $record->update(['is_published' => !$record->is_published]); + $record->update(['is_published' => ! $record->is_published]); }), ]) ->toolbarActions([ diff --git a/app/Filament/Resources/BlogResource/Pages/CreateBlog.php b/app/Filament/Resources/BlogResource/Pages/CreateBlog.php index 711fda1..50c061f 100644 --- a/app/Filament/Resources/BlogResource/Pages/CreateBlog.php +++ b/app/Filament/Resources/BlogResource/Pages/CreateBlog.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\BlogResource\Pages; use App\Filament\Resources\BlogResource; -use Filament\Actions; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; diff --git a/app/Filament/Resources/BlogResource/Pages/EditBlog.php b/app/Filament/Resources/BlogResource/Pages/EditBlog.php index f24723d..236b25e 100644 --- a/app/Filament/Resources/BlogResource/Pages/EditBlog.php +++ b/app/Filament/Resources/BlogResource/Pages/EditBlog.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\BlogResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\BlogResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -18,6 +17,7 @@ class EditBlog extends EditRecord DeleteAction::make(), ]; } + protected function getRedirectUrl(): ?string { return $this->getResource()::getUrl('index'); diff --git a/app/Filament/Resources/BlogResource/Pages/ListBlogs.php b/app/Filament/Resources/BlogResource/Pages/ListBlogs.php index 12c4655..04dacf8 100644 --- a/app/Filament/Resources/BlogResource/Pages/ListBlogs.php +++ b/app/Filament/Resources/BlogResource/Pages/ListBlogs.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\BlogResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\BlogResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListBlogs extends ListRecords diff --git a/app/Filament/Resources/CategoryResource.php b/app/Filament/Resources/CategoryResource.php index 31e2e11..1b883b9 100644 --- a/app/Filament/Resources/CategoryResource.php +++ b/app/Filament/Resources/CategoryResource.php @@ -2,39 +2,33 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Schemas\Components\Utilities\Set; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\Action; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use App\Filament\Resources\CategoryResource\Pages\ListCategories; use App\Filament\Resources\CategoryResource\Pages\CreateCategory; use App\Filament\Resources\CategoryResource\Pages\EditCategory; -use App\Filament\Resources\CategoryResource\Pages; -use App\Filament\Resources\CategoryResource\RelationManagers; +use App\Filament\Resources\CategoryResource\Pages\ListCategories; use App\Models\Category; -use Filament\Forms; +use Filament\Actions\Action; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Resources\Resource; -use Filament\Tables; -use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; +use Filament\Schemas\Components\Utilities\Set; +use Filament\Schemas\Schema; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Table; use Illuminate\Support\Str; class CategoryResource extends Resource { protected static ?string $model = Category::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-ticket'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-ticket'; - protected static string | \UnitEnum | null $navigationGroup = 'Content'; + protected static string|\UnitEnum|null $navigationGroup = 'Content'; public static function form(Schema $schema): Schema { @@ -52,7 +46,7 @@ class CategoryResource extends Resource ]) ->columnSpanFull() ->required() - ->default(1) + ->default(1), ]); } @@ -80,7 +74,7 @@ class CategoryResource extends Resource ->label('Toggle Status') ->icon('heroicon-o-power') ->action(function (Category $record) { - $record->update(['is_active' => !$record->is_active]); + $record->update(['is_active' => ! $record->is_active]); }), ]) ->toolbarActions([ diff --git a/app/Filament/Resources/CategoryResource/Pages/CreateCategory.php b/app/Filament/Resources/CategoryResource/Pages/CreateCategory.php index 41b42d8..3fb9bb4 100644 --- a/app/Filament/Resources/CategoryResource/Pages/CreateCategory.php +++ b/app/Filament/Resources/CategoryResource/Pages/CreateCategory.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\CategoryResource\Pages; use App\Filament\Resources\CategoryResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateCategory extends CreateRecord diff --git a/app/Filament/Resources/CategoryResource/Pages/EditCategory.php b/app/Filament/Resources/CategoryResource/Pages/EditCategory.php index 0d51a83..f92cc59 100644 --- a/app/Filament/Resources/CategoryResource/Pages/EditCategory.php +++ b/app/Filament/Resources/CategoryResource/Pages/EditCategory.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\CategoryResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\CategoryResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Resources\Pages\EditRecord; class EditCategory extends EditRecord diff --git a/app/Filament/Resources/CategoryResource/Pages/ListCategories.php b/app/Filament/Resources/CategoryResource/Pages/ListCategories.php index d0ecc64..b69308b 100644 --- a/app/Filament/Resources/CategoryResource/Pages/ListCategories.php +++ b/app/Filament/Resources/CategoryResource/Pages/ListCategories.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\CategoryResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\CategoryResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListCategories extends ListRecords diff --git a/app/Filament/Resources/MenuResource.php b/app/Filament/Resources/MenuResource.php index a7cc27c..b94813f 100644 --- a/app/Filament/Resources/MenuResource.php +++ b/app/Filament/Resources/MenuResource.php @@ -2,41 +2,36 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use App\Filament\Resources\MenuResource\Pages\ListMenus; use App\Filament\Resources\MenuResource\Pages\CreateMenu; use App\Filament\Resources\MenuResource\Pages\EditMenu; -use App\Filament\Resources\MenuResource\Pages; -use App\Filament\Resources\MenuResource\RelationManagers; +use App\Filament\Resources\MenuResource\Pages\ListMenus; use App\Models\Menu; -use Filament\Forms; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Resources\Resource; -use Filament\Tables; +use Filament\Schemas\Schema; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class MenuResource extends Resource { protected static ?string $model = Menu::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-bars-3-bottom-left'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bars-3-bottom-left'; - protected static string | \UnitEnum | null $navigationGroup = 'Content'; + protected static string|\UnitEnum|null $navigationGroup = 'Content'; public static function form(Schema $schema): Schema { $menus = Menu::Pluck('name', 'id')->toArray(); + return $schema ->components([ TextInput::make('name') @@ -65,7 +60,7 @@ class MenuResource extends Resource TextColumn::make('name')->sortable(), TextColumn::make('url')->label('URL'), TextColumn::make('parentname.name')->label('Parent Name'), - IconColumn::make('new_tab')->label('Open in New Tab')->boolean() + IconColumn::make('new_tab')->label('Open in New Tab')->boolean(), ]) ->filters([ // diff --git a/app/Filament/Resources/MenuResource/Pages/CreateMenu.php b/app/Filament/Resources/MenuResource/Pages/CreateMenu.php index ec4355f..f924cee 100644 --- a/app/Filament/Resources/MenuResource/Pages/CreateMenu.php +++ b/app/Filament/Resources/MenuResource/Pages/CreateMenu.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\MenuResource\Pages; use App\Filament\Resources\MenuResource; -use Filament\Actions; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; diff --git a/app/Filament/Resources/MenuResource/Pages/EditMenu.php b/app/Filament/Resources/MenuResource/Pages/EditMenu.php index 7f8e82f..314c3f8 100644 --- a/app/Filament/Resources/MenuResource/Pages/EditMenu.php +++ b/app/Filament/Resources/MenuResource/Pages/EditMenu.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\MenuResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\MenuResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -18,6 +17,7 @@ class EditMenu extends EditRecord DeleteAction::make(), ]; } + protected function getRedirectUrl(): ?string { return $this->getResource()::getUrl('index'); diff --git a/app/Filament/Resources/MenuResource/Pages/ListMenus.php b/app/Filament/Resources/MenuResource/Pages/ListMenus.php index 421ea62..9d5b809 100644 --- a/app/Filament/Resources/MenuResource/Pages/ListMenus.php +++ b/app/Filament/Resources/MenuResource/Pages/ListMenus.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\MenuResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\MenuResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListMenus extends ListRecords diff --git a/app/Filament/Resources/PageResource.php b/app/Filament/Resources/PageResource.php index 763c5d5..1987bf2 100644 --- a/app/Filament/Resources/PageResource.php +++ b/app/Filament/Resources/PageResource.php @@ -2,48 +2,39 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Schemas\Components\Section; -use Filament\Schemas\Components\Utilities\Set; -use Filament\Tables\Filters\SelectFilter; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\Action; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use App\Filament\Resources\PageResource\Pages\ListPages; use App\Filament\Resources\PageResource\Pages\CreatePage; use App\Filament\Resources\PageResource\Pages\EditPage; -use App\Filament\Resources\PageResource\Pages; -use App\Filament\Resources\PageResource\RelationManagers; +use App\Filament\Resources\PageResource\Pages\ListPages; use App\Models\Page; -use Filament\Forms; +use Filament\Actions\Action; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\KeyValue; -use Filament\Forms\Components\Repeater; use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; -use Filament\Forms\Components\Toggle; -use Illuminate\Support\Str; use Filament\Resources\Resource; -use Filament\Tables; +use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\Utilities\Set; +use Filament\Schemas\Schema; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; -use Symfony\Contracts\Service\Attribute\Required; +use Illuminate\Support\Str; class PageResource extends Resource { protected static ?string $model = Page::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-document'; - protected static string | \UnitEnum | null $navigationGroup = 'Content'; + protected static string|\UnitEnum|null $navigationGroup = 'Content'; public static function form(Schema $schema): Schema { @@ -64,7 +55,7 @@ class PageResource extends Resource Select::make('is_published') ->options([ 0 => 'Draft', - 1 => 'Published' + 1 => 'Published', ]) ->default(1) ->required() @@ -94,8 +85,6 @@ class PageResource extends Resource Textarea::make('custom_header')->rows(6)->label('Custom Header (Optional)'), ]), - - ]); } @@ -126,7 +115,7 @@ class PageResource extends Resource ->label('Toggle Published') ->icon('heroicon-o-eye') ->action(function (Page $record) { - $record->update(['is_published' => !$record->is_published]); + $record->update(['is_published' => ! $record->is_published]); }), ]) ->toolbarActions([ diff --git a/app/Filament/Resources/PageResource/Pages/CreatePage.php b/app/Filament/Resources/PageResource/Pages/CreatePage.php index 2e1ff81..2d6f64c 100644 --- a/app/Filament/Resources/PageResource/Pages/CreatePage.php +++ b/app/Filament/Resources/PageResource/Pages/CreatePage.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\PageResource\Pages; use App\Filament\Resources\PageResource; -use Filament\Actions; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; diff --git a/app/Filament/Resources/PageResource/Pages/EditPage.php b/app/Filament/Resources/PageResource/Pages/EditPage.php index 1d45d20..f1f8815 100644 --- a/app/Filament/Resources/PageResource/Pages/EditPage.php +++ b/app/Filament/Resources/PageResource/Pages/EditPage.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\PageResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\PageResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -18,6 +17,7 @@ class EditPage extends EditRecord DeleteAction::make(), ]; } + protected function getRedirectUrl(): ?string { return $this->getResource()::getUrl('index'); diff --git a/app/Filament/Resources/PageResource/Pages/ListPages.php b/app/Filament/Resources/PageResource/Pages/ListPages.php index 243648f..ebc7c65 100644 --- a/app/Filament/Resources/PageResource/Pages/ListPages.php +++ b/app/Filament/Resources/PageResource/Pages/ListPages.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\PageResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\PageResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListPages extends ListRecords diff --git a/app/Filament/Resources/PlanResource.php b/app/Filament/Resources/PlanResource.php index ba83e48..4a4a50d 100644 --- a/app/Filament/Resources/PlanResource.php +++ b/app/Filament/Resources/PlanResource.php @@ -2,45 +2,33 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Schemas\Components\Section; -use Filament\Tables\Filters\SelectFilter; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use App\Filament\Resources\PlanResource\Pages\ListPlans; use App\Filament\Resources\PlanResource\Pages\CreatePlan; use App\Filament\Resources\PlanResource\Pages\EditPlan; -use App\Filament\Resources\PlanResource\Pages; -use App\Filament\Resources\PlanResource\RelationManagers; +use App\Filament\Resources\PlanResource\Pages\ListPlans; use App\Models\Plan; -use Filament\Forms; -use Filament\Forms\Components\FileUpload; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\KeyValue; -use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; -use Filament\Forms\Set; use Filament\Resources\Resource; -use Filament\Tables; +use Filament\Schemas\Components\Section; +use Filament\Schemas\Schema; use Filament\Tables\Columns\BooleanColumn; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; -use Illuminate\Support\Str; -use phpDocumentor\Reflection\Types\Boolean; class PlanResource extends Resource { protected static ?string $model = Plan::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-rectangle-stack'; - - protected static string | \UnitEnum | null $navigationGroup = 'Web Master'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack'; + protected static string|\UnitEnum|null $navigationGroup = 'Web Master'; public static function form(Schema $schema): Schema { @@ -114,6 +102,7 @@ class PlanResource extends Resource return $query->where('accept_oxapay', true); } } + return $query; }), ]) diff --git a/app/Filament/Resources/PlanResource/Pages/CreatePlan.php b/app/Filament/Resources/PlanResource/Pages/CreatePlan.php index 1d9a4b2..43ea1a7 100644 --- a/app/Filament/Resources/PlanResource/Pages/CreatePlan.php +++ b/app/Filament/Resources/PlanResource/Pages/CreatePlan.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\PlanResource\Pages; use App\Filament\Resources\PlanResource; -use Filament\Actions; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; diff --git a/app/Filament/Resources/PlanResource/Pages/EditPlan.php b/app/Filament/Resources/PlanResource/Pages/EditPlan.php index 50e8af8..f646a73 100644 --- a/app/Filament/Resources/PlanResource/Pages/EditPlan.php +++ b/app/Filament/Resources/PlanResource/Pages/EditPlan.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\PlanResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\PlanResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -18,6 +17,7 @@ class EditPlan extends EditRecord DeleteAction::make(), ]; } + protected function getRedirectUrl(): ?string { return $this->getResource()::getUrl('index'); diff --git a/app/Filament/Resources/PlanResource/Pages/ListPlans.php b/app/Filament/Resources/PlanResource/Pages/ListPlans.php index 56724fc..10e217f 100644 --- a/app/Filament/Resources/PlanResource/Pages/ListPlans.php +++ b/app/Filament/Resources/PlanResource/Pages/ListPlans.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\PlanResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\PlanResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListPlans extends ListRecords diff --git a/app/Filament/Resources/TicketResource.php b/app/Filament/Resources/TicketResource.php index 1742e28..81dd6d8 100644 --- a/app/Filament/Resources/TicketResource.php +++ b/app/Filament/Resources/TicketResource.php @@ -2,50 +2,44 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Actions\ViewAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; -use Filament\Actions\Action; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use Filament\Actions\BulkAction; -use Illuminate\Support\Collection; -use Illuminate\Support\Facades\Mail; -use App\Mail\TicketResponseNotification; -use App\Filament\Resources\TicketResource\RelationManagers\ResponsesRelationManager; -use App\Filament\Resources\TicketResource\Pages\ListTickets; use App\Filament\Resources\TicketResource\Pages\CreateTicket; use App\Filament\Resources\TicketResource\Pages\EditTicket; -use App\Filament\Resources\TicketResource\Pages; -use App\Filament\Resources\TicketResource\RelationManagers; +use App\Filament\Resources\TicketResource\Pages\ListTickets; +use App\Filament\Resources\TicketResource\RelationManagers\ResponsesRelationManager; +use App\Mail\TicketResponseNotification; use App\Models\Ticket; use App\Models\TicketResponse; -use Filament\Forms; +use Filament\Actions\Action; +use Filament\Actions\BulkAction; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; use Filament\Forms\Components\DatePicker; -use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; use Filament\Resources\Resource; +use Filament\Schemas\Schema; use Filament\Tables; use Filament\Tables\Columns\BadgeColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; +use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\HtmlString; class TicketResource extends Resource { - protected static ?string $model = Ticket::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-ticket'; - protected static string | \UnitEnum | null $navigationGroup = 'Support'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-ticket'; + + protected static string|\UnitEnum|null $navigationGroup = 'Support'; public static function form(Schema $schema): Schema { @@ -99,7 +93,7 @@ class TicketResource extends Resource ->colors([ 'success' => fn ($state) => $state === 'open', 'warning' => fn ($state) => $state === 'pending', - 'danger' => fn ($state) => $state === 'closed', + 'danger' => fn ($state) => $state === 'closed', ]) ->sortable(), TextColumn::make('created_at') @@ -165,8 +159,8 @@ class TicketResource extends Resource // Ticket Subject & Message $html .= '
'; - $html .= '
Subject: ' . e($ticket->subject) . '
'; - $html .= '

Message: ' . nl2br(e($ticket->message)) . '

'; + $html .= '
Subject: '.e($ticket->subject).'
'; + $html .= '

Message: '.nl2br(e($ticket->message)).'

'; $html .= '
'; // Responses Section @@ -175,10 +169,10 @@ class TicketResource extends Resource foreach ($ticket->responses as $response) { $html .= '
'; $html .= '
'; - $html .= '' . e($response->user->name) . ''; - $html .= '' . e($response->created_at->diffForHumans()) . ''; + $html .= ''.e($response->user->name).''; + $html .= ''.e($response->created_at->diffForHumans()).''; $html .= '
'; - $html .= '

' . nl2br(e($response->response)) . '

'; + $html .= '

'.nl2br(e($response->response)).'

'; $html .= '
'; } diff --git a/app/Filament/Resources/TicketResource/Pages/CreateTicket.php b/app/Filament/Resources/TicketResource/Pages/CreateTicket.php index f3998f5..321bca8 100644 --- a/app/Filament/Resources/TicketResource/Pages/CreateTicket.php +++ b/app/Filament/Resources/TicketResource/Pages/CreateTicket.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\TicketResource\Pages; use App\Filament\Resources\TicketResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateTicket extends CreateRecord diff --git a/app/Filament/Resources/TicketResource/Pages/EditTicket.php b/app/Filament/Resources/TicketResource/Pages/EditTicket.php index 6fbd8f6..6322513 100644 --- a/app/Filament/Resources/TicketResource/Pages/EditTicket.php +++ b/app/Filament/Resources/TicketResource/Pages/EditTicket.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\TicketResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\TicketResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Resources\Pages\EditRecord; class EditTicket extends EditRecord diff --git a/app/Filament/Resources/TicketResource/Pages/ListTickets.php b/app/Filament/Resources/TicketResource/Pages/ListTickets.php index 3d2a788..af220de 100644 --- a/app/Filament/Resources/TicketResource/Pages/ListTickets.php +++ b/app/Filament/Resources/TicketResource/Pages/ListTickets.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\TicketResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\TicketResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListTickets extends ListRecords diff --git a/app/Filament/Resources/TicketResource/RelationManagers/ResponsesRelationManager.php b/app/Filament/Resources/TicketResource/RelationManagers/ResponsesRelationManager.php index 677376b..0e58d9a 100644 --- a/app/Filament/Resources/TicketResource/RelationManagers/ResponsesRelationManager.php +++ b/app/Filament/Resources/TicketResource/RelationManagers/ResponsesRelationManager.php @@ -2,22 +2,17 @@ namespace App\Filament\Resources\TicketResource\RelationManagers; -use Filament\Schemas\Schema; -use Filament\Actions\CreateAction; -use Filament\Actions\EditAction; -use Filament\Actions\DeleteAction; use Filament\Actions\BulkActionGroup; +use Filament\Actions\CreateAction; +use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; -use Filament\Forms; +use Filament\Actions\EditAction; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; -use Filament\Forms\Components\TextInput; use Filament\Resources\RelationManagers\RelationManager; -use Filament\Tables; +use Filament\Schemas\Schema; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class ResponsesRelationManager extends RelationManager { diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index a6216d5..c2586a7 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -2,45 +2,38 @@ namespace App\Filament\Resources; -use Filament\Schemas\Schema; -use Filament\Actions\EditAction; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use Filament\Actions\BulkAction; -use Exception; -use App\Filament\Resources\UserResource\Pages\ListUsers; use App\Filament\Resources\UserResource\Pages\CreateUser; use App\Filament\Resources\UserResource\Pages\EditUser; -use App\Filament\Resources\UserResource\Pages; +use App\Filament\Resources\UserResource\Pages\ListUsers; use App\Filament\Resources\UserResource\RelationManagers\LogsRelationManager; use App\Filament\Resources\UserResource\RelationManagers\UsageLogsRelationManager; use App\Models\User; use DB; -use Filament\Actions\Action; -use Filament\Forms; +use Exception; +use Filament\Actions\BulkAction; +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; use Filament\Resources\Resource; -use Filament\Tables; +use Filament\Schemas\Schema; use Filament\Tables\Columns\BadgeColumn; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; -use Illuminate\Database\Eloquent\SoftDeletingScope; -use Illuminate\Support\Facades\Response; class UserResource extends Resource { protected static ?string $model = User::class; - protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-users'; + protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-users'; - protected static string | \UnitEnum | null $navigationGroup = 'Admin'; + protected static string|\UnitEnum|null $navigationGroup = 'Admin'; public static function form(Schema $schema): Schema { @@ -58,7 +51,7 @@ class UserResource extends Resource ->label('Email Verification Status') ->disabled() ->formatStateUsing(fn ($record) => $record->email_verified_at ?? '' - ? 'Verified at ' . $record->email_verified_at->toDateTimeString() + ? 'Verified at '.$record->email_verified_at->toDateTimeString() : 'Not Verified') ->helperText('Shows whether the user has verified their email address.'), TextInput::make('stripe_id') @@ -103,7 +96,7 @@ class UserResource extends Resource ->falseIcon('heroicon-o-x-circle') ->trueColor('success') ->falseColor('danger') - ->getStateUsing(fn ($record) => !is_null($record->email_verified_at)) + ->getStateUsing(fn ($record) => ! is_null($record->email_verified_at)) ->sortable(), BadgeColumn::make('level') ->label('User Level') @@ -118,7 +111,7 @@ class UserResource extends Resource ->colors([ 'success' => fn ($state) => $state === 'Normal User', 'danger' => fn ($state) => $state === 'Banned', - 'warning' => fn ($state) => $state === 'Super Admin', + 'warning' => fn ($state) => $state === 'Super Admin', ]) ->sortable(), TextColumn::make('stripe_id')->label('Stripe ID')->copyable(), @@ -179,7 +172,6 @@ class UserResource extends Resource ->whereIn('id', $records->pluck('id')) ->update(['level' => $newLevel]); - Notification::make() ->title('User Level Updated') ->body('The selected users\' levels have been updated successfully.') @@ -219,6 +211,4 @@ class UserResource extends Resource 'edit' => EditUser::route('/{record}/edit'), ]; } - - } diff --git a/app/Filament/Resources/UserResource/Pages/CreateUser.php b/app/Filament/Resources/UserResource/Pages/CreateUser.php index 73aa46d..78a3894 100644 --- a/app/Filament/Resources/UserResource/Pages/CreateUser.php +++ b/app/Filament/Resources/UserResource/Pages/CreateUser.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateUser extends CreateRecord diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index 2c71999..fa1df55 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -2,11 +2,10 @@ namespace App\Filament\Resources\UserResource\Pages; -use Filament\Actions\DeleteAction; use App\Filament\Resources\UserResource; use App\Models\User; -use Filament\Actions; use Filament\Actions\Action; +use Filament\Actions\DeleteAction; use Filament\Resources\Pages\EditRecord; use Illuminate\Support\Facades\Response; @@ -79,7 +78,7 @@ class EditUser extends EditRecord function () use ($csvContent) { echo $csvContent; }, - "user_{$record->id}_report_" . now()->format('Ymd_His') . '.csv', + "user_{$record->id}_report_".now()->format('Ymd_His').'.csv', ['Content-Type' => 'text/csv'] ); }) diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 629da62..4a25a8b 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -2,9 +2,8 @@ namespace App\Filament\Resources\UserResource\Pages; -use Filament\Actions\CreateAction; use App\Filament\Resources\UserResource; -use Filament\Actions; +use Filament\Actions\CreateAction; use Filament\Resources\Pages\ListRecords; class ListUsers extends ListRecords diff --git a/app/Filament/Resources/UserResource/RelationManagers/LogsRelationManager.php b/app/Filament/Resources/UserResource/RelationManagers/LogsRelationManager.php index 065e0f7..3d374d4 100644 --- a/app/Filament/Resources/UserResource/RelationManagers/LogsRelationManager.php +++ b/app/Filament/Resources/UserResource/RelationManagers/LogsRelationManager.php @@ -2,19 +2,16 @@ namespace App\Filament\Resources\UserResource\RelationManagers; -use Filament\Tables\Columns\TextColumn; use Filament\Actions\BulkActionGroup; -use Filament\Forms; -use Filament\Forms\Form; use Filament\Resources\RelationManagers\RelationManager; use Filament\Tables; +use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class LogsRelationManager extends RelationManager { protected static string $relationship = 'logs'; + protected static ?string $title = 'General Logs'; public function table(Table $table): Table @@ -37,15 +34,15 @@ class LogsRelationManager extends RelationManager // ]) ->headerActions([ - //Tables\Actions\CreateAction::make(), + // Tables\Actions\CreateAction::make(), ]) ->recordActions([ - //Tables\Actions\EditAction::make(), - //Tables\Actions\DeleteAction::make(), + // Tables\Actions\EditAction::make(), + // Tables\Actions\DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ - //Tables\Actions\DeleteBulkAction::make(), + // Tables\Actions\DeleteBulkAction::make(), ]), ]); } diff --git a/app/Filament/Resources/UserResource/RelationManagers/UsageLogsRelationManager.php b/app/Filament/Resources/UserResource/RelationManagers/UsageLogsRelationManager.php index 3ec038e..701c1c4 100644 --- a/app/Filament/Resources/UserResource/RelationManagers/UsageLogsRelationManager.php +++ b/app/Filament/Resources/UserResource/RelationManagers/UsageLogsRelationManager.php @@ -2,15 +2,11 @@ namespace App\Filament\Resources\UserResource\RelationManagers; -use Filament\Tables\Columns\TextColumn; use Filament\Actions\BulkActionGroup; -use Filament\Forms; -use Filament\Forms\Form; use Filament\Resources\RelationManagers\RelationManager; use Filament\Tables; +use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class UsageLogsRelationManager extends RelationManager { @@ -42,15 +38,15 @@ class UsageLogsRelationManager extends RelationManager // ]) ->headerActions([ - //Tables\Actions\CreateAction::make(), + // Tables\Actions\CreateAction::make(), ]) ->recordActions([ - //Tables\Actions\EditAction::make(), - //Tables\Actions\DeleteAction::make(), + // Tables\Actions\EditAction::make(), + // Tables\Actions\DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ - //Tables\Actions\DeleteBulkAction::make(), + // Tables\Actions\DeleteBulkAction::make(), ]), ]); } diff --git a/app/Filament/Widgets/StatsOverview.php b/app/Filament/Widgets/StatsOverview.php index 792cb0e..20726f3 100644 --- a/app/Filament/Widgets/StatsOverview.php +++ b/app/Filament/Widgets/StatsOverview.php @@ -79,6 +79,7 @@ class StatsOverview extends BaseWidget if ($today == $yesterday) { return null; } + return $today > $yesterday ? 'heroicon-o-arrow-up' : 'heroicon-o-arrow-down'; } @@ -87,6 +88,7 @@ class StatsOverview extends BaseWidget if ($today == $yesterday) { return 'gray'; } + return $today > $yesterday ? 'success' : 'danger'; } @@ -95,6 +97,7 @@ class StatsOverview extends BaseWidget if ($period === 'yesterday') { return User::where('created_at', '<', Carbon::today('UTC')->startOfDay())->count(); } + return User::count(); } @@ -111,6 +114,7 @@ class StatsOverview extends BaseWidget if ($period === 'yesterday') { return Log::where('created_at', '<', Carbon::today('UTC')->startOfDay())->count(); } + return Log::count(); } @@ -131,6 +135,7 @@ class StatsOverview extends BaseWidget ->where('created_at', '<', Carbon::today('UTC')->startOfDay()) ->count(); } + return User::whereNotNull('stripe_id')->count(); } @@ -139,6 +144,7 @@ class StatsOverview extends BaseWidget if ($period === 'yesterday') { return PremiumEmail::where('created_at', '<', Carbon::today('UTC')->startOfDay())->count(); } + return PremiumEmail::count(); } diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 013778c..d38f109 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -4,12 +4,12 @@ namespace App\Http\Controllers; use App\Models\Premium; use App\Models\ZEmail; -use Illuminate\Http\Request; use Session; class AppController extends Controller { - public function mailbox($email = null) { + public function mailbox($email = null) + { if ($email) { $validatedData = validator(['email' => $email], [ 'email' => 'required|email', @@ -18,39 +18,48 @@ class AppController extends Controller if (json_decode(config('app.settings.configuration_settings'))->enable_create_from_url) { ZEmail::createCustomEmailFull($email); } + return redirect()->route('mailbox'); } - if (!ZEmail::getEmail()) { + if (! ZEmail::getEmail()) { return redirect()->route('home'); } if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) { return redirect()->route('home'); } + return $this->app(); } - public function app() { + public function app() + { return redirect()->route('home'); } - public function switch($email) { + + public function switch($email) + { ZEmail::setEmail($email); if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) { return redirect()->route('home'); } + return redirect()->route('mailbox'); } - public function delete($email = null) { + public function delete($email = null) + { if ($email) { $emails = ZEmail::getEmails(); ZEmail::removeEmail($email); + return redirect()->route('mailbox'); } else { return redirect()->route('home'); } } - public function switchP($email) { + public function switchP($email) + { if (Session::get('isInboxTypePremium')) { Premium::setEmailP($email); } else { @@ -59,10 +68,12 @@ class AppController extends Controller if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) { return redirect()->route('dashboard'); } + return redirect()->route('dashboard.premium'); } - public function deleteP($email = null) { + public function deleteP($email = null) + { if ($email) { if (Session::get('isInboxTypePremium')) { $emails = Premium::getEmails(); @@ -71,43 +82,50 @@ class AppController extends Controller $emails = ZEmail::getEmails(); ZEmail::removeEmail($email); } + return redirect()->route('dashboard.premium'); } else { return redirect()->route('dashboard'); } } - public function locale($locale) { + public function locale($locale) + { if (in_array($locale, config('app.locales'))) { session(['locale' => $locale]); + return redirect()->back(); } abort(400); } - - private function getStringBetween($string, $start, $end) { - $string = ' ' . $string; + private function getStringBetween($string, $start, $end) + { + $string = ' '.$string; $ini = strpos($string, $start); - if ($ini == 0) return ''; + if ($ini == 0) { + return ''; + } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; + return substr($string, $ini, $len); } - private function setHeaders($page) { + + private function setHeaders($page) + { $header = $page->header; foreach ($page->meta ? unserialize($page->meta) : [] as $meta) { if ($meta['name'] == 'canonical') { - $header .= ''; - } else if (str_contains($meta['name'], 'og:')) { - $header .= ''; + $header .= ''; + } elseif (str_contains($meta['name'], 'og:')) { + $header .= ''; } else { - $header .= ''; + $header .= ''; } } $page->header = $header; + return $page; } - - } diff --git a/app/Http/Controllers/Auth/VerifyEmailController.php b/app/Http/Controllers/Auth/VerifyEmailController.php index e1f1995..bfeef5a 100644 --- a/app/Http/Controllers/Auth/VerifyEmailController.php +++ b/app/Http/Controllers/Auth/VerifyEmailController.php @@ -2,9 +2,9 @@ namespace App\Http\Controllers\Auth; -use Illuminate\Contracts\Auth\MustVerifyEmail; use App\Http\Controllers\Controller; use Illuminate\Auth\Events\Verified; +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\EmailVerificationRequest; use Illuminate\Http\RedirectResponse; diff --git a/app/Http/Controllers/WebhookController.php b/app/Http/Controllers/WebhookController.php index 55e3221..94bfa90 100644 --- a/app/Http/Controllers/WebhookController.php +++ b/app/Http/Controllers/WebhookController.php @@ -2,15 +2,16 @@ namespace App\Http\Controllers; -use Log; -use Exception; use App\NotifyMe; use Carbon\Carbon; +use Exception; use Illuminate\Http\Request; +use Log; class WebhookController extends Controller { use NotifyMe; + public function oxapay(Request $request) { // Get the request data @@ -18,8 +19,9 @@ class WebhookController extends Controller $data = json_decode($postData, true); // Validate request data - if (!$data || !isset($data['type']) || !in_array($data['type'], ['invoice', 'payment_link', 'payout'])) { + if (! $data || ! isset($data['type']) || ! in_array($data['type'], ['invoice', 'payment_link', 'payout'])) { Log::warning('Invalid Oxapay webhook data', ['data' => $data]); + return response('Invalid data.type', 400); } @@ -53,11 +55,11 @@ class WebhookController extends Controller 'date' => $date, ]); - $message = "✅ Oxapay Invoice Payment Success\n" . - "Track ID: {$trackId}\n" . - "Email: {$email}\n" . - "Amount: {$amount} {$currency}\n" . - "Order ID: {$orderId}\n" . + $message = "✅ Oxapay Invoice Payment Success\n". + "Track ID: {$trackId}\n". + "Email: {$email}\n". + "Amount: {$amount} {$currency}\n". + "Order ID: {$orderId}\n". "Time: {$date}"; self::sendTelegramNotification($message); } elseif ($data['type'] === 'payout') { @@ -83,13 +85,13 @@ class WebhookController extends Controller 'date' => $date, ]); - $message = "📤 Oxapay Payout Confirmed\n" . - "Track ID: {$trackId}\n" . - "Amount: {$amount} {$currency}\n" . - "Network: {$network}\n" . - "Address: {$address}\n" . - "Transaction Hash: {$txHash}\n" . - "Description: {$description}\n" . + $message = "📤 Oxapay Payout Confirmed\n". + "Track ID: {$trackId}\n". + "Amount: {$amount} {$currency}\n". + "Network: {$network}\n". + "Address: {$address}\n". + "Transaction Hash: {$txHash}\n". + "Description: {$description}\n". "Date: {$date}"; self::sendTelegramNotification($message); } @@ -100,13 +102,15 @@ class WebhookController extends Controller self::sendTelegramNotification(" Failed to process Oxapay webhook\n Type: {$data['type']}\n - Email/Track ID: " . ($data['type'] === 'invoice' ? ($data['email'] ?? 'Unknown') : ($data['track_id'] ?? 'Unknown')) . "\n + Email/Track ID: ".($data['type'] === 'invoice' ? ($data['email'] ?? 'Unknown') : ($data['track_id'] ?? 'Unknown'))."\n Error: {$e->getMessage()} "); + return response('Processing error', 400); } } else { Log::warning('Invalid Oxapay HMAC signature', ['hmac_header' => $hmacHeader, 'calculated_hmac' => $calculatedHmac]); + return response('Invalid HMAC signature', 400); } } diff --git a/app/Http/Middleware/CheckPageSlug.php b/app/Http/Middleware/CheckPageSlug.php index 6339906..77c1602 100644 --- a/app/Http/Middleware/CheckPageSlug.php +++ b/app/Http/Middleware/CheckPageSlug.php @@ -11,7 +11,7 @@ class CheckPageSlug /** * Handle an incoming request. * - * @param Closure(Request):Response $next + * @param Closure(Request):Response $next */ public function handle(Request $request, Closure $next): Response { @@ -21,9 +21,10 @@ class CheckPageSlug if (file_exists($publicPath) && is_file($publicPath) && pathinfo($slug, PATHINFO_EXTENSION) === 'php') { ob_start(); - include($publicPath); + include $publicPath; $content = ob_get_clean(); ob_flush(); + return response($content); } diff --git a/app/Http/Middleware/CheckUserBanned.php b/app/Http/Middleware/CheckUserBanned.php index 917a05b..7274eda 100644 --- a/app/Http/Middleware/CheckUserBanned.php +++ b/app/Http/Middleware/CheckUserBanned.php @@ -12,7 +12,7 @@ class CheckUserBanned /** * Handle an incoming request. * - * @param Closure(Request):Response $next + * @param Closure(Request):Response $next */ public function handle(Request $request, Closure $next): Response { @@ -20,6 +20,7 @@ class CheckUserBanned // Return the banned page instead of proceeding with the request return response()->view('banned'); } + return $next($request); } } diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php index eeefeba..6603763 100644 --- a/app/Http/Middleware/Locale.php +++ b/app/Http/Middleware/Locale.php @@ -2,8 +2,8 @@ namespace App\Http\Middleware; -use Exception; use Closure; +use Exception; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; @@ -12,7 +12,7 @@ class Locale /** * Handle an incoming request. * - * @param Closure(Request):Response $next + * @param Closure(Request):Response $next */ public function handle(Request $request, Closure $next): Response { @@ -24,6 +24,7 @@ class Locale } catch (Exception $e) { } app()->setLocale(session('locale', session('browser-locale', config('app.settings.language', config('app.locale', 'en'))))); + return $next($request); } } diff --git a/app/Listeners/StripeEventListener.php b/app/Listeners/StripeEventListener.php index 1689261..8679f6b 100644 --- a/app/Listeners/StripeEventListener.php +++ b/app/Listeners/StripeEventListener.php @@ -3,16 +3,13 @@ namespace App\Listeners; use App\NotifyMe; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Support\Facades\Log; use Laravel\Cashier\Events\WebhookReceived; -use Livewire\Livewire; class StripeEventListener { use NotifyMe; + /** * Create the event listener. */ @@ -32,10 +29,10 @@ class StripeEventListener $amount = $event->payload['data']['object']['amount_paid'] / 100 ?? 'Unknown'; // Convert cents to dollars $email = $event->payload['data']['object']['customer_email'] ?? 'Unknown'; - $message = "✅ Payment Success\n" . - "Email: {$email}\n" . - "Amount: $" . number_format($amount, 2) . "\n" . - "Time: " . now()->toDateTimeString(); + $message = "✅ Payment Success\n". + "Email: {$email}\n". + 'Amount: $'.number_format($amount, 2)."\n". + 'Time: '.now()->toDateTimeString(); self::sendTelegramNotification($message); } @@ -45,9 +42,9 @@ class StripeEventListener $email = $event->payload['data']['object']['customer_email'] ?? 'Unknown'; - $message = "❌ Subscription Canceled\n" . - "Email: {$email}\n" . - "Time: " . now()->toDateTimeString(); + $message = "❌ Subscription Canceled\n". + "Email: {$email}\n". + 'Time: '.now()->toDateTimeString(); self::sendTelegramNotification($message); } } diff --git a/app/Livewire/AddOn.php b/app/Livewire/AddOn.php index 31efd78..eff9c3f 100644 --- a/app/Livewire/AddOn.php +++ b/app/Livewire/AddOn.php @@ -4,17 +4,22 @@ namespace App\Livewire; use App\Models\ZEmail; use Livewire\Component; -use Request; use Session; class AddOn extends Component { - public $title = ""; - public $description = ""; - public $keywords = ""; - public $route = ""; + public $title = ''; + + public $description = ''; + + public $keywords = ''; + + public $route = ''; + public $faqs = []; + public $faqSchema; + protected $listeners = ['fetchMessages' => 'checkIfAnyMessage']; public function checkIfAnyMessage() @@ -38,18 +43,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'disposable-gmail') { $this->title = 'Disposable Gmail Email | Free Temporary Gmail Inbox Online'; @@ -58,18 +63,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'disposable-outlook') { @@ -79,18 +84,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'disposable-yahoo') { $this->title = 'Disposable Yahoo Mail | Free Temporary Yahoo Inbox'; @@ -99,18 +104,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'gmailnator') { $this->title = 'Gmailnator - Free Temporary Gmail Email Address Generator'; @@ -119,18 +124,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'emailnator') { $this->title = 'Emailnator - Free Disposable Temporary Email Service'; @@ -139,18 +144,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } elseif ($route == 'temp-gmail') { $this->title = 'Temp Gmail | Free Temporary Gmail Inbox for Instant Use'; @@ -159,18 +164,18 @@ class AddOn extends Component $this->route = $route; $this->faqs = $this->faqs[$route]; $this->faqSchema = [ - "@context" => "https://schema.org", - "@type" => "FAQPage", - "mainEntity" => collect($this->faqs)->map(function ($faq) { + '@context' => 'https://schema.org', + '@type' => 'FAQPage', + 'mainEntity' => collect($this->faqs)->map(function ($faq) { return [ - "@type" => "Question", - "name" => $faq['title'], - "acceptedAnswer" => [ - "@type" => "Answer", - "text" => $faq['content'] - ] + '@type' => 'Question', + 'name' => $faq['title'], + 'acceptedAnswer' => [ + '@type' => 'Answer', + 'text' => $faq['content'], + ], ]; - })->toArray() + })->toArray(), ]; } diff --git a/app/Livewire/Auth/Register.php b/app/Livewire/Auth/Register.php index e771ede..1737f9b 100644 --- a/app/Livewire/Auth/Register.php +++ b/app/Livewire/Auth/Register.php @@ -2,12 +2,11 @@ namespace App\Livewire\Auth; -use Illuminate\Validation\Rules\Password; use App\Models\User; use Illuminate\Auth\Events\Registered; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; -use Illuminate\Validation\Rules; +use Illuminate\Validation\Rules\Password; use Livewire\Attributes\Layout; use Livewire\Component; diff --git a/app/Livewire/Blog.php b/app/Livewire/Blog.php index d3f4ce4..c01224e 100644 --- a/app/Livewire/Blog.php +++ b/app/Livewire/Blog.php @@ -8,9 +8,11 @@ use Livewire\Component; class Blog extends Component { public $postDetail; + public $category; - public function mount($slug) { + public function mount($slug) + { $this->postDetail = \App\Models\Blog::where('slug', $slug)->firstOrFail(); $this->category = Category::where('id', $this->postDetail->category_id)->first(); } diff --git a/app/Livewire/Dashboard/Bulk.php b/app/Livewire/Dashboard/Bulk.php index 2740ad8..1dab45e 100644 --- a/app/Livewire/Dashboard/Bulk.php +++ b/app/Livewire/Dashboard/Bulk.php @@ -8,14 +8,17 @@ use Session; class Bulk extends Component { public $bulkEmails = []; + public $bulkCount = 1; private $isSubscribed = false; - public function mount() { + public function mount() + { $subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']); Session::put('isSubscribed', $subscriptionCheck); } + public function generateBulk() { $this->validate([ @@ -34,11 +37,11 @@ class Bulk extends Component public function downloadBulk() { // Ensure there's something to download - if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) { + if (empty($this->bulkEmails) || ! is_array($this->bulkEmails)) { return; } - $filename = 'bulk_emails_' . now()->format('Ymd_His') . '.txt'; + $filename = 'bulk_emails_'.now()->format('Ymd_His').'.txt'; $content = implode(PHP_EOL, $this->bulkEmails); return response()->streamDownload(function () use ($content) { @@ -49,40 +52,42 @@ class Bulk extends Component private function randomEmail(): string { $domain = $this->getRandomDomain(); - if ($domain == "gmail.com" || $domain == "googlemail.com") { + if ($domain == 'gmail.com' || $domain == 'googlemail.com') { $uname = $this->getRandomGmailUser(); $uname_len = strlen($uname); $len_power = $uname_len - 1; - $combination = pow(2,$len_power); - $rand_comb = mt_rand(1,$combination); - $formatted = implode(' ',str_split($uname)); + $combination = pow(2, $len_power); + $rand_comb = mt_rand(1, $combination); + $formatted = implode(' ', str_split($uname)); $uname_exp = explode(' ', $formatted); - $bin = intval(""); - for($i=0; $i<$len_power; $i++) { - $bin .= mt_rand(0,1); + $bin = intval(''); + for ($i = 0; $i < $len_power; $i++) { + $bin .= mt_rand(0, 1); } - $bin = explode(' ', implode(' ',str_split(strval($bin)))); + $bin = explode(' ', implode(' ', str_split(strval($bin)))); - $email = ""; - for($i=0; $i<$len_power; $i++) { + $email = ''; + for ($i = 0; $i < $len_power; $i++) { $email .= $uname_exp[$i]; - if($bin[$i]) { - $email .= "."; + if ($bin[$i]) { + $email .= '.'; } } $email .= $uname_exp[$i]; - $gmail_rand = mt_rand(1,10); - if($gmail_rand > 5) { - $email .= "@gmail.com"; + $gmail_rand = mt_rand(1, 10); + if ($gmail_rand > 5) { + $email .= '@gmail.com'; } else { - $email .= "@googlemail.com"; + $email .= '@googlemail.com'; } + return $email; } else { return $this->generateRandomUsername().'@'.$domain; } } + private function generateRandomUsername(): string { $start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0; @@ -90,36 +95,48 @@ class Bulk extends Component if ($start == 0 && $end == 0) { return $this->generatePronounceableWord(); } + return $this->generatedRandomBetweenLength($start, $end); } + private function generatedRandomBetweenLength($start, $end): string { $length = rand($start, $end); + return $this->generateRandomString($length); } - private function getRandomDomain() { + + private function getRandomDomain() + { $domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? []; $count = count($domains); + return $count > 0 ? $domains[rand(1, $count) - 1] : ''; } - private function getRandomGmailUser() { + + private function getRandomGmailUser() + { $gmailusername = json_decode(config('app.settings.configuration_settings'))->premium_gmailUsernames ?? []; $count = count($gmailusername); + return $count > 0 ? $gmailusername[rand(1, $count) - 1] : ''; } + private function generatePronounceableWord(): string { - $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones - $v = 'aeiou'; //vowels - $a = $c . $v; //both + $c = 'bcdfghjklmnprstvwz'; // consonants except hard to speak ones + $v = 'aeiou'; // vowels + $a = $c.$v; // both $random = ''; for ($j = 0; $j < 2; $j++) { $random .= $c[rand(0, strlen($c) - 1)]; $random .= $v[rand(0, strlen($v) - 1)]; $random .= $a[rand(0, strlen($a) - 1)]; } + return $random; } + private function generateRandomString($length = 10): string { $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; @@ -128,6 +145,7 @@ class Bulk extends Component for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } + return $randomString; } diff --git a/app/Livewire/Dashboard/BulkGmail.php b/app/Livewire/Dashboard/BulkGmail.php index 0debfe3..2bf0211 100644 --- a/app/Livewire/Dashboard/BulkGmail.php +++ b/app/Livewire/Dashboard/BulkGmail.php @@ -4,15 +4,17 @@ namespace App\Livewire\Dashboard; use Livewire\Component; use Session; -use function Pest\Laravel\withoutMockingConsoleOutput; class BulkGmail extends Component { public $email; + public int $quantity = 10; + public $bulkEmails = []; - public function mount() { + public function mount() + { $subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']); Session::put('isSubscribed', $subscriptionCheck); } @@ -32,17 +34,17 @@ class BulkGmail extends Component $this->bulkEmails = []; } - $this->bulkEmails = $this->generateDotVariants(explode("@", $this->email)[0], $this->quantity); + $this->bulkEmails = $this->generateDotVariants(explode('@', $this->email)[0], $this->quantity); } public function downloadBulk() { // Ensure there's something to download - if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) { + if (empty($this->bulkEmails) || ! is_array($this->bulkEmails)) { return; } - $filename = 'bulk_gmails_' . now()->format('Ymd_His') . '.txt'; + $filename = 'bulk_gmails_'.now()->format('Ymd_His').'.txt'; $content = implode(PHP_EOL, $this->bulkEmails); return response()->streamDownload(function () use ($content) { @@ -66,11 +68,11 @@ class BulkGmail extends Component $lastPos = 0; foreach ($combo as $pos) { - $dotted .= substr($uname, $lastPos, $pos - $lastPos) . '.'; + $dotted .= substr($uname, $lastPos, $pos - $lastPos).'.'; $lastPos = $pos; } $dotted .= substr($uname, $lastPos); - $results[] = $dotted . '@gmail.com'; + $results[] = $dotted.'@gmail.com'; if (count($results) >= $quantity) { return $results; diff --git a/app/Livewire/Dashboard/Dashboard.php b/app/Livewire/Dashboard/Dashboard.php index aeb3b2b..e1ba492 100644 --- a/app/Livewire/Dashboard/Dashboard.php +++ b/app/Livewire/Dashboard/Dashboard.php @@ -2,8 +2,6 @@ namespace App\Livewire\Dashboard; -use Stripe\StripeClient; -use Log; use App\Models\UsageLog; use Cache; use Carbon\Carbon; @@ -11,13 +9,19 @@ use DB; use Exception; use Illuminate\Http\Request; use Livewire\Component; +use Log; +use Stripe\StripeClient; class Dashboard extends Component { public $message; + public $usageLog; + public $subscription; + public $plans; + public $showStripeBilling = false; public function paymentStatus(Request $request) @@ -26,6 +30,7 @@ class Dashboard extends Component $currentUrl = $request->fullUrl(); if ($status == 'success') { $this->syncSubscription(); + return redirect()->route('dashboard')->with('status', 'success'); } elseif ($status == 'cancel') { return redirect()->route('dashboard')->with('status', 'cancel'); @@ -39,13 +44,13 @@ class Dashboard extends Component $userId = $user->id; if ($user->subscribed()) { $subscription = $user->subscriptions() - //->where(['stripe_status' => 'active']) + // ->where(['stripe_status' => 'active']) ->orderByDesc('updated_at') ->first(); if ($subscription !== null) { $subscriptionId = $subscription->stripe_id; $cacheKey = "stripe_check_executed_user_{$userId}_{$subscriptionId}"; - if (!Cache::has($cacheKey)) { + if (! Cache::has($cacheKey)) { try { $stripe = new StripeClient(config('cashier.secret')); $subscriptionData = $stripe->subscriptions->retrieve($subscriptionId, []); @@ -60,11 +65,11 @@ class Dashboard extends Component if ($cancel_at_period_end) { $final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString(); } else { - if ($cancel_at === null && $canceled_at !== null && $status === "canceled" && $cancel_at_period_end === false) { - //$final_ends_at = Carbon::createFromTimestamp($canceled_at)->toDateTimeString(); + if ($cancel_at === null && $canceled_at !== null && $status === 'canceled' && $cancel_at_period_end === false) { + // $final_ends_at = Carbon::createFromTimestamp($canceled_at)->toDateTimeString(); $final_ends_at = Carbon::now()->subDays(2)->toDateTimeString(); $redirect = true; - } elseif($status === "active" && $cancel_at !== null) { + } elseif ($status === 'active' && $cancel_at !== null) { $final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString(); } else { $final_ends_at = null; @@ -88,6 +93,7 @@ class Dashboard extends Component } } + return $redirect; } @@ -98,7 +104,7 @@ class Dashboard extends Component if ($user->hasStripeId()) { $stripe = new StripeClient(config('cashier.secret')); $subscriptions = $stripe->subscriptions->all(['limit' => 1]); - if (!$subscriptions->isEmpty()) { + if (! $subscriptions->isEmpty()) { $data = $subscriptions->data[0]; $items = $subscriptions->data[0]->items->data[0]; @@ -110,7 +116,7 @@ class Dashboard extends Component $stripe_price = $items->price->id; $stripe_product = $items->price->product; $ends_at = $items->current_period_end; - $subscriptionItemId = $items->id; + $subscriptionItemId = $items->id; if ($cancel_at_period_end) { $final_ends_at = Carbon::createFromTimestamp($ends_at)->toDateTimeString(); } else { @@ -118,7 +124,7 @@ class Dashboard extends Component } try { - if ($status === "active") { + if ($status === 'active') { $subscriptionsTable = DB::table('subscriptions')->where(['stripe_id' => $subscriptionId])->first(); if ($subscriptionsTable == null) { $subscriptionsTable = DB::table('subscriptions')->insert([ @@ -158,9 +164,9 @@ class Dashboard extends Component public function mount(Request $request) { - if($this->checkForSubscriptionStatus()) { + if ($this->checkForSubscriptionStatus()) { return redirect()->route('dashboard'); - }; + } try { $status = $request->session()->get('status'); if (isset($status)) { @@ -176,7 +182,7 @@ class Dashboard extends Component } $plans = config('app.plans', []); - if (!empty($plans) && isset($plans[0]) && is_array($plans[0]) && isset($plans[0]['product_id']) && auth()->user()->subscribedToProduct($plans[0]['product_id'])) { + if (! empty($plans) && isset($plans[0]) && is_array($plans[0]) && isset($plans[0]['product_id']) && auth()->user()->subscribedToProduct($plans[0]['product_id'])) { try { $result = auth()->user()->subscriptions()->where(['stripe_status' => 'active'])->orderByDesc('updated_at')->first(); if ($result != null) { diff --git a/app/Livewire/Dashboard/Mailbox/Inbox.php b/app/Livewire/Dashboard/Mailbox/Inbox.php index 2404b96..947cf2a 100644 --- a/app/Livewire/Dashboard/Mailbox/Inbox.php +++ b/app/Livewire/Dashboard/Mailbox/Inbox.php @@ -2,44 +2,62 @@ namespace App\Livewire\Dashboard\Mailbox; -use Exception; use App\ColorPicker; use App\Models\Log; use App\Models\Premium; use App\Models\PremiumEmail; use App\Models\UsageLog; use App\Models\ZEmail; -use Artisan; use Carbon\Carbon; +use Exception; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Cookie; use Livewire\Component; use Session; class Inbox extends Component { use ColorPicker; + public $messages = []; + public $deleted = []; + public $error = ''; + public $email; + public $initial = false; + public $type; + public $overflow = false; + public $messageId; + public $list = false; + public $emails; + public $mailboxHistory; + public $emailsHistory; - public $username, $domain, $domains, $action; + + public $username; + + public $domain; + + public $domains; + + public $action; + public $email_limit = 20; + public bool $premium = true; private $isSubscribed; protected $listeners = ['updateEmail' => 'syncEmail', 'getEmail' => 'generateEmail', 'fetchMessages' => 'fetch', 'setMessageId' => 'setMessageId']; - public function mount(): void { $this->premium = Session::get('isInboxTypePremium', true); @@ -64,7 +82,7 @@ class Inbox extends Component $subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']); Session::put('isSubscribed', $subscriptionCheck); - if($subscriptionCheck) { + if ($subscriptionCheck) { try { $result = auth()->user()->subscriptions()->where(['stripe_status' => 'active'])->orderByDesc('updated_at')->first(); $userPriceID = $result['items'][0]['stripe_price']; @@ -116,7 +134,7 @@ class Inbox extends Component } else { $domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; } - if (!in_array($domain, $domains)) { + if (! in_array($domain, $domains)) { return $this->showAlert('error', __('This mailbox can not be recovered.')); } } @@ -150,24 +168,25 @@ class Inbox extends Component } /* Actions */ - public function create() { - if (!$this->username) { + public function create() + { + if (! $this->username) { return $this->showAlert('error', __('Please enter Username')); } $this->checkDomainInUsername(); if (strlen($this->username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($this->username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) { - return $this->showAlert('error', __('Username length cannot be less than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_min . ' ' . __('and greater than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_max); + return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_max); } - if (!$this->domain) { + if (! $this->domain) { return $this->showAlert('error', __('Please Select a Domain')); } if (in_array($this->username, json_decode(config('app.settings.configuration_settings'))->forbidden_ids)) { return $this->showAlert('error', __('Username not allowed')); } - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of MAX ') . $this->email_limit . __(' temp mail')); + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of MAX ').$this->email_limit.__(' temp mail')); } - if (!$this->checkUsedEmail()) { + if (! $this->checkUsedEmail()) { return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.')); } if ($this->premium) { @@ -175,42 +194,51 @@ class Inbox extends Component } else { $this->email = ZEmail::createCustomEmail($this->username, $this->domain); } + return redirect()->route('dashboard.premium'); } - public function random() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.')); + public function random() + { + + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.')); } if ($this->premium) { $this->email = Premium::generateRandomEmail(); } else { $this->email = ZEmail::generateRandomEmail(); } + return redirect()->route('dashboard.premium'); } - public function gmail() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.')); + + public function gmail() + { + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.')); } if ($this->premium) { $this->email = Premium::generateRandomGmail(); } else { $this->email = ZEmail::generateRandomGmail(); } + return redirect()->route('dashboard.premium'); } - public function outlook() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.')); + public function outlook() + { + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.')); } if ($this->premium) { $this->email = Premium::generateRandomOutlook(); } else { $this->email = ZEmail::generateRandomOutlook(); } + return redirect()->route('dashboard.premium'); } @@ -230,18 +258,21 @@ class Inbox extends Component if (count($logs) >= $this->email_limit) { return false; } + return true; } private function checkUsedEmail(): bool { if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) { - $check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count(); + $check = Log::where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count(); if ($check > 0) { return false; } + return true; } + return true; } @@ -268,7 +299,7 @@ class Inbox extends Component } else { $domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; } - if (!in_array($domain, $domains)) { + if (! in_array($domain, $domains)) { $key = array_search($this->email, $this->emails); if ($this->premium) { Premium::removeEmail($this->email); @@ -290,7 +321,6 @@ class Inbox extends Component /* Mailbox */ - public function fetch(): void { try { @@ -300,33 +330,33 @@ class Inbox extends Component } $responses = []; if ($this->premium) { - if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->premium_cc_check) { + if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->premium_cc_check) { $responses = [ 'to' => Premium::getMessages($this->email, 'to', $this->deleted), 'cc' => [ 'data' => [], - 'notifications' => [] - ] + 'notifications' => [], + ], ]; } else { $responses = [ 'to' => Premium::getMessages($this->email, 'to', $this->deleted), - 'cc' => Premium::getMessages($this->email, 'cc', $this->deleted) + 'cc' => Premium::getMessages($this->email, 'cc', $this->deleted), ]; } } else { - if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) { + if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->cc_check) { $responses = [ 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted), 'cc' => [ 'data' => [], - 'notifications' => [] - ] + 'notifications' => [], + ], ]; } else { $responses = [ 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted), - 'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted) + 'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted), ]; } } @@ -336,7 +366,7 @@ class Inbox extends Component $notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']); if (count($notifications)) { - if (!$this->overflow && count($this->messages) == $count) { + if (! $this->overflow && count($this->messages) == $count) { $this->overflow = true; } } else { @@ -367,16 +397,17 @@ class Inbox extends Component $this->initial = true; } - public function delete($messageId) { + public function delete($messageId) + { try { $this->deleted[] = $messageId; foreach ($this->messages as $key => $message) { if ($message['id'] == $messageId) { if ($this->premium) { - $directory = public_path('tmp/premium/attachments/') . $messageId; + $directory = public_path('tmp/premium/attachments/').$messageId; } else { - $directory = public_path('tmp/attachments/') . $messageId; + $directory = public_path('tmp/attachments/').$messageId; } $this->rrmdir($directory); unset($this->messages[$key]); @@ -384,7 +415,7 @@ class Inbox extends Component } } catch ( - Exception $exception + Exception $exception ) { \Illuminate\Support\Facades\Log::error($exception->getMessage()); } @@ -393,7 +424,7 @@ class Inbox extends Component public function toggleMode() { - $this->premium = !$this->premium; + $this->premium = ! $this->premium; Session::put('isInboxTypePremium', $this->premium); if ($this->premium) { $this->domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? []; @@ -432,11 +463,12 @@ class Inbox extends Component if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . "/" . $object)) - $this->rrmdir($dir . DIRECTORY_SEPARATOR . $object); - else - unlink($dir . DIRECTORY_SEPARATOR . $object); + if ($object != '.' && $object != '..') { + if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) { + $this->rrmdir($dir.DIRECTORY_SEPARATOR.$object); + } else { + unlink($dir.DIRECTORY_SEPARATOR.$object); + } } } rmdir($dir); diff --git a/app/Livewire/Dashboard/Pricing.php b/app/Livewire/Dashboard/Pricing.php index 9dde791..7f23b93 100644 --- a/app/Livewire/Dashboard/Pricing.php +++ b/app/Livewire/Dashboard/Pricing.php @@ -2,15 +2,16 @@ namespace App\Livewire\Dashboard; -use Exception; -use Log; use App\Models\ActivationKey; use App\Models\Plan; +use Exception; use Livewire\Component; +use Log; class Pricing extends Component { public $plans; + public $activation_key; public function mount(): void @@ -66,12 +67,12 @@ class Pricing extends Component $user->updateStripeCustomer([ 'address' => [ 'postal_code' => '10001', - 'country' => 'US', + 'country' => 'US', ], 'name' => $user->name, 'email' => $user->email, ]); - $user->creditBalance($plan->price * 100, 'Premium Top-up for plan: ' . $plan->name); + $user->creditBalance($plan->price * 100, 'Premium Top-up for plan: '.$plan->name); $balance = $user->balance(); $user->newSubscription('default', $plan->pricing_id)->create(); @@ -81,12 +82,15 @@ class Pricing extends Component $ends_at = now()->addYear(); } $user->subscription('default')->cancelAt($ends_at); + return true; } catch (Exception $e) { Log::error($e->getMessage()); + return false; } } + public function render() { return view('livewire.dashboard.pricing'); diff --git a/app/Livewire/Dashboard/Support.php b/app/Livewire/Dashboard/Support.php index 65a2535..4b345cc 100644 --- a/app/Livewire/Dashboard/Support.php +++ b/app/Livewire/Dashboard/Support.php @@ -2,9 +2,9 @@ namespace App\Livewire\Dashboard; -use Exception; use App\Models\Ticket; use App\Models\TicketResponse; +use Exception; use Livewire\Component; use Request; use Str; @@ -12,11 +12,17 @@ use Str; class Support extends Component { public $tickets = []; + public $subject; + public $message; + public $response; + public $list = false; + public $open = 0; + public $closed = 0; public function store() @@ -37,15 +43,14 @@ class Support extends Component ]); $this->dispatch('showAlert', ['type' => 'success', 'message' => 'Your ticket has been created successfully!']); $this->dispatch('closeModal'); - $this->reset(['subject','message']); + $this->reset(['subject', 'message']); $this->tickets = Ticket::with('responses') - ->where('user_id', auth()->id()) - ->get(); + ->where('user_id', auth()->id()) + ->get(); } catch (Exception $exception) { $this->dispatch('showAlert', ['type' => 'error', 'message' => 'Something went wrong!']); } - } public function reply($ticket_id) @@ -56,14 +61,16 @@ class Support extends Component try { - if (!is_numeric($ticket_id)) { + if (! is_numeric($ticket_id)) { $this->dispatch('showAlert', ['type' => 'error', 'message' => 'Invalid ticket ID.']); + return; } $ticket = Ticket::find($ticket_id); - if (!$ticket) { + if (! $ticket) { $this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']); + return; } @@ -91,13 +98,15 @@ class Support extends Component public function close($ticket_id) { - if (!is_numeric($ticket_id)) { + if (! is_numeric($ticket_id)) { $this->dispatch('showAlert', ['type' => 'error', 'message' => 'Invalid ticket ID.']); + return; } $ticket = Ticket::find($ticket_id); - if (!$ticket) { + if (! $ticket) { $this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']); + return; } @@ -113,8 +122,8 @@ class Support extends Component public function mount() { $this->tickets = Ticket::with('responses') - ->where('user_id', auth()->id()) - ->get(); + ->where('user_id', auth()->id()) + ->get(); $this->updateTicketCounts(); } diff --git a/app/Livewire/Frontend/Action.php b/app/Livewire/Frontend/Action.php index fccd712..57044b8 100644 --- a/app/Livewire/Frontend/Action.php +++ b/app/Livewire/Frontend/Action.php @@ -9,61 +9,83 @@ use Livewire\Component; class Action extends Component { - public $username, $email, $emails, $domain, $domains, $action, $initial; - public function mount() { + public $username; + + public $email; + + public $emails; + + public $domain; + + public $domains; + + public $action; + + public $initial; + + public function mount() + { $this->domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; $this->email = ZEmail::getEmail(); $this->emails = ZEmail::getEmails(); $this->validateDomainInEmail(); } - public function create() { - if (!$this->username) { + public function create() + { + if (! $this->username) { return $this->showAlert('error', __('Please enter Username')); } $this->checkDomainInUsername(); if (strlen($this->username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($this->username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) { - return $this->showAlert('error', __('Username length cannot be less than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_min . ' ' . __('and greater than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_max); + return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_max); } - if (!$this->domain) { + if (! $this->domain) { return $this->showAlert('error', __('Please Select a Domain')); } if (in_array($this->username, json_decode(config('app.settings.configuration_settings'))->forbidden_ids)) { return $this->showAlert('error', __('Username not allowed')); } - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of MAX ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail')); + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of MAX ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail')); } - if (!$this->checkUsedEmail()) { + if (! $this->checkUsedEmail()) { return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.')); } $this->email = ZEmail::createCustomEmail($this->username, $this->domain); + return redirect()->route('mailbox'); } - public function random() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.')); + + public function random() + { + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.')); } $this->email = ZEmail::generateRandomEmail(); return redirect()->route('mailbox'); } - public function gmail() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.')); + public function gmail() + { + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.')); } $this->email = ZEmail::generateRandomGmail(); + return redirect()->route('mailbox'); } - public function outlook() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.')); + public function outlook() + { + if (! $this->checkEmailLimit()) { + return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.')); } $this->email = ZEmail::generateRandomOutlook(); + return redirect()->route('mailbox'); } @@ -87,22 +109,26 @@ class Action extends Component if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->email_limit) { return false; } + return true; } private function checkUsedEmail(): bool { if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) { - $check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count(); + $check = Log::where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count(); if ($check > 0) { return false; } + return true; } + return true; } - private function checkDomainInUsername() { + private function checkDomainInUsername() + { $parts = explode('@', $this->username); if (isset($parts[1])) { if (in_array($parts[1], $this->domains)) { @@ -118,7 +144,7 @@ class Action extends Component if (isset($data[1])) { $domain = $data[1]; $domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; - if (!in_array($domain, $domains)) { + if (! in_array($domain, $domains)) { $key = array_search($this->email, $this->emails); ZEmail::removeEmail($this->email); if ($key == 0 && count($this->emails) == 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') { @@ -129,7 +155,9 @@ class Action extends Component } } } - public function render() { + + public function render() + { return view('livewire.frontend.action'); } } diff --git a/app/Livewire/Frontend/Email.php b/app/Livewire/Frontend/Email.php index 0f32e15..3493df9 100644 --- a/app/Livewire/Frontend/Email.php +++ b/app/Livewire/Frontend/Email.php @@ -8,7 +8,14 @@ use Livewire\Component; class Email extends Component { public $list = false; - public $type, $email, $emails, $initial; + + public $type; + + public $email; + + public $emails; + + public $initial; protected $listeners = ['updateEmail' => 'syncEmail', 'getEmail' => 'generateEmail']; diff --git a/app/Livewire/Frontend/Mailbox.php b/app/Livewire/Frontend/Mailbox.php index 9c51d46..c0a6c68 100644 --- a/app/Livewire/Frontend/Mailbox.php +++ b/app/Livewire/Frontend/Mailbox.php @@ -2,11 +2,11 @@ namespace App\Livewire\Frontend; -use Exception; -use App\Models\Email; use App\ColorPicker; +use App\Models\Email; use App\Models\Message; use App\Models\ZEmail; +use Exception; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Livewire\Component; @@ -16,12 +16,19 @@ class Mailbox extends Component use ColorPicker; public $messages = []; + public $deleted = []; + public $error = ''; + public $email; + public $initial = false; + public $type; + public $overflow = false; + public $messageId; protected $listeners = ['fetchMessages' => 'fetch', 'syncMailbox' => 'syncEmail', 'setMessageId' => 'setMessageId']; @@ -30,10 +37,11 @@ class Mailbox extends Component { $this->email = ZEmail::getEmail(); $this->initial = false; - if (!ZEmail::getEmail()) { + if (! ZEmail::getEmail()) { return redirect()->route('home'); } } + public function syncEmail($email): void { $this->email = $email; @@ -49,18 +57,18 @@ class Mailbox extends Component $this->messages = []; } $responses = []; - if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) { + if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->cc_check) { $responses = [ 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted), 'cc' => [ 'data' => [], - 'notifications' => [] - ] + 'notifications' => [], + ], ]; } else { $responses = [ 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted), - 'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted) + 'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted), ]; } @@ -69,7 +77,7 @@ class Mailbox extends Component $notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']); if (count($notifications)) { - if (!$this->overflow && count($this->messages) == $count) { + if (! $this->overflow && count($this->messages) == $count) { $this->overflow = true; } } else { @@ -91,7 +99,8 @@ class Mailbox extends Component $this->initial = true; } - public function delete($messageId) { + public function delete($messageId) + { try { if (config('app.beta_feature')) { @@ -103,7 +112,7 @@ class Mailbox extends Component $this->deleted[] = $messageId; foreach ($this->messages as $key => $message) { if ($message['id'] == $messageId) { - $directory = public_path('tmp/attachments/') . $messageId; + $directory = public_path('tmp/attachments/').$messageId; $this->rrmdir($directory); unset($this->messages[$key]); } @@ -127,11 +136,12 @@ class Mailbox extends Component if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . "/" . $object)) - $this->rrmdir($dir . DIRECTORY_SEPARATOR . $object); - else - unlink($dir . DIRECTORY_SEPARATOR . $object); + if ($object != '.' && $object != '..') { + if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) { + $this->rrmdir($dir.DIRECTORY_SEPARATOR.$object); + } else { + unlink($dir.DIRECTORY_SEPARATOR.$object); + } } } rmdir($dir); diff --git a/app/Livewire/Home.php b/app/Livewire/Home.php index fdef19b..1859296 100644 --- a/app/Livewire/Home.php +++ b/app/Livewire/Home.php @@ -17,6 +17,7 @@ class Home extends Component return redirect()->route('mailbox'); } } + public function render() { return view('livewire.home'); diff --git a/app/Livewire/Page.php b/app/Livewire/Page.php index 9696d9b..8186614 100644 --- a/app/Livewire/Page.php +++ b/app/Livewire/Page.php @@ -9,7 +9,6 @@ class Page extends Component public $slug; public function mount($slug) - { $this->slug = $slug; } @@ -18,9 +17,10 @@ class Page extends Component { $page = \App\Models\Page::where('slug', $this->slug)->firstOrFail(); - if ($page->is_published == false ) { + if ($page->is_published == false) { abort(404); } + return view('livewire.page', [ 'page' => $page, ]); diff --git a/app/Livewire/Settings/Appearance.php b/app/Livewire/Settings/Appearance.php index be0927a..5fd9608 100644 --- a/app/Livewire/Settings/Appearance.php +++ b/app/Livewire/Settings/Appearance.php @@ -4,6 +4,7 @@ namespace App\Livewire\Settings; use Livewire\Attributes\Layout; use Livewire\Component; + #[Layout('components.layouts.dashboard')] class Appearance extends Component diff --git a/app/Livewire/Settings/DeleteUserForm.php b/app/Livewire/Settings/DeleteUserForm.php index 22c34eb..8ef2c6e 100644 --- a/app/Livewire/Settings/DeleteUserForm.php +++ b/app/Livewire/Settings/DeleteUserForm.php @@ -6,6 +6,7 @@ use App\Livewire\Actions\Logout; use Illuminate\Support\Facades\Auth; use Livewire\Attributes\Layout; use Livewire\Component; + #[Layout('components.layouts.dashboard')] class DeleteUserForm extends Component diff --git a/app/Livewire/Settings/Password.php b/app/Livewire/Settings/Password.php index 9fb0d26..8e3f5a6 100644 --- a/app/Livewire/Settings/Password.php +++ b/app/Livewire/Settings/Password.php @@ -8,6 +8,7 @@ use Illuminate\Validation\Rules\Password as PasswordRule; use Illuminate\Validation\ValidationException; use Livewire\Attributes\Layout; use Livewire\Component; + #[Layout('components.layouts.dashboard')] class Password extends Component diff --git a/app/Mail/TicketResponseNotification.php b/app/Mail/TicketResponseNotification.php index 1924115..1526420 100644 --- a/app/Mail/TicketResponseNotification.php +++ b/app/Mail/TicketResponseNotification.php @@ -2,13 +2,11 @@ namespace App\Mail; -use Illuminate\Mail\Mailables\Attachment; use App\Models\Ticket; -use App\Models\TicketResponse; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Database\Eloquent\Collection; use Illuminate\Mail\Mailable; +use Illuminate\Mail\Mailables\Attachment; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Queue\SerializesModels; @@ -18,7 +16,9 @@ class TicketResponseNotification extends Mailable use Queueable, SerializesModels; public Ticket $ticket; + public Collection $responses; + /** * Create a new message instance. */ @@ -34,7 +34,7 @@ class TicketResponseNotification extends Mailable public function envelope(): Envelope { return new Envelope( - subject: 'Support Ticket Response: #'. $this->ticket->ticket_id, + subject: 'Support Ticket Response: #'.$this->ticket->ticket_id, ); } diff --git a/app/Models/Category.php b/app/Models/Category.php index cb1533a..38b5b42 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -13,14 +13,15 @@ class Category extends Model protected $fillable = [ 'name', 'slug', - 'is_active' + 'is_active', ]; protected $casts = [ 'is_active' => 'boolean', ]; - public function blogs(): HasMany { + public function blogs(): HasMany + { return $this->hasMany(Blog::class); } } diff --git a/app/Models/Email.php b/app/Models/Email.php index 0bf6d76..902164b 100644 --- a/app/Models/Email.php +++ b/app/Models/Email.php @@ -2,19 +2,19 @@ namespace App\Models; -use Ddeboer\Imap\ConnectionInterface; -use DateTime; -use Exception; -use Illuminate\Support\Facades\Log; use App\ColorPicker; use Carbon\Carbon; use Carbon\CarbonImmutable; +use DateTime; +use Ddeboer\Imap\ConnectionInterface; use Ddeboer\Imap\Search\Date\Since; use Ddeboer\Imap\Search\Email\To; use Ddeboer\Imap\Server; +use Exception; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Validator; class Email extends Model diff --git a/app/Models/Menu.php b/app/Models/Menu.php index ffe1e39..161cb02 100644 --- a/app/Models/Menu.php +++ b/app/Models/Menu.php @@ -13,7 +13,7 @@ class Menu extends Model 'name', 'url', 'new_tab', - 'parent' + 'parent', ]; public function parentname() diff --git a/app/Models/Message.php b/app/Models/Message.php index df76d53..5652408 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -2,17 +2,17 @@ namespace App\Models; -use DateTime; -use Exception; -use Illuminate\Support\Facades\Log; use App\ColorPicker; use Carbon\Carbon; +use DateTime; use Ddeboer\Imap\Search\Email\Cc; use Ddeboer\Imap\Search\Email\To; use Ddeboer\Imap\SearchExpression; +use Exception; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; class Message extends Model diff --git a/app/Models/Meta.php b/app/Models/Meta.php index 0557aed..92c5b00 100644 --- a/app/Models/Meta.php +++ b/app/Models/Meta.php @@ -5,7 +5,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class Meta extends Model { +class Meta extends Model +{ use HasFactory; protected $fillable = [ @@ -13,9 +14,11 @@ class Meta extends Model { 'value', ]; - public function incrementMeta($value = 1) { + public function incrementMeta($value = 1) + { $this->value = $this->value + $value; $this->save(); + return true; } @@ -24,8 +27,10 @@ class Meta extends Model { $meta = Meta::where('key', 'email_ids_created')->first(); if ($meta) { $meta->incrementMeta($value); + return true; } + return false; } @@ -34,24 +39,30 @@ class Meta extends Model { $meta = Meta::where('key', 'messages_received')->first(); if ($meta) { $meta->incrementMeta($value); + return true; } + return false; } - public static function getEmailIdsCreated() { + public static function getEmailIdsCreated() + { $meta = Meta::where('key', 'email_ids_created')->first(); if ($meta) { return $meta->value; } - return "NaN"; + + return 'NaN'; } - public static function getMessagesReceived() { + public static function getMessagesReceived() + { $meta = Meta::where('key', 'messages_received')->first(); if ($meta) { return $meta->value; } - return "NaN"; + + return 'NaN'; } } diff --git a/app/Models/Page.php b/app/Models/Page.php index fce9395..b6437f3 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -17,7 +17,7 @@ class Page extends Model 'meta', 'custom_header', 'page_image', - 'is_published' + 'is_published', ]; protected $casts = [ diff --git a/app/Models/Premium.php b/app/Models/Premium.php index d3b7b1f..6b3710f 100644 --- a/app/Models/Premium.php +++ b/app/Models/Premium.php @@ -2,23 +2,23 @@ namespace App\Models; -use Ddeboer\Imap\ConnectionInterface; -use DateTime; -use Exception; -use Log; use App\ColorPicker; use Carbon\Carbon; +use DateTime; +use Ddeboer\Imap\ConnectionInterface; use Ddeboer\Imap\Search\Email\Cc; use Ddeboer\Imap\Search\Email\To; use Ddeboer\Imap\SearchExpression; -use Ddeboer\Imap\Server; +use Exception; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cookie; +use Log; class Premium extends Model { use ColorPicker; + public static function connectMailBox($imap = null): ConnectionInterface { $imapDB = json_decode(config('app.settings.imap_settings'), true); @@ -31,7 +31,7 @@ class Premium extends Model 'password' => $imapDB['premium_password'], 'default_account' => $imapDB['premium_default_account'], 'protocol' => $imapDB['premium_protocol'], - 'cc_check' => $imapDB['premium_cc_check'] + 'cc_check' => $imapDB['premium_cc_check'], ]; return ZEmail::connectMailBox($imap); @@ -41,15 +41,15 @@ class Premium extends Model { if ($email == null) { return [ - "data" => [], - "notifications" => [] + 'data' => [], + 'notifications' => [], ]; } $allowed = explode(',', 'doc,docx,xls,xlsx,ppt,pptx,xps,pdf,dxf,ai,psd,eps,ps,svg,ttf,zip,rar,tar,gzip,mp3,mpeg,wav,ogg,jpeg,jpg,png,gif,bmp,tif,webm,mpeg4,3gpp,mov,avi,mpegs,wmv,flx,txt'); $connection = self::connectMailBox(); $mailbox = $connection->getMailbox('INBOX'); - $search = new SearchExpression(); + $search = new SearchExpression; if ($type == 'cc') { $search->addCondition(new Cc($email)); } else { @@ -60,18 +60,19 @@ class Premium extends Model $count = 1; $response = [ 'data' => [], - 'notifications' => [] + 'notifications' => [], ]; foreach ($messages as $message) { if (in_array($message->getNumber(), $deleted)) { $message->delete(); + continue; } $blocked = false; $sender = $message->getFrom(); $date = $message->getDate(); - if (!$date) { - $date = new DateTime(); + if (! $date) { + $date = new DateTime; if ($message->getHeaders()->get('udate')) { $date->setTimestamp($message->getHeaders()->get('udate')); } @@ -82,12 +83,12 @@ class Premium extends Model $html = $message->getBodyHtml(); $text = $message->getBodyText(); if ($text) { - $contentText = str_replace('', $text)); + $content = str_replace('', $text)); } if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) { $content = str_replace('href="', 'href="http://href.li/?', $content); @@ -106,28 +107,28 @@ class Premium extends Model $obj['contentText'] = $contentText; $obj['attachments'] = []; $obj['is_seen'] = true; - $obj['sender_photo'] = self::chooseColor(strtoupper(substr($sender->getName() ?: $sender->getAddress(), 0, 1) )); + $obj['sender_photo'] = self::chooseColor(strtoupper(substr($sender->getName() ?: $sender->getAddress(), 0, 1))); - //Checking if Sender is Blocked + // Checking if Sender is Blocked $domain = explode('@', $obj['sender_email'])[1]; $blocked = in_array($domain, json_decode(config('app.settings.configuration_settings'))->blocked_domains); if ($blocked) { $obj['subject'] = __('Blocked'); - $obj['content'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin'); - $obj['contentText'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin'); + $obj['content'] = __('Emails from').' '.$domain.' '.__('are blocked by Admin'); + $obj['contentText'] = __('Emails from').' '.$domain.' '.__('are blocked by Admin'); } - if ($message->hasAttachments() && !$blocked) { + if ($message->hasAttachments() && ! $blocked) { $attachments = $message->getAttachments(); - $directory = './tmp/premium/attachments/' . $obj['id'] . '/'; + $directory = './tmp/premium/attachments/'.$obj['id'].'/'; is_dir($directory) || mkdir($directory, 0777, true); foreach ($attachments as $attachment) { $filenameArray = explode('.', $attachment->getFilename()); $extension = $filenameArray[count($filenameArray) - 1]; if (in_array($extension, $allowed)) { - if (!file_exists($directory . $attachment->getFilename())) { + if (! file_exists($directory.$attachment->getFilename())) { try { file_put_contents( - $directory . $attachment->getFilename(), + $directory.$attachment->getFilename(), $attachment->getDecodedContent() ); } catch (Exception $e) { @@ -135,28 +136,28 @@ class Premium extends Model } } if ($attachment->getFilename() !== 'undefined') { - $url = config('app.settings.app_base_url') . str_replace('./', '/', $directory . $attachment->getFilename()); + $url = config('app.settings.app_base_url').str_replace('./', '/', $directory.$attachment->getFilename()); $structure = $attachment->getStructure(); if (isset($structure->id) && str_contains($obj['content'], trim($structure->id, '<>'))) { - $obj['content'] = str_replace('cid:' . trim($structure->id, '<>'), $url, $obj['content']); + $obj['content'] = str_replace('cid:'.trim($structure->id, '<>'), $url, $obj['content']); } $obj['attachments'][] = [ 'file' => $attachment->getFilename(), - 'url' => $url + 'url' => $url, ]; } } } } $response['data'][] = $obj; - if (!$message->isSeen()) { + if (! $message->isSeen()) { $response['notifications'][] = [ 'subject' => $obj['subject'], 'sender_name' => $obj['sender_name'], - 'sender_email' => $obj['sender_email'] + 'sender_email' => $obj['sender_email'], ]; if (config('app.zemail_log')) { - file_put_contents(storage_path('logs/zemail.csv'), request()->ip() . "," . date("Y-m-d h:i:s a") . "," . $obj['sender_email'] . "," . $email . PHP_EOL, FILE_APPEND); + file_put_contents(storage_path('logs/zemail.csv'), request()->ip().','.date('Y-m-d h:i:s a').','.$obj['sender_email'].','.$email.PHP_EOL, FILE_APPEND); } } $message->markAsSeen(); @@ -167,6 +168,7 @@ class Premium extends Model $response['data'] = array_reverse($response['data']); $connection->expunge(); + return $response; } @@ -174,6 +176,7 @@ class Premium extends Model { return self::fetchMessages($email, $type, $deleted); } + public static function deleteMessage($id): void { $connection = self::connectMailBox(); @@ -181,20 +184,25 @@ class Premium extends Model $mailbox->getMessage($id)->delete(); $connection->expunge(); } - public static function getEmail($generate = false) { + + public static function getEmail($generate = false) + { if (Cookie::has('p_email')) { return Cookie::get('p_email'); } else { return $generate ? self::generateRandomEmail() : null; } } - public static function getEmails() { + + public static function getEmails() + { if (Cookie::has('p_emails')) { return unserialize(Cookie::get('p_emails')); } else { return []; } } + public static function setEmail($email): void { $emails = unserialize(Cookie::get('p_emails')); @@ -211,6 +219,7 @@ class Premium extends Model Cookie::queue('p_email', $email, 43800); } } + public static function removeEmail($email): void { $emails = self::getEmails(); @@ -226,17 +235,20 @@ class Premium extends Model Cookie::queue('p_emails', serialize([]), -1); } } + public static function createCustomEmailFull($email): string { $data = explode('@', $email); $username = $data[0]; if (strlen($username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) { - $zemail = new Premium(); + $zemail = new Premium; $username = $zemail->generateRandomUsername(); } $domain = $data[1]; + return self::createCustomEmail($username, $domain); } + public static function createCustomEmail($username, $domain): string { $username = preg_replace('/[^a-zA-Z0-9+.]/', '', strtolower($username)); @@ -259,7 +271,7 @@ class Premium extends Model return self::generateRandomOutlook(true); } - $zemail = new Premium(); + $zemail = new Premium; if ($username === '' && in_array($domain, $domains)) { return $zemail->generateRandomUsername().'@'.$domain; @@ -270,14 +282,15 @@ class Premium extends Model [$check_username, $post_username] = explode('+', $username, 2); if (in_array($check_username, $outlook_usernames)) { - $email = $username . '@' . $domain; + $email = $username.'@'.$domain; } else { - $email = $zemail->getRandomOutlookUser() . '+' . $post_username . '@' . $domain; + $email = $zemail->getRandomOutlookUser().'+'.$post_username.'@'.$domain; } } else { - $email = $zemail->getRandomOutlookUser() . '+' . $username . '@' . $domain; + $email = $zemail->getRandomOutlookUser().'+'.$username.'@'.$domain; } self::storeEmail($email); + return $email; } @@ -286,142 +299,152 @@ class Premium extends Model [$check_username, $post_username] = explode('+', $username, 2); if (in_array($check_username, $gmail_usernames)) { - $email = $username . '@' . $domain; + $email = $username.'@'.$domain; } else { - $email = $zemail->getRandomGmailUser() . '+' . $post_username . '@' . $domain; + $email = $zemail->getRandomGmailUser().'+'.$post_username.'@'.$domain; } } elseif (str_contains($username, '.')) { $check_username = str_replace('.', '', $username); if (in_array($check_username, $gmail_usernames)) { - $email = $username . '@' . $domain; + $email = $username.'@'.$domain; } else { - $email = $zemail->generateRandomGmail() . '@' . $domain; + $email = $zemail->generateRandomGmail().'@'.$domain; } } else { - $email = $zemail->getRandomGmailUser() . '+' . $username . '@' . $domain; + $email = $zemail->getRandomGmailUser().'+'.$username.'@'.$domain; } self::storeEmail($email); + return $email; } // Handle other custom domains - if (!in_array($domain, $domains)) { + if (! in_array($domain, $domains)) { return self::generateRandomEmail(true); } $finalDomain = in_array($domain, $domains) ? $domain : ($domains[0] ?? 'example.com'); - $email = $username . '@' . $finalDomain; + $email = $username.'@'.$finalDomain; self::storeEmail($email); + return $email; } + public static function generateRandomEmail($store = true): string { - $zemail = new Premium(); + $zemail = new Premium; $domain = $zemail->getRandomDomain(); - if ($domain == "gmail.com") { - $rd = mt_rand(0,1); + if ($domain == 'gmail.com') { + $rd = mt_rand(0, 1); if ($rd == 0) { $email = $zemail->generateRandomGmail(false); } else { $email = $zemail->getRandomGmailUser().'+'.$zemail->generateRandomUsername().'@gmail.com'; } - } elseif ($domain == "googlemail.com") { - $rd = mt_rand(0,1); + } elseif ($domain == 'googlemail.com') { + $rd = mt_rand(0, 1); if ($rd == 0) { $email = $zemail->generateRandomGmail(false); } else { $email = $zemail->getRandomGmailUser().'+'.$zemail->generateRandomUsername().'@googlemail.com'; } - } elseif ($domain == "outlook.com") { + } elseif ($domain == 'outlook.com') { $email = $zemail->getRandomOutlookUser().'+'.$zemail->generateRandomUsername().'@outlook.com'; - } - else { - $email = $zemail->generateRandomUsername() . '@' . $domain; + } else { + $email = $zemail->generateRandomUsername().'@'.$domain; } if ($store) { self::storeEmail($email); } + return $email; } + public static function generateRandomGmail($store = true): string { - $zemail = new Premium(); + $zemail = new Premium; $uname = $zemail->getRandomGmailUser(); $uname_len = strlen($uname); $len_power = $uname_len - 1; - $combination = pow(2,$len_power); - $rand_comb = mt_rand(1,$combination); - $formatted = implode(' ',str_split($uname)); + $combination = pow(2, $len_power); + $rand_comb = mt_rand(1, $combination); + $formatted = implode(' ', str_split($uname)); $uname_exp = explode(' ', $formatted); - $bin = intval(""); - for($i=0; $i<$len_power; $i++) { - $bin .= mt_rand(0,1); + $bin = intval(''); + for ($i = 0; $i < $len_power; $i++) { + $bin .= mt_rand(0, 1); } - $bin = explode(' ', implode(' ',str_split(strval($bin)))); + $bin = explode(' ', implode(' ', str_split(strval($bin)))); - $email = ""; - for($i=0; $i<$len_power; $i++) { + $email = ''; + for ($i = 0; $i < $len_power; $i++) { $email .= $uname_exp[$i]; - if($bin[$i]) { - $email .= "."; + if ($bin[$i]) { + $email .= '.'; } } $email .= $uname_exp[$i]; - $gmail_rand = mt_rand(1,10); - if($gmail_rand > 5) { - $email .= "@gmail.com"; + $gmail_rand = mt_rand(1, 10); + if ($gmail_rand > 5) { + $email .= '@gmail.com'; } else { - $email .= "@googlemail.com"; + $email .= '@googlemail.com'; } if ($store) { self::storeEmail($email); } + return $email; } public static function generateRandomOutlook($store = true): string { - $zemail = new Premium(); + $zemail = new Premium; $email = $zemail->getRandomOutlookUser().'+'.$zemail->generateRandomUsername().'@outlook.com'; if ($store) { self::storeEmail($email); } + return $email; } + private static function storeEmail($email): void { Log::create([ 'user_id' => auth()->user()->id, 'ip' => request()->ip(), - 'email' => $email + 'email' => $email, ]); self::storeUsageLog($email); Cookie::queue('p_email', $email, 43800); $emails = Cookie::has('p_emails') ? unserialize(Cookie::get('p_emails')) : []; - if (!in_array($email, $emails)) { + if (! in_array($email, $emails)) { self::incrementEmailStats(); $emails[] = $email; Cookie::queue('p_emails', serialize($emails), 43800); } } + public static function incrementEmailStats($count = 1): void { Meta::incrementEmailIdsCreated($count); self::incrementEmailIdsCreated($count); } + public static function incrementMessagesStats($count = 1): void { Meta::incrementMessagesReceived($count); self::incrementMessagesReceived($count); } + private function generateRandomUsername(): string { $start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0; @@ -429,41 +452,56 @@ class Premium extends Model if ($start == 0 && $end == 0) { return $this->generatePronounceableWord(); } + return $this->generatedRandomBetweenLength($start, $end); } + protected function generatedRandomBetweenLength($start, $end): string { $length = rand($start, $end); + return $this->generateRandomString($length); } - private function getRandomDomain() { + + private function getRandomDomain() + { $domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? []; $count = count($domains); + return $count > 0 ? $domains[rand(1, $count) - 1] : ''; } - private function getRandomGmailUser() { + + private function getRandomGmailUser() + { $gmailusername = json_decode(config('app.settings.configuration_settings'))->premium_gmailUsernames ?? []; $count = count($gmailusername); + return $count > 0 ? $gmailusername[rand(1, $count) - 1] : ''; } - private function getRandomOutlookUser() { + + private function getRandomOutlookUser() + { $outlook_username = json_decode(config('app.settings.configuration_settings'))->premium_outlookUsernames ?? []; $count = count($outlook_username); + return $count > 0 ? $outlook_username[rand(1, $count) - 1] : ''; } + private function generatePronounceableWord(): string { - $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones - $v = 'aeiou'; //vowels - $a = $c . $v; //both + $c = 'bcdfghjklmnprstvwz'; // consonants except hard to speak ones + $v = 'aeiou'; // vowels + $a = $c.$v; // both $random = ''; for ($j = 0; $j < 2; $j++) { $random .= $c[rand(0, strlen($c) - 1)]; $random .= $v[rand(0, strlen($v) - 1)]; $random .= $a[rand(0, strlen($a) - 1)]; } + return $random; } + private function generateRandomString($length = 10): string { $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; @@ -472,18 +510,17 @@ class Premium extends Model for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } + return $randomString; } /** * Stats Handling Functions */ - - public static function incrementEmailIdsCreated($count = 1): void { $user = Auth::user(); - if (!$user) { + if (! $user) { return; } @@ -498,7 +535,7 @@ class Premium extends Model public static function incrementMessagesReceived($count = 1): void { $user = Auth::user(); - if (!$user) { + if (! $user) { return; } @@ -514,7 +551,7 @@ class Premium extends Model { try { $user = Auth::user(); - if (!$user) { + if (! $user) { return; } @@ -525,9 +562,9 @@ class Premium extends Model ); $history = $usageLog->emails_created_history ?? []; - if (!in_array($email, $history)) { + if (! in_array($email, $history)) { $history[] = $email; - //$usageLog->emails_created_count += 1; + // $usageLog->emails_created_count += 1; $usageLog->emails_created_history = $history; $usageLog->save(); } diff --git a/app/Models/RemoteEmail.php b/app/Models/RemoteEmail.php index 1be7530..785f73e 100644 --- a/app/Models/RemoteEmail.php +++ b/app/Models/RemoteEmail.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Validator; class RemoteEmail extends Model { use HasFactory; + protected $table = 'emails'; public function getConnectionName() @@ -20,7 +21,6 @@ class RemoteEmail extends Model return 'mysql_remote'; } - protected $fillable = [ 'message_id', 'subject', @@ -42,12 +42,13 @@ class RemoteEmail extends Model public static function fetchEmailFromDB($email) { $validator = Validator::make(['email' => $email], [ - 'email' => 'required|email' + 'email' => 'required|email', ]); if ($validator->fails()) { return []; } + return self::whereJsonContains('to', $email)->orderBy('timestamp', 'desc')->get(); } } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 06a1609..d95d449 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -4,7 +4,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; class Setting extends Model { diff --git a/app/Models/Ticket.php b/app/Models/Ticket.php index ca807a5..18f1c74 100644 --- a/app/Models/Ticket.php +++ b/app/Models/Ticket.php @@ -2,8 +2,8 @@ namespace App\Models; -use Exception; use Carbon\Carbon; +use Exception; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; @@ -13,7 +13,7 @@ class Ticket extends Model use HasFactory; protected $fillable = [ - 'user_id', 'ticket_id', 'subject', 'message', 'status', 'last_response_at', 'ip_address' + 'user_id', 'ticket_id', 'subject', 'message', 'status', 'last_response_at', 'ip_address', ]; protected static function boot() @@ -22,7 +22,7 @@ class Ticket extends Model static::creating(function ($ticket) { if (empty($ticket->ticket_id)) { - $ticket->ticket_id = 'TICKET-' . strtoupper(Str::random(6)); + $ticket->ticket_id = 'TICKET-'.strtoupper(Str::random(6)); } }); } @@ -61,6 +61,7 @@ class Ticket extends Model ]); } } + return true; } catch (Exception $e) { return false; diff --git a/app/Models/TicketResponse.php b/app/Models/TicketResponse.php index 38a0565..9054908 100644 --- a/app/Models/TicketResponse.php +++ b/app/Models/TicketResponse.php @@ -10,7 +10,7 @@ class TicketResponse extends Model use HasFactory; protected $fillable = [ - 'ticket_id', 'user_id', 'response', 'ip_address' + 'ticket_id', 'user_id', 'response', 'ip_address', ]; public function ticket() diff --git a/app/NotifyMe.php b/app/NotifyMe.php index d88596e..0b6fd45 100644 --- a/app/NotifyMe.php +++ b/app/NotifyMe.php @@ -2,18 +2,20 @@ namespace App; -use Log; -use Http; use Exception; +use Http; +use Log; trait NotifyMe { - function sendTelegramNotification($message) { + public function sendTelegramNotification($message) + { $botToken = config('app.notify_tg_bot_token'); $chatId = config('app.notify_tg_chat_id'); - if (!$botToken || !$chatId) { + if (! $botToken || ! $chatId) { Log::error('Telegram bot token or chat ID not configured'); + return false; } @@ -22,14 +24,16 @@ trait NotifyMe $data = [ 'chat_id' => $chatId, 'text' => $message, - 'parse_mode' => 'HTML' + 'parse_mode' => 'HTML', ]; try { $response = Http::post($url, $data); + return $response->successful(); } catch (Exception $e) { - Log::error('Failed to send Telegram notification: ' . $e->getMessage()); + Log::error('Failed to send Telegram notification: '.$e->getMessage()); + return false; } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 7887d04..5919bc4 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,11 +2,11 @@ namespace App\Providers; -use Exception; use App\Models\Blog; use App\Models\Menu; use App\Models\Plan; use DB; +use Exception; use Illuminate\Support\ServiceProvider; use Laravel\Cashier\Cashier; diff --git a/app/Providers/Filament/DashPanelProvider.php b/app/Providers/Filament/DashPanelProvider.php index 9bbd4b7..266bc34 100644 --- a/app/Providers/Filament/DashPanelProvider.php +++ b/app/Providers/Filament/DashPanelProvider.php @@ -2,12 +2,11 @@ namespace App\Providers\Filament; -use Filament\Pages\Dashboard; use Filament\Http\Middleware\Authenticate; use Filament\Http\Middleware\AuthenticateSession; use Filament\Http\Middleware\DisableBladeIconComponents; use Filament\Http\Middleware\DispatchServingFilamentEvent; -use Filament\Pages; +use Filament\Pages\Dashboard; use Filament\Panel; use Filament\PanelProvider; use Filament\Support\Colors\Color; @@ -39,8 +38,8 @@ class DashPanelProvider extends PanelProvider ]) ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') ->widgets([ - //Widgets\AccountWidget::class, - //Widgets\FilamentInfoWidget::class, + // Widgets\AccountWidget::class, + // Widgets\FilamentInfoWidget::class, ]) ->middleware([ EncryptCookies::class, diff --git a/cleanCron.php b/cleanCron.php index ffa763d..6b6a0ab 100644 --- a/cleanCron.php +++ b/cleanCron.php @@ -1,10 +1,10 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -20,5 +20,5 @@ try { echo "Output:\n$output"; } catch (\Exception $e) { - echo "Error running Artisan command: " . $e->getMessage(); + echo 'Error running Artisan command: '.$e->getMessage(); } diff --git a/closeTicket.php b/closeTicket.php index 34f00a9..1d07656 100644 --- a/closeTicket.php +++ b/closeTicket.php @@ -1,10 +1,10 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -20,5 +20,5 @@ try { echo "Output:\n$output"; } catch (\Exception $e) { - echo "Error running Artisan command: " . $e->getMessage(); + echo 'Error running Artisan command: '.$e->getMessage(); } diff --git a/config/debugbar.php b/config/debugbar.php index c6f8d77..a2add0d 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -38,14 +38,14 @@ return [ | Leaving it to null will allow localhost only. */ 'storage' => [ - 'enabled' => true, - 'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback. - 'driver' => 'file', // redis, file, pdo, socket, custom - 'path' => storage_path('debugbar'), // For file driver + 'enabled' => true, + 'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback. + 'driver' => 'file', // redis, file, pdo, socket, custom + 'path' => storage_path('debugbar'), // For file driver 'connection' => null, // Leave null for default connection (Redis/PDO) - 'provider' => '', // Instance of StorageInterface for custom driver - 'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver - 'port' => 2304, // Port to use with the "socket" driver + 'provider' => '', // Instance of StorageInterface for custom driver + 'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver + 'port' => 2304, // Port to use with the "socket" driver ], /* @@ -162,31 +162,31 @@ return [ */ 'collectors' => [ - 'phpinfo' => false, // Php version - 'messages' => true, // Messages - 'time' => true, // Time Datalogger - 'memory' => true, // Memory usage - 'exceptions' => true, // Exception displayer - 'log' => true, // Logs from Monolog (merged in messages if enabled) - 'db' => true, // Show database (PDO) queries and bindings - 'views' => true, // Views with their data - 'route' => false, // Current route information - 'auth' => false, // Display Laravel authentication status - 'gate' => true, // Display Laravel Gate checks - 'session' => false, // Display session data + 'phpinfo' => false, // Php version + 'messages' => true, // Messages + 'time' => true, // Time Datalogger + 'memory' => true, // Memory usage + 'exceptions' => true, // Exception displayer + 'log' => true, // Logs from Monolog (merged in messages if enabled) + 'db' => true, // Show database (PDO) queries and bindings + 'views' => true, // Views with their data + 'route' => false, // Current route information + 'auth' => false, // Display Laravel authentication status + 'gate' => true, // Display Laravel Gate checks + 'session' => false, // Display session data 'symfony_request' => true, // Only one can be enabled.. - 'mail' => true, // Catch mail messages - 'laravel' => true, // Laravel version and environment - 'events' => false, // All events fired + 'mail' => true, // Catch mail messages + 'laravel' => true, // Laravel version and environment + 'events' => false, // All events fired 'default_request' => false, // Regular or special Symfony request logger - 'logs' => false, // Add the latest log messages - 'files' => false, // Show the included files - 'config' => false, // Display config settings - 'cache' => false, // Display cache events - 'models' => true, // Display models - 'livewire' => true, // Display Livewire (when available) - 'jobs' => false, // Display dispatched jobs - 'pennant' => false, // Display Pennant feature flags + 'logs' => false, // Add the latest log messages + 'files' => false, // Show the included files + 'config' => false, // Display config settings + 'cache' => false, // Display cache events + 'models' => true, // Display models + 'livewire' => true, // Display Livewire (when available) + 'jobs' => false, // Display dispatched jobs + 'pennant' => false, // Display Pennant feature flags ], /* @@ -216,23 +216,23 @@ return [ 'show_guards' => true, // Show the guards that are used ], 'db' => [ - 'with_params' => true, // Render SQL with the parameters substituted - 'exclude_paths' => [ // Paths to exclude entirely from the collector -// 'vendor/laravel/framework/src/Illuminate/Session', // Exclude sessions queries + 'with_params' => true, // Render SQL with the parameters substituted + 'exclude_paths' => [ // Paths to exclude entirely from the collector + // 'vendor/laravel/framework/src/Illuminate/Session', // Exclude sessions queries ], - 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. + 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) - 'timeline' => false, // Add the queries to the timeline - 'duration_background' => true, // Show shaded background on each query relative to how long it took to execute. + 'timeline' => false, // Add the queries to the timeline + 'duration_background' => true, // Show shaded background on each query relative to how long it took to execute. 'explain' => [ // Show EXPLAIN output on queries 'enabled' => false, ], - 'hints' => false, // Show hints for common mistakes - 'show_copy' => true, // Show copy button next to the query, - 'slow_threshold' => false, // Only track queries that last longer than this time in ms - 'memory_usage' => false, // Show queries memory usage - 'soft_limit' => 100, // After the soft limit, no parameters/backtrace are captured - 'hard_limit' => 500, // After the hard limit, queries are ignored + 'hints' => false, // Show hints for common mistakes + 'show_copy' => true, // Show copy button next to the query, + 'slow_threshold' => false, // Only track queries that last longer than this time in ms + 'memory_usage' => false, // Show queries memory usage + 'soft_limit' => 100, // After the soft limit, no parameters/backtrace are captured + 'hard_limit' => 500, // After the hard limit, queries are ignored ], 'mail' => [ 'timeline' => true, // Add mails to the timeline @@ -243,7 +243,7 @@ return [ 'data' => false, // True for all data, 'keys' for only names, false for no parameters. 'group' => 50, // Group duplicate views. Pass value to auto-group, or true/false to force 'exclude_paths' => [ // Add the paths which you don't want to appear in the views - 'vendor/filament' // Exclude Filament components by default + 'vendor/filament', // Exclude Filament components by default ], ], 'route' => [ diff --git a/config/services.php b/config/services.php index e7b7363..a436509 100644 --- a/config/services.php +++ b/config/services.php @@ -37,6 +37,6 @@ return [ 'oxapay' => [ 'merchant_api_key' => env('OXAPAY_MERCHANT_API_KEY', ''), 'payout_api_key' => env('OXAPAY_PAYOUT_API_KEY', ''), - ] + ], ]; diff --git a/database/factories/MetaFactory.php b/database/factories/MetaFactory.php index af6ba1a..2e64ce9 100644 --- a/database/factories/MetaFactory.php +++ b/database/factories/MetaFactory.php @@ -16,4 +16,4 @@ class MetaFactory extends Factory 'value' => $this->faker->word(), ]; } -} \ No newline at end of file +} diff --git a/database/factories/RemoteEmailFactory.php b/database/factories/RemoteEmailFactory.php index 7c9df7e..f7d691a 100644 --- a/database/factories/RemoteEmailFactory.php +++ b/database/factories/RemoteEmailFactory.php @@ -17,10 +17,10 @@ class RemoteEmailFactory extends Factory 'from_name' => $this->faker->name(), 'from_email' => $this->faker->email(), 'to' => [$this->faker->email()], - 'body_html' => '

' . $this->faker->paragraph() . '

', + 'body_html' => '

'.$this->faker->paragraph().'

', 'body_text' => $this->faker->paragraph(), 'is_seen' => $this->faker->boolean(), 'timestamp' => $this->faker->dateTime(), ]; } -} \ No newline at end of file +} diff --git a/database/migrations/2025_06_20_172251_add_oxa_pay_details_to_plans_table.php b/database/migrations/2025_06_20_172251_add_oxa_pay_details_to_plans_table.php index 2acc022..8a06df7 100644 --- a/database/migrations/2025_06_20_172251_add_oxa_pay_details_to_plans_table.php +++ b/database/migrations/2025_06_20_172251_add_oxa_pay_details_to_plans_table.php @@ -13,7 +13,8 @@ return new class extends Migration { Schema::table('plans', function (Blueprint $table) { $table->string('oxapay_link')->nullable()->after('accept_shoppy'); - $table->boolean('accept_oxapay')->default(false)->after('oxapay_link');}); + $table->boolean('accept_oxapay')->default(false)->after('oxapay_link'); + }); } /** diff --git a/database/seeders/AdminSeeder.php b/database/seeders/AdminSeeder.php index 6aa6e78..48f5a02 100644 --- a/database/seeders/AdminSeeder.php +++ b/database/seeders/AdminSeeder.php @@ -3,7 +3,6 @@ namespace Database\Seeders; use App\Models\User; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Hash; diff --git a/database/seeders/MetaSeeder.php b/database/seeders/MetaSeeder.php index 7863f32..79b00b4 100644 --- a/database/seeders/MetaSeeder.php +++ b/database/seeders/MetaSeeder.php @@ -3,7 +3,6 @@ namespace Database\Seeders; use App\Models\Meta; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class MetaSeeder extends Seeder @@ -17,10 +16,10 @@ class MetaSeeder extends Seeder $metas->email_ids_created = 0; $metas->messages_received = 0; foreach ($metas as $key => $meta) { - if (!Meta::where('key', $key)->exists()) { + if (! Meta::where('key', $key)->exists()) { Meta::create([ 'key' => $key, - 'value' => $meta + 'value' => $meta, ]); } } diff --git a/database/seeders/UpdatePlansTableSeeder.php b/database/seeders/UpdatePlansTableSeeder.php index c39396c..3871e86 100644 --- a/database/seeders/UpdatePlansTableSeeder.php +++ b/database/seeders/UpdatePlansTableSeeder.php @@ -3,7 +3,6 @@ namespace Database\Seeders; use App\Models\Plan; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class UpdatePlansTableSeeder extends Seeder diff --git a/dropattach.php b/dropattach.php index bb8f51f..eed000a 100644 --- a/dropattach.php +++ b/dropattach.php @@ -1,11 +1,13 @@ diff --git a/dropattachP.php b/dropattachP.php index a5fbb0f..111da50 100644 --- a/dropattachP.php +++ b/dropattachP.php @@ -1,11 +1,13 @@ diff --git a/dropmail.php b/dropmail.php index 2adc3d4..5debbca 100644 --- a/dropmail.php +++ b/dropmail.php @@ -1,8 +1,9 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -24,23 +25,23 @@ $password = $imapDB['password']; $inbox = imap_open($hostname, $username, $password); // Check for connection errors -if (!$inbox) { - die('Could not connect to mailbox: ' . imap_last_error()); +if (! $inbox) { + exit('Could not connect to mailbox: '.imap_last_error()); } // Get current time in Unix timestamp $current_time = time(); // Search for messages older than one day -//$search_criteria = 'BEFORE "' . date('d-M-Y', strtotime('-3 hours', $current_time)) . '"'; -//$messages = imap_search($inbox, $search_criteria); +// $search_criteria = 'BEFORE "' . date('d-M-Y', strtotime('-3 hours', $current_time)) . '"'; +// $messages = imap_search($inbox, $search_criteria); $messages = imap_search($inbox, 'ALL'); $batch_size = 10; $deleted_count = 0; -//if ($messages) { +// if ($messages) { // $chunks = array_chunk($messages, $batch_size); // foreach ($chunks as $chunk) { // foreach ($chunk as $message_number) { @@ -50,9 +51,9 @@ $deleted_count = 0; // $deleted_count += count($chunk); // } // echo $deleted_count . ' messages older than specified time have been deleted.'; -//} else { +// } else { // echo 'No messages older than specified time found in mailbox.'; -//} +// } if ($messages) { $chunks = array_chunk($messages, $batch_size); @@ -71,7 +72,7 @@ if ($messages) { } imap_expunge($inbox); } - echo $deleted_count . ' messages older than 2 hours have been deleted.'; + echo $deleted_count.' messages older than 2 hours have been deleted.'; } else { echo 'No messages found in mailbox.'; } diff --git a/dropmailP.php b/dropmailP.php index 83d130d..29eaf3b 100644 --- a/dropmailP.php +++ b/dropmailP.php @@ -1,8 +1,9 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -24,15 +25,15 @@ $password = $imapDB['premium_password']; $inbox = imap_open($hostname, $username, $password); // Check for connection errors -if (!$inbox) { - die('Could not connect to mailbox: ' . imap_last_error()); +if (! $inbox) { + exit('Could not connect to mailbox: '.imap_last_error()); } // Get current time in Unix timestamp $current_time = time(); // Search for messages older than one day -$search_criteria = 'BEFORE "' . date('d-M-Y', strtotime('-3 hours', $current_time)) . '"'; +$search_criteria = 'BEFORE "'.date('d-M-Y', strtotime('-3 hours', $current_time)).'"'; $messages = imap_search($inbox, $search_criteria); $batch_size = 10; @@ -47,11 +48,10 @@ if ($messages) { imap_expunge($inbox); $deleted_count += count($chunk); } - echo $deleted_count . ' messages older than specified time have been deleted.'; + echo $deleted_count.' messages older than specified time have been deleted.'; } else { echo 'No messages older than specified time found in mailbox.'; } // Close mailbox connection imap_close($inbox); - diff --git a/inCron.php b/inCron.php index 138f564..1529b89 100644 --- a/inCron.php +++ b/inCron.php @@ -1,10 +1,10 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -20,5 +20,5 @@ try { echo "Output:\n$output"; } catch (\Exception $e) { - echo "Error running Artisan command: " . $e->getMessage(); + echo 'Error running Artisan command: '.$e->getMessage(); } diff --git a/indisposableCron.php b/indisposableCron.php index 357418f..8460b41 100644 --- a/indisposableCron.php +++ b/indisposableCron.php @@ -1,10 +1,10 @@ make(Illuminate\Contracts\Console\Kernel::class); @@ -20,5 +20,5 @@ try { echo "Output:\n$output"; } catch (\Exception $e) { - echo "Error running Artisan command: " . $e->getMessage(); + echo 'Error running Artisan command: '.$e->getMessage(); } diff --git a/routes/console.php b/routes/console.php index 335e1c0..cd16460 100644 --- a/routes/console.php +++ b/routes/console.php @@ -9,17 +9,17 @@ Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote'); -//Schedule::call(function () { +// Schedule::call(function () { // Email::fetchProcessStoreEmail(); -//})->everyMinute(); +// })->everyMinute(); Schedule::call(function () { Email::deleteBulkAttachments(); })->daily(); -//Schedule::call(function () { +// Schedule::call(function () { // Email::deleteBulkMailboxes(); -//})->everyMinute(); +// })->everyMinute(); Schedule::call(function () { Email::deleteMessagesFromDB(); @@ -30,13 +30,13 @@ Schedule::call(function () { })->everyThreeHours(); Schedule::call(function () { - Email::cleanMailbox(); + Email::cleanMailbox(); }); -Artisan::command('cleanMail', function (){ +Artisan::command('cleanMail', function () { $this->comment(Email::cleanMailbox()); }); -Artisan::command('closeTicket', function (){ - $this->comment(Ticket::autoClose()); +Artisan::command('closeTicket', function () { + $this->comment(Ticket::autoClose()); }); diff --git a/routes/web.php b/routes/web.php index edae491..da8ec3e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,7 +15,6 @@ use App\Livewire\Frontend\Mailbox; use App\Livewire\Home; use App\Livewire\ListBlog; use App\Livewire\Page; - use App\Livewire\Settings\Appearance; use App\Livewire\Settings\Password; use App\Livewire\Settings\Profile; @@ -45,6 +44,7 @@ Route::post('/sync', function (Request $request) { } catch (\Exception $e) { \Log::error($e->getMessage()); } + return response()->noContent(); }); @@ -75,13 +75,13 @@ Route::middleware(['auth', 'verified', CheckUserBanned::class])->group(function if (in_array($pricing_id, $pricingData)) { return auth()->user() - ->newSubscription('default', $pricing_id) - ->allowPromotionCodes() - ->checkout([ - 'billing_address_collection' => 'required', - 'success_url' => route('checkout.success'), - 'cancel_url' => route('checkout.cancel'), - ]); + ->newSubscription('default', $pricing_id) + ->allowPromotionCodes() + ->checkout([ + 'billing_address_collection' => 'required', + 'success_url' => route('checkout.success'), + 'cancel_url' => route('checkout.cancel'), + ]); } abort(404); @@ -98,7 +98,7 @@ Route::middleware(['auth', 'verified', CheckUserBanned::class])->group(function $validUser = 'admin'; $validPass = 'admin@9608'; // 🔐 Change this to something secure - if (!isset($_SERVER['PHP_AUTH_USER']) || + if (! isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $validUser || $_SERVER['PHP_AUTH_PW'] !== $validPass) { @@ -119,7 +119,7 @@ Route::middleware(['auth', 'verified', CheckUserBanned::class])->group(function $validUser = 'admin'; $validPass = 'admin@9608'; // 🔐 Change this to something secure - if (!isset($_SERVER['PHP_AUTH_USER']) || + if (! isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $validUser || $_SERVER['PHP_AUTH_PW'] !== $validPass) { diff --git a/tests/Concerns/LoadsApplicationData.php b/tests/Concerns/LoadsApplicationData.php index 8beb290..db6af61 100644 --- a/tests/Concerns/LoadsApplicationData.php +++ b/tests/Concerns/LoadsApplicationData.php @@ -79,13 +79,13 @@ trait LoadsApplicationData } // Ensure we always have collections, even if cache is empty - if (!($menus instanceof \Illuminate\Support\Collection)) { + if (! ($menus instanceof \Illuminate\Support\Collection)) { $menus = collect(); } - if (!($blogs instanceof \Illuminate\Support\Collection)) { + if (! ($blogs instanceof \Illuminate\Support\Collection)) { $blogs = collect(); } - if (!($plans instanceof \Illuminate\Support\Collection)) { + if (! ($plans instanceof \Illuminate\Support\Collection)) { $plans = collect(); } diff --git a/tests/Feature/Controllers/WebhookControllerTest.php b/tests/Feature/Controllers/WebhookControllerTest.php index d767d69..e820cbe 100644 --- a/tests/Feature/Controllers/WebhookControllerTest.php +++ b/tests/Feature/Controllers/WebhookControllerTest.php @@ -2,7 +2,6 @@ namespace Tests\Feature\Controllers; -use App\Http\Controllers\WebhookController; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; @@ -263,7 +262,6 @@ class WebhookControllerTest extends TestCase 'email' => 'test@example.com', ]; - $response = $this->postJson('/webhook/oxapay', $invalidData); $response->assertStatus(400); @@ -284,7 +282,6 @@ class WebhookControllerTest extends TestCase $validHmac = hash_hmac('sha512', $postData, $apiSecretKey); $invalidHmac = 'invalid_hmac'; - $response = $this->postJson('/webhook/oxapay', $validData, [ 'HMAC' => $invalidHmac, ]); @@ -349,7 +346,6 @@ class WebhookControllerTest extends TestCase $invoicePostData = json_encode($invoiceData); $invoiceHmac = hash_hmac('sha512', $invoicePostData, 'test_merchant_key'); - $response = $this->postJson('/webhook/oxapay', $invoiceData, [ 'HMAC' => $invoiceHmac, ]); @@ -387,4 +383,4 @@ class WebhookControllerTest extends TestCase $response->assertStatus(200); } -} \ No newline at end of file +} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 636a54c..8c7b79c 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -2,8 +2,8 @@ namespace Tests\Feature; -use Tests\TestCase; use Tests\Concerns\LoadsApplicationData; +use Tests\TestCase; class ExampleTest extends TestCase { diff --git a/tests/Feature/Filament/ResourcesTest.php b/tests/Feature/Filament/ResourcesTest.php index 4a85211..ecebc2e 100644 --- a/tests/Feature/Filament/ResourcesTest.php +++ b/tests/Feature/Filament/ResourcesTest.php @@ -2,11 +2,8 @@ namespace Tests\Feature\Filament; -use App\Filament\Resources\BlogResource; use App\Filament\Resources\BlogResource\Pages\CreateBlog; -use App\Filament\Resources\PlanResource; use App\Filament\Resources\PlanResource\Pages\CreatePlan; -use App\Filament\Resources\TicketResource; use App\Filament\Resources\TicketResource\Pages\CreateTicket; use App\Models\Blog; use App\Models\Category; @@ -17,8 +14,8 @@ use App\Models\Ticket; use App\Models\TicketResponse; use App\Models\User; use Filament\Facades\Filament; -use Tests\TestCase; use Livewire\Livewire; +use Tests\TestCase; class ResourcesTest extends TestCase { @@ -693,7 +690,6 @@ class ResourcesTest extends TestCase ->assertHasFormErrors(['name', 'url']); } - /** @test */ public function it_can_delete_menu_item() { @@ -716,7 +712,6 @@ class ResourcesTest extends TestCase ->assertCanSeeTableRecords([$menu2, $menu1], inOrder: true); } - /** @test */ public function it_can_handle_parent_child_relationships() { @@ -859,4 +854,4 @@ class ResourcesTest extends TestCase ->sortTable('name') ->assertSuccessful(); } -} \ No newline at end of file +} diff --git a/tests/Feature/Filament/UserResourceTest.php b/tests/Feature/Filament/UserResourceTest.php index 1179da7..7d8aba7 100644 --- a/tests/Feature/Filament/UserResourceTest.php +++ b/tests/Feature/Filament/UserResourceTest.php @@ -7,12 +7,10 @@ use App\Filament\Resources\UserResource\Pages\CreateUser; use App\Filament\Resources\UserResource\Pages\EditUser; use App\Filament\Resources\UserResource\Pages\ListUsers; use App\Models\Log; -use App\Models\UsageLog; use App\Models\User; use Filament\Facades\Filament; -use Illuminate\Support\Facades\Notification; -use Tests\TestCase; use Livewire\Livewire; +use Tests\TestCase; class UserResourceTest extends TestCase { @@ -306,8 +304,6 @@ class UserResourceTest extends TestCase ->assertTableBulkActionExists('updateLevel'); } - - /** @test */ public function it_searches_across_multiple_fields() { @@ -342,4 +338,4 @@ class UserResourceTest extends TestCase { $this->assertEquals(User::class, UserResource::getModel()); } -} \ No newline at end of file +} diff --git a/tests/Feature/Livewire/Auth/LoginTest.php b/tests/Feature/Livewire/Auth/LoginTest.php index d1a6760..c5887af 100644 --- a/tests/Feature/Livewire/Auth/LoginTest.php +++ b/tests/Feature/Livewire/Auth/LoginTest.php @@ -91,7 +91,7 @@ class LoginTest extends TestCase public function it_handles_rate_limiting() { // Clear any existing rate limit attempts - RateLimiter::clear('login:' . request()->ip()); + RateLimiter::clear('login:'.request()->ip()); // Exceed the rate limit (5 attempts by default) for ($i = 0; $i < 6; $i++) { @@ -124,7 +124,7 @@ class LoginTest extends TestCase public function it_handles_lockout_event() { // Clear any existing rate limit attempts - RateLimiter::clear('login:' . request()->ip()); + RateLimiter::clear('login:'.request()->ip()); // Exceed the rate limit to trigger lockout for ($i = 0; $i < 6; $i++) { @@ -170,4 +170,4 @@ class LoginTest extends TestCase $this->assertAuthenticatedAs($this->user); } -} \ No newline at end of file +} diff --git a/tests/Feature/Livewire/Auth/RegisterTest.php b/tests/Feature/Livewire/Auth/RegisterTest.php index ce1e3f9..2bec483 100644 --- a/tests/Feature/Livewire/Auth/RegisterTest.php +++ b/tests/Feature/Livewire/Auth/RegisterTest.php @@ -205,4 +205,4 @@ class RegisterTest extends TestCase ->call('register') ->assertHasErrors(['password']); } -} \ No newline at end of file +} diff --git a/tests/Feature/Livewire/DashboardTest.php b/tests/Feature/Livewire/DashboardTest.php index 5ca6942..58e21c2 100644 --- a/tests/Feature/Livewire/DashboardTest.php +++ b/tests/Feature/Livewire/DashboardTest.php @@ -58,4 +58,4 @@ class DashboardTest extends TestCase $component->assertSee('Purchase Subscription'); $component->assertSee('Have an Activation Key?'); } -} \ No newline at end of file +} diff --git a/tests/Feature/Livewire/FrontendTest.php b/tests/Feature/Livewire/FrontendTest.php index fadd112..acdca9e 100644 --- a/tests/Feature/Livewire/FrontendTest.php +++ b/tests/Feature/Livewire/FrontendTest.php @@ -93,4 +93,4 @@ class FrontendTest extends TestCase $component->assertStatus(200); } -} \ No newline at end of file +} diff --git a/tests/Unit/ColorPickerTest.php b/tests/Unit/ColorPickerTest.php index 50f685d..38fd4db 100644 --- a/tests/Unit/ColorPickerTest.php +++ b/tests/Unit/ColorPickerTest.php @@ -231,4 +231,4 @@ class ColorPickerTest extends TestCase $this->assertEquals($staticResult, $instanceResult); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/ActivationKeyTest.php b/tests/Unit/Models/ActivationKeyTest.php index d9ad3a5..e38be9c 100644 --- a/tests/Unit/Models/ActivationKeyTest.php +++ b/tests/Unit/Models/ActivationKeyTest.php @@ -72,4 +72,4 @@ class ActivationKeyTest extends TestCase $this->assertCount(1, $unactivatedKeys); $this->assertCount(1, $activatedKeys); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/BlogTest.php b/tests/Unit/Models/BlogTest.php index a625b45..9bcd15a 100644 --- a/tests/Unit/Models/BlogTest.php +++ b/tests/Unit/Models/BlogTest.php @@ -153,4 +153,4 @@ class BlogTest extends TestCase $this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $blog); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/CategoryTest.php b/tests/Unit/Models/CategoryTest.php index 9575bb5..5559a29 100644 --- a/tests/Unit/Models/CategoryTest.php +++ b/tests/Unit/Models/CategoryTest.php @@ -91,4 +91,4 @@ class CategoryTest extends TestCase $this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $category); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/EmailTest.php b/tests/Unit/Models/EmailTest.php index 7b2cdd3..b01774d 100644 --- a/tests/Unit/Models/EmailTest.php +++ b/tests/Unit/Models/EmailTest.php @@ -3,10 +3,8 @@ namespace Tests\Unit\Models; use App\Models\Email; -use App\Models\RemoteEmail; use Carbon\Carbon; use Illuminate\Support\Facades\Config; -use Illuminate\Support\Facades\File; use Tests\TestCase; class EmailTest extends TestCase @@ -91,7 +89,7 @@ class EmailTest extends TestCase } /** @test */ - public function it_validates_email_format_in_fetchEmailFromDB() + public function it_validates_email_format_in_fetch_email_from_db() { $result = Email::fetchEmailFromDB('invalid-email'); @@ -114,7 +112,7 @@ class EmailTest extends TestCase } /** @test */ - public function it_orders_emails_by_timestamp_descending_in_fetchEmailFromDB() + public function it_orders_emails_by_timestamp_descending_in_fetch_email_from_db() { $oldEmail = Email::factory()->create([ 'to' => ['test@example.com'], @@ -138,4 +136,4 @@ class EmailTest extends TestCase $this->assertEquals('emails', $email->getTable()); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/LogTest.php b/tests/Unit/Models/LogTest.php index 4bb831d..52b59b0 100644 --- a/tests/Unit/Models/LogTest.php +++ b/tests/Unit/Models/LogTest.php @@ -72,4 +72,4 @@ class LogTest extends TestCase $this->assertEquals($newLog->id, $logs->first()->id); $this->assertEquals($oldLog->id, $logs->last()->id); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/MenuTest.php b/tests/Unit/Models/MenuTest.php index e521217..f5490b1 100644 --- a/tests/Unit/Models/MenuTest.php +++ b/tests/Unit/Models/MenuTest.php @@ -56,4 +56,4 @@ class MenuTest extends TestCase $this->assertEquals('home', $childMenu->parent); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/MessageTest.php b/tests/Unit/Models/MessageTest.php index ee42b44..2c81597 100644 --- a/tests/Unit/Models/MessageTest.php +++ b/tests/Unit/Models/MessageTest.php @@ -68,4 +68,4 @@ class MessageTest extends TestCase $this->assertCount(1, $unseenMessages); $this->assertCount(1, $seenMessages); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/MetaTest.php b/tests/Unit/Models/MetaTest.php index 4a78bc0..aaaba2b 100644 --- a/tests/Unit/Models/MetaTest.php +++ b/tests/Unit/Models/MetaTest.php @@ -56,4 +56,4 @@ class MetaTest extends TestCase $this->assertEquals('ZEmailnator', $siteName->value); $this->assertEquals('100', $maxEmails->value); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/PageTest.php b/tests/Unit/Models/PageTest.php index 6314121..9a2291b 100644 --- a/tests/Unit/Models/PageTest.php +++ b/tests/Unit/Models/PageTest.php @@ -59,4 +59,4 @@ class PageTest extends TestCase $this->assertCount(1, $publishedPages); $this->assertCount(1, $draftPages); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/PlanTest.php b/tests/Unit/Models/PlanTest.php index 48d6800..39a8327 100644 --- a/tests/Unit/Models/PlanTest.php +++ b/tests/Unit/Models/PlanTest.php @@ -147,4 +147,4 @@ class PlanTest extends TestCase $this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $plan); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/PremiumEmailTest.php b/tests/Unit/Models/PremiumEmailTest.php index 472aa3c..ab117eb 100644 --- a/tests/Unit/Models/PremiumEmailTest.php +++ b/tests/Unit/Models/PremiumEmailTest.php @@ -76,4 +76,4 @@ class PremiumEmailTest extends TestCase $this->assertCount(1, $seenEmails); $this->assertCount(1, $unseenEmails); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/RemoteEmailTest.php b/tests/Unit/Models/RemoteEmailTest.php index bd8b4f1..440a1af 100644 --- a/tests/Unit/Models/RemoteEmailTest.php +++ b/tests/Unit/Models/RemoteEmailTest.php @@ -65,4 +65,4 @@ class RemoteEmailTest extends TestCase $this->assertInstanceOf(Carbon::class, $remoteEmail->timestamp); $this->assertEquals($timestamp->format('Y-m-d H:i:s'), $remoteEmail->timestamp->format('Y-m-d H:i:s')); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/SettingTest.php b/tests/Unit/Models/SettingTest.php index 40a3118..db9e01b 100644 --- a/tests/Unit/Models/SettingTest.php +++ b/tests/Unit/Models/SettingTest.php @@ -64,4 +64,4 @@ class SettingTest extends TestCase $this->assertCount(2, $allSettings); $this->assertIsString($allSettings->first()->app_name); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/TicketResponseTest.php b/tests/Unit/Models/TicketResponseTest.php index dae82d0..4ddfaae 100644 --- a/tests/Unit/Models/TicketResponseTest.php +++ b/tests/Unit/Models/TicketResponseTest.php @@ -135,4 +135,4 @@ class TicketResponseTest extends TestCase $this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $response); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/TicketTest.php b/tests/Unit/Models/TicketTest.php index 84a36d8..9427856 100644 --- a/tests/Unit/Models/TicketTest.php +++ b/tests/Unit/Models/TicketTest.php @@ -97,4 +97,4 @@ class TicketTest extends TestCase $this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $ticket); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/UsageLogTest.php b/tests/Unit/Models/UsageLogTest.php index 5588ea5..f08514f 100644 --- a/tests/Unit/Models/UsageLogTest.php +++ b/tests/Unit/Models/UsageLogTest.php @@ -64,4 +64,4 @@ class UsageLogTest extends TestCase $this->assertEquals(15, $usageLog->emails_created_count); $this->assertEquals(25, $usageLog->emails_received_count); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/UserTest.php b/tests/Unit/Models/UserTest.php index 584ba0c..ae69ef5 100644 --- a/tests/Unit/Models/UserTest.php +++ b/tests/Unit/Models/UserTest.php @@ -214,4 +214,4 @@ class UserTest extends TestCase $this->assertCount(0, $this->user->fresh()->tokens); } -} \ No newline at end of file +} diff --git a/tests/Unit/Models/ZEmailTest.php b/tests/Unit/Models/ZEmailTest.php index 6585430..3005a54 100644 --- a/tests/Unit/Models/ZEmailTest.php +++ b/tests/Unit/Models/ZEmailTest.php @@ -343,4 +343,4 @@ class ZEmailTest extends TestCase $this->assertEquals('', $result); } -} \ No newline at end of file +} diff --git a/tests/Unit/NotifyMeTest.php b/tests/Unit/NotifyMeTest.php index c7b71ed..9f17290 100644 --- a/tests/Unit/NotifyMeTest.php +++ b/tests/Unit/NotifyMeTest.php @@ -157,4 +157,4 @@ class NotifyMeTest extends TestCase $this->assertTrue($result); } -} \ No newline at end of file +}