<?php

namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Ingredient;
use App\Models\IqImage;
use App\Models\ProductCategory;
use App\Models\ProductIngredient;
use App\Models\Setting;
use Request;


class SettingController extends Controller
{


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

    public function index()
    {

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


    public function store()
    {

        $data = Request::all();

        if(isset($data['action'])){
            if(isset($data['settings'])){
                foreach ($data['settings'] as $key=>$value){
                    Setting::setContentBySlug($key, $value['val'], $value['type']);
                }
            }
        }
        \Session()->flash('alert-save', '1');
        return redirect(route('admin_settings'));


    }




}