<?php

namespace App\Repository;

use App\Settings;
use Carbon\Carbon;

class Setting {

    CONST CACHE_KEY = 'SETTINGS';

    public function all($code) {
        $key = "all.{$code}";
        $cacheKey = $this->getCacheKey($key);
        return cache()->remember($cacheKey, Carbon::now()->addMinutes(10), function() use($code) {
                    return Settings::where('code', $code)->first();
                });
    }

    public function get($id) {
        
    }

    public function getCacheKey($key) {
        $key = strtoupper($key);

        return self::CACHE_KEY . $key;
    }

}
