<?php

namespace App\Http\Controllers\SyS;

use App\Http\Controllers\Controller;
use App\Models\SySetting;
use Request;


class SettingController extends Controller
{
    protected $userRepo;

    public function __construct()
    {
        $this->middleware('sysadmin');

    }

    public function index()
    {

        $data = [
            'values' => SySetting::all(),
        ];
        return view('sys.settings.index', $data);
    }

    public function store()
    {

        $data = Request::all();

        $data['active'] =  isset($data['active']) ? true : false;
        if($data['id'] === "new"){
            $model = SySetting::create($data);
        }else{
            $model = SySetting::find($data['id']);
            $model->fill($data);
            $model->save();
        }


        \Session()->flash('alert-save', '1');
        return redirect(route('sysadmin_settings'));

    }


}