Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

monicahq/monica

23656 stars
2 code files
View monicahq/monica on GitHub

app/Console/Commands/Clean.php

Open in GitHub
use App\Models\User\SyncToken;
use Illuminate\Console\Command;
use App\Events\TokenDeleteEvent;
use App\Services\Instance\TokenClean;
use Illuminate\Support\Facades\Event;
 
class Clean extends Command
{
protected $signature = 'monica:clean
{--dry-run : Do everything except actually clean monica instance.}';
 
protected $description = 'Clean monica instance';
 
public function handle(): void
{
Event::listen(TokenDeleteEvent::class, function ($event) {
$this->handleTokenDelete($event->token);
});
 
app(TokenClean::class)->execute([
'dryrun' => (bool) $this->option('dry-run'),
]);
}
 
private function handleTokenDelete($token)
{
$this->info('Delete token '.$token->id.' - User '.$token->user_id.' - Type '.$token->name.' - timestamp '.$token->timestamp);
}
}

app/Console/Kernel.php

Open in GitHub
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
class Kernel extends ConsoleKernel
{
//
protected function schedule(Schedule $schedule)
{
//
$this->scheduleCommand($schedule, 'monica:clean', 'daily');
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.