<?php

namespace Modules\Setting\Repositories;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Modules\Setting\Interfaces\SettingRepositoryInterface;
use Modules\Setting\Models\Setting;
use Modules\User\Models\Module;

class SettingRepository implements SettingRepositoryInterface
{

    public function get(array $request)
    {
        $settings = Setting::cursor();
        return $settings;
    }
    public function getAll()
    {
        $settings = Setting::get()->toArray();
        return $settings;
    }

    public function getItem(Setting $setting)
    {
        return $setting ;
    }

    public function getItemByKey($key)
    {
        return Setting::where('key', $key)->first();
    }

    //
    public function save(array $request):void
    {
        Setting::where('key', $request['key'])->update([
            'value' => $request['value'],
        ]);
    }
}
