2024-11-14 00:15:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-12-08 19:57:00 +01:00
|
|
|
namespace App\Livewire\Installer\Steps;
|
2024-11-14 00:15:48 +01:00
|
|
|
|
2026-01-27 11:36:07 +01:00
|
|
|
use App\Enums\TablerIcon;
|
2024-12-08 19:57:00 +01:00
|
|
|
use App\Livewire\Installer\PanelInstaller;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Exception;
|
2024-11-14 00:15:48 +01:00
|
|
|
use Filament\Forms\Components\TextInput;
|
|
|
|
|
use Filament\Forms\Components\Toggle;
|
|
|
|
|
use Filament\Forms\Components\ToggleButtons;
|
2025-09-08 13:12:33 -04:00
|
|
|
use Filament\Schemas\Components\Utilities\Get;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Filament\Schemas\Components\Wizard\Step;
|
2024-11-14 00:15:48 +01:00
|
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
|
|
|
|
|
|
class QueueStep
|
|
|
|
|
{
|
|
|
|
|
public const QUEUE_DRIVERS = [
|
|
|
|
|
'database' => 'Database',
|
|
|
|
|
'redis' => 'Redis',
|
|
|
|
|
'sync' => 'Sync',
|
|
|
|
|
];
|
|
|
|
|
|
2025-09-08 13:12:33 -04:00
|
|
|
/**
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
2024-11-14 00:15:48 +01:00
|
|
|
public static function make(PanelInstaller $installer): Step
|
|
|
|
|
{
|
|
|
|
|
return Step::make('queue')
|
2025-09-04 20:17:59 +02:00
|
|
|
->label(trans('installer.queue.title'))
|
2024-11-14 00:15:48 +01:00
|
|
|
->columns()
|
|
|
|
|
->schema([
|
|
|
|
|
ToggleButtons::make('env_queue.QUEUE_CONNECTION')
|
2025-09-04 20:17:59 +02:00
|
|
|
->label(trans('installer.queue.driver'))
|
2026-01-27 11:36:07 +01:00
|
|
|
->hintIcon(TablerIcon::QuestionMark, trans('installer.queue.driver_help'))
|
2024-11-14 00:15:48 +01:00
|
|
|
->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')
|
2025-09-04 20:17:59 +02:00
|
|
|
->label(trans('installer.queue.fields.done'))
|
2025-03-15 19:28:59 +01:00
|
|
|
->accepted(fn () => !@file_exists('/.dockerenv'))
|
2024-11-14 00:15:48 +01:00
|
|
|
->inline(false)
|
|
|
|
|
->validationMessages([
|
2025-09-04 20:17:59 +02:00
|
|
|
'accepted' => trans('installer.queue.fields.done_validation'),
|
2024-11-14 00:15:48 +01:00
|
|
|
])
|
2025-03-15 19:28:59 +01:00
|
|
|
->hidden(fn () => @file_exists('/.dockerenv')),
|
2024-11-14 00:15:48 +01:00
|
|
|
TextInput::make('crontab')
|
2025-09-04 20:17:59 +02:00
|
|
|
->label(new HtmlString(trans('installer.queue.fields.crontab')))
|
2024-11-14 00:15:48 +01:00
|
|
|
->disabled()
|
2025-09-08 13:12:33 -04:00
|
|
|
->hintCopy()
|
2025-10-03 00:03:22 +02:00
|
|
|
->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 -')
|
2025-03-15 19:28:59 +01:00
|
|
|
->hidden(fn () => @file_exists('/.dockerenv'))
|
2024-11-14 00:15:48 +01:00
|
|
|
->columnSpanFull(),
|
|
|
|
|
TextInput::make('queueService')
|
2025-09-04 20:17:59 +02:00
|
|
|
->label(new HtmlString(trans('installer.queue.fields.service')))
|
2024-11-14 00:15:48 +01:00
|
|
|
->disabled()
|
2025-09-08 13:12:33 -04:00
|
|
|
->hintCopy()
|
2024-11-14 00:15:48 +01:00
|
|
|
->default('sudo php ' . base_path() . '/artisan p:environment:queue-service')
|
2025-03-15 19:28:59 +01:00
|
|
|
->hidden(fn () => @file_exists('/.dockerenv'))
|
2024-11-14 00:15:48 +01:00
|
|
|
->columnSpanFull(),
|
|
|
|
|
])
|
2024-12-01 04:04:40 +01:00
|
|
|
->afterValidation(fn () => $installer->writeToEnv('env_queue'));
|
2024-11-14 00:15:48 +01:00
|
|
|
}
|
|
|
|
|
}
|