<?php
if(!function_exists('apiUrl')){
    function apiUrl(){
    	//return 'http://127.0.0.1:8000/';
    	//return 'http://sams-apply.test/';
		return 'http://backend.samsapply.co.uk/';
    }
}

if(!function_exists('dDate')){
    function dDate($date=NULL, $format='d M Y', $default='N/A'){

    	if(empty($format)) $format='d M Y';

    	if(empty($date)) return $default;
    	return date($format, strtotime($date));

    }
}

if(!function_exists('utc_to_local')){
	function utc_to_local($tz, $time_str, $format='d M Y g:i A'){

		return \Carbon\Carbon::parse(
			$time_str
		)->setTimezone($tz)->format($format);

	}
}

if(!function_exists('findTrait')){
    function findTrait($name){
    	return "\\App\\Traits\\{$name}";
    }
}

if(!function_exists('getApiRequest')){
    function getApiRequest($url){
		$data = Illuminate\Support\Facades\Http::get($url);
        return $data->json();
    }
}

if(!function_exists('findRowByColumn')){
    function findRowByColumn($model,$columnName,$value){
		$data = model($model)::where($columnName,$value)->first();
        return $data;
    }
}

if(!function_exists('model')){
	function model($name){
		return "\\App\\Models\\{$name}";
	}
}

if(!function_exists('flag_url')){
	function flag_url($code, $size='1x1'){
		//alt size 4x3
		return asset("flags/{$size}/".strtolower($code).".svg");
	}
}
