<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Auth;
use App\Models\Settings;

class AppController extends BaseController
{
    public $siteSettings ;
    public function __construct()
    {
        $settings = Settings::get()->keyBy('key');
        $siteSettings[] = $settings->map(function($settings, $key) {									
            return $siteSettings[] = $settings->value;
            });
        $this->siteSettings = $siteSettings[0];
    }
    /*Language Translation*/
    public function lang($locale)
    {
        if ($locale) {
            App::setLocale($locale);
            Session::put('lang', $locale);
            Session::save();
            return redirect()->back()->with('locale', $locale);
        } else {
            return redirect()->back();
        }
    }
    public function dashboard(){
        return view('admin.index');
    }
    public function admin(){
        if (Auth::check()) {
            return Redirect::to('admin/dashboard');
        }else{
            return Redirect::to('admin/login');
        }
    }
    public function checkredirect(){
        if (Auth::check()) {

        }
    }
}
