<?php

namespace App\Support;

use App\Models\PermanentEmployeeSalaryPayment;
use Illuminate\Support\Facades\DB;

class ClearSalaryPayments
{
    /**
     * Delete all permanent employee monthly salary payment rows (draft and paid).
     *
     * @return array{payments: int}
     */
    public static function run(): array
    {
        return DB::transaction(function (): array {
            $count = PermanentEmployeeSalaryPayment::query()->count();

            PermanentEmployeeSalaryPayment::query()->delete();

            return ['payments' => $count];
        });
    }
}
