<?php

namespace App\Service\Setting;

use App\Models\Setting;

class GeneralSetting
{
    public static function SettingSore(array $data)
    {
        $prepard = collect($data);
        if ($prepard['colmun'] == 'purchase_to_shop_warehoue') {
            $col = 'purchase_to_warehoue';
        } else {
            $col = 'purchase_to_shop_warehoue';
        }
        $setting = Setting::first();
        if ($setting) {
            Setting::where('id', $setting->id)->update([
                $prepard['colmun'] => $prepard['status'],
                $col => true,
            ]);
        } else {
            Setting::create([
                $prepard['colmun'] => $prepard['status'],
                $col => true,
            ]);
        }
    }
}
