<?php

namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Session;

class AppController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */

	//for login user to set language in users table
	public function change_language(Request $request){
		//return $request->all();
		if($request->apptype == "app"){ $id = $request->user_id; } else{ $id = Auth::id(); }
		if ($id) {
			$post = User::find($id);
		  	$post->language = $request->language;
		  	$post->save();
		}else{
			$language = $request->language;
			if(!in_array($language,['en','ar'])){
			    $language='en';
			}
			Session::put('language',$language);
		}
	}

	
}
