uawdijnntqw1x1x1
IP : 216.73.216.130
Hostname : it-staging-server
Kernel : Linux it-staging-server 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
forge
/
stage.herta-bht.smartcon-survey.com
/
app
/
Filament
/
Actions
/
LoadDataAction.php
/
/
<?php namespace App\Filament\Actions; use App\Imports\InterviewImporter; use App\Models\Country; use App\Models\DataAggregation; use App\Models\DataUpload; use App\Services\ExternalDataService; use Filament\Actions; use Filament\Forms; use Filament\Notifications\Notification; use RuntimeException; class LoadDataAction { public static function get(): Actions\Action { return Actions\Action::make('load_new_interviews') ->label('Upload new interviews') ->icon('heroicon-o-cloud-arrow-down') ->form(self::modalForm()) ->action(fn ($data) => self::modalAction($data)); } private static function modalForm(): array { return [ Forms\Components\Select::make('country_id') ->label('Country') ->options(Country::pluck('name', 'id')) ->reactive() ->required(), Forms\Components\Select::make('wave') ->options(fn ($get) => ExternalDataService::getWaves($get('country_id'))) ->visible(fn ($get) => $get('country_id')) ->disableOptionWhen(fn ($value): bool => $value < 0) ->required(), ]; } private static function modalAction(array $data): void { ini_set('memory_limit', '2048M'); ini_set('max_execution_time', '300'); if ($data['country_id'] === null || $data['wave'] === null) { Notification::make('error') ->title('Error')->body('You must select a country and wave') ->danger()->send(); return; } $country = Country::find($data['country_id']); if ($country === null) { Notification::make('error') ->title('Error')->body('Country not found') ->danger()->send(); return; } try { InterviewImporter::import($country, $data['wave']); } catch (RuntimeException $e) { Notification::make('error') ->title('Error')->body($e->getMessage()) ->danger()->send(); return; } $dataUpload = DataUpload::where('country_id', $country->id) ->with('country') ->where('wave', $data['wave']) ->first(); // Aggregate the interviews to improve the performance of the dashboard // and avoid long loading times DataAggregation::aggregateInterviews(); Notification::make('success') ->title("The {$dataUpload->country->name} interviews wave $dataUpload->wave uploaded") ->body($dataUpload->interviews_count.' interviews uploaded successfully.') ->success()->duration(6000)->send(); } }
/home/forge/stage.herta-bht.smartcon-survey.com/app/Filament/Actions/LoadDataAction.php