Skip to content

Commit

Permalink
Auto sync
Browse files Browse the repository at this point in the history
  • Loading branch information
toyi committed Dec 4, 2022
1 parent 7484bb7 commit a9df336
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config/sync-database.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php return [

'auto' => [
'enabled' => env('SYNC_AUTO', false),
'at' => env('SYNC_AUTO_AT', '06:10')
],
# Remote server configuration
'ssh' => [
'host' => env('SYNC_SSH_HOST'),
Expand Down
11 changes: 11 additions & 0 deletions src/SyncDatabaseProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace Toyi\SyncDatabase;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;

class SyncDatabaseProvider extends ServiceProvider
Expand All @@ -18,4 +20,13 @@ public function register()
__DIR__ . '/../config/sync-database.php' => $this->app->basePath() . '/config/sync-database.php',
]);
}

public function boot()
{
$this->app->booted(function () {
if (Config::get('sync-database.auto.enabled')) {
$this->app->make(Schedule::class)->command(SyncDatabaseCommand::class)->dailyAt(Config::get('sync-database.auto.at'));
}
});
}
}

0 comments on commit a9df336

Please sign in to comment.