<?php

namespace App\Services;

use App\Models\Client;
use App\Models\Stats;
use App\Models\Visits;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class AppDataResetService
{
    public function reset(): void
    {
        DB::transaction(function () {
            Schema::disableForeignKeyConstraints();
            Client::truncate();
            Visits::truncate();
            Schema::enableForeignKeyConstraints();

            Stats::query()->delete();
            Stats::create([
                'click' => 0,
                'client' => 0,
                'bot' => 0,
                'card' => 0,
            ]);
        });
    }
}
