File: /var/www/html/punjabcabs/app/Helper/ViewHelper.php
<?php
use App\PromocodeUsage;
use App\ServiceType;
use \Carbon\Carbon;
function currency($value = '')
{
if($value == ""){
return Setting::get('currency')."0.00";
} else {
return Setting::get('currency').$value;
}
}
function distance($value = '')
{
if($value == ""){
return "0".Setting::get('distance', 'Km');
}else{
return $value.Setting::get('distance', 'Km');
}
}
function img($img){
if($img == ""){
return asset('main/avatar.jpg');
}else if (strpos($img, 'http') !== false) {
return $img;
}else{
return asset('storage/'.$img);
}
}
function image($img){
if($img == ""){
return asset('main/avatar.jpg');
}else{
return asset($img);
}
}
function promo_used_count($promo_id)
{
return PromocodeUsage::where('status','ADDED')->where('promocode_id',$promo_id)->count();
}
function curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close ($ch);
return $return;
}
function get_all_service_types()
{
return ServiceType::all();
}
function hideEmail($email) {
return $email;
}
function hidechar($char) {
return $char;
}
function date_formatter($str){
if($str !=''){
$date = Carbon::parse($str);
return $date->format('d-m-Y');
}else{
return "-";
}
}
function datetime_formatter($str){
if($str !=''){
$date = Carbon::parse($str);
return $date->format('d-m-Y H:i:s');
}else{
return "-";
}
}