functions.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. if(!function_exists('apiUrl')){
  3. function apiUrl(){
  4. //return 'http://127.0.0.1:8000/';
  5. //return 'http://sams-apply.test/';
  6. return 'http://backend.samsapply.co.uk/';
  7. }
  8. }
  9. if(!function_exists('dDate')){
  10. function dDate($date=NULL, $format='d M Y', $default='N/A'){
  11. if(empty($format)) $format='d M Y';
  12. if(empty($date)) return $default;
  13. return date($format, strtotime($date));
  14. }
  15. }
  16. if(!function_exists('utc_to_local')){
  17. function utc_to_local($tz, $time_str, $format='d M Y g:i A'){
  18. return \Carbon\Carbon::parse(
  19. $time_str
  20. )->setTimezone($tz)->format($format);
  21. }
  22. }
  23. if(!function_exists('findTrait')){
  24. function findTrait($name){
  25. return "\\App\\Traits\\{$name}";
  26. }
  27. }
  28. if(!function_exists('getApiRequest')){
  29. function getApiRequest($url){
  30. $data = Illuminate\Support\Facades\Http::get($url);
  31. return $data->json();
  32. }
  33. }
  34. if(!function_exists('findRowByColumn')){
  35. function findRowByColumn($model,$columnName,$value){
  36. $data = model($model)::where($columnName,$value)->first();
  37. return $data;
  38. }
  39. }
  40. if(!function_exists('model')){
  41. function model($name){
  42. return "\\App\\Models\\{$name}";
  43. }
  44. }
  45. if(!function_exists('flag_url')){
  46. function flag_url($code, $size='1x1'){
  47. //alt size 4x3
  48. return asset("flags/{$size}/".strtolower($code).".svg");
  49. }
  50. }