laravellaravel-backup

Do I need / can I run laravel backups froma controller?


Here's a bit of context:

Anyway could someone kindly lead the way to a solution, for this, as I guess it's not such an unusual use case ...?

Many thanks,

JMB


Solution

  • If I understand correctly, when the admin changes the Backup-related setting, you also want to change the scheduling cron. It is possible to do this from the controller. You can set a scheduling in Controller:

    Illuminate\Console\Scheduling\Schedule;
    
        protected function schedule(Schedule $schedule): void
        {
            switch ($adminChoice) {
            case 'daily':
                $schedule->command('backup:run')->daily();
                break;
            case 'weekly':
                $schedule->command('backup:run')->weekly();
                break;
           }
        }