mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 08:06:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			65 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Livewire\Installer\Steps;
 | |
| 
 | |
| use App\Livewire\Installer\PanelInstaller;
 | |
| use Exception;
 | |
| use Filament\Forms\Components\TextInput;
 | |
| use Filament\Forms\Components\Toggle;
 | |
| use Filament\Forms\Components\ToggleButtons;
 | |
| use Filament\Schemas\Components\Utilities\Get;
 | |
| use Filament\Schemas\Components\Wizard\Step;
 | |
| use Illuminate\Support\HtmlString;
 | |
| 
 | |
| class QueueStep
 | |
| {
 | |
|     public const QUEUE_DRIVERS = [
 | |
|         'database' => 'Database',
 | |
|         'redis' => 'Redis',
 | |
|         'sync' => 'Sync',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * @throws Exception
 | |
|      */
 | |
|     public static function make(PanelInstaller $installer): Step
 | |
|     {
 | |
|         return Step::make('queue')
 | |
|             ->label(trans('installer.queue.title'))
 | |
|             ->columns()
 | |
|             ->schema([
 | |
|                 ToggleButtons::make('env_queue.QUEUE_CONNECTION')
 | |
|                     ->label(trans('installer.queue.driver'))
 | |
|                     ->hintIcon('tabler-question-mark', trans('installer.queue.driver_help'))
 | |
|                     ->required()
 | |
|                     ->inline()
 | |
|                     ->options(self::QUEUE_DRIVERS)
 | |
|                     ->disableOptionWhen(fn ($value, Get $get) => $value === 'redis' && $get('env_cache.CACHE_STORE') !== 'redis')
 | |
|                     ->default(config('queue.default')),
 | |
|                 Toggle::make('done')
 | |
|                     ->label(trans('installer.queue.fields.done'))
 | |
|                     ->accepted(fn () => !@file_exists('/.dockerenv'))
 | |
|                     ->inline(false)
 | |
|                     ->validationMessages([
 | |
|                         'accepted' => trans('installer.queue.fields.done_validation'),
 | |
|                     ])
 | |
|                     ->hidden(fn () => @file_exists('/.dockerenv')),
 | |
|                 TextInput::make('crontab')
 | |
|                     ->label(new HtmlString(trans('installer.queue.fields.crontab')))
 | |
|                     ->disabled()
 | |
|                     ->hintCopy()
 | |
|                     ->default('(sudo crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | sudo crontab -u www-data -')
 | |
|                     ->hidden(fn () => @file_exists('/.dockerenv'))
 | |
|                     ->columnSpanFull(),
 | |
|                 TextInput::make('queueService')
 | |
|                     ->label(new HtmlString(trans('installer.queue.fields.service')))
 | |
|                     ->disabled()
 | |
|                     ->hintCopy()
 | |
|                     ->default('sudo php ' . base_path() . '/artisan p:environment:queue-service')
 | |
|                     ->hidden(fn () => @file_exists('/.dockerenv'))
 | |
|                     ->columnSpanFull(),
 | |
|             ])
 | |
|             ->afterValidation(fn () => $installer->writeToEnv('env_queue'));
 | |
|     }
 | |
| }
 | 
