%PDF- %PDF-
Direktori : /home/silvzytp/crm-ind-code/app/Helpers/ |
Current File : //home/silvzytp/crm-ind-code/app/Helpers/Helper.php |
<?php use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\File; // const variable define('ALERT_SUCCESS','Record has been saved successfully.'); define('ALERT_DELETE','Record has been remove successfully.'); define('ALERT_UPDATE','Record has been updated successfully.'); define('ALERT_WRONG',['status'=>'error','message'=>'Somthing Wrong!']); define('STATUS',[1=>'Published',2=>'Pending']); define('UNAUTHORIZED',['status'=>'error','message'=>'Access denied! you Don’t Have Permission To Access on This Site']); define('__FILE_PATH__','uploads/'); define('SERVER_ERROR','Server Error!'); define('ASSET','/assets'); define('PREFIX','PAN-'); define('REFERENCE','SOD-L-'); define('POTENTIAL',[1=>'Yes',2=>'No',3=>'Not Spacified']); define('HOT_LINK',[1=>'Yes',2=>'No']); define('MONTH_DAY_DATA',[ 1=>'1 Day', 2=>'2 Day', 3=>'3 Day', 4=>'4 Day', 5=>'5 Day', 6=>'6 Day', 7=>'7 Day', 8=>'8 Day', 9=>'9 Day', 10=>'10 Day', 11=>'11 Day', 12=>'12 Day', 13=>'13 Day', 14=>'14 Day', 15=>'15 Day', 16=>'16 Day', 17=>'17 Day', 18=>'18 Day', 19=>'19 Day', 20=>'20 Day', 21=>'21 Day', 22=>'22 Day', 23=>'23 Day', 24=>'24 Day', 25=>'25 Day', 26=>'26 Day', 27=>'27 Day', 28=>'28 Day', 29=>'29 Day', 30=>'30 Day', 31=>'31 Day', ]); define('MONTH',[ 1=>'January', 2=>'February', 3=>'March', 4=>'April', 5=>'May', 6=>'June', 7=>'July', 8=>'August', 9=>'September', 10=>'October', 11=>'November', 12=>'December', ]); /** * status * * @param $status * @return \Illuminate\Http\Response */ if (!function_exists('status')) { function status($status){ if ($status == 1) { $output = '<span class="badge badge-primary">Published</span>'; }else{ $output = '<span class="badge badge-danger">Pending</span>'; } return $output; } } /** * auth route name * * @return \Illuminate\Http\Response */ if (!function_exists('routeName')) { function routeName(){ if (Auth::user()->role->slug == 'super-admin') { return 'super'; } else { return 'app'; } } } /** * File upload storage * * @param $file * @param $folder * @return \Illuminate\Http\Response */ if (!function_exists('file_store')) { function file_store($file,$folder) { if ($file) { $folderName = __FILE_PATH__.$folder; // folder name // if not have a folder create folder !File::exists($folderName) ? File::makeDirectory($folderName, 0777, true, true) : false; $fileExtension = $file->getClientOriginalExtension(); // file extension $fileName = uniqid(time().rand()).'.'.$fileExtension; // new file name $fileName = $folderName.$fileName; $file->move($folderName, $fileName); // upload file storage }else{ $fileName = NULL; } return $fileName; } } /** * File remove or upload storage * * @param $file * @param $folder * @param $oldFile * @return \Illuminate\Http\Response */ if (!function_exists('file_update')) { function file_update($file,$folder,$oldFile) { if ($file) { $folderName = __FILE_PATH__.$folder; // folder name // if not have a folder create folder !File::exists($folderName) ? File::makeDirectory($folderName, 0777, true, true) : false; file_exists($oldFile) ? unlink($oldFile) : false; // old file remove $fileExtension = $file->getClientOriginalExtension(); // file extension $fileName = uniqid(time().rand()).'.'.$fileExtension; // new file name $fileName = $folderName.$fileName; $file->move($folderName, $fileName); // upload file storage }else{ $fileName = $oldFile; } return $fileName; } } /** * File remove or upload storage * * @param $file * @param $folder * @param $oldFile * @return \Illuminate\Http\Response */ if (!function_exists('file_remove')) { function file_remove($oldFile){ return file_exists($oldFile) ? unlink($oldFile) : false; // file remove } } /** * Date format * * @param $date * @param $format * @return Response; */ if(!function_exists('date_formats')){ function date_formats($date,$format){ return date($format,strtotime($date)); } } /** * Page title * * @param $title * @return Response; */ if(!function_exists('page_title')){ function page_title($siteTitle = null){ return view()->share(['siteTitle'=>$siteTitle]); } } /** * Tooltrip back * * @param $title * @return Response; */ if(!function_exists('tooltip')){ function tooltip($title){ return 'data-container="body" data-toggle="tooltip" data-placement="top" title="" data-original-title="'.$title.'"'; } } /** * Tooltrip white * * @param $title * @return Response; */ if(!function_exists('tooltip_white')){ function tooltip_white($title){ return 'data-container="body" data-toggle="popover" data-trigger="hover" data-placement="top" data-content="'.$title.'" data-original-title="" title=""'; } } /** * Flash message response data * * @param $status * @param $message * @return Response; */ function response_alert($status,$message): array { return ['status'=>$status,'message'=>$message]; } /** * unique id generated * * @param $offset * @param $length * @return \Illuminate\Http\Response */ function unique_data_generate($offset,$length){ // unique order id generate $chars = '0123456789ABCDEFGHIJKLMNOPQRST'; return substr(str_shuffle($chars), $offset, $length); }