helpers.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. use Illuminate\Support\Str;
  3. function judge_level($level){
  4. switch ($level){
  5. case 1:
  6. $level='销售主管';
  7. break;
  8. case 2:
  9. $level='销售经理';
  10. break;
  11. case 3:
  12. $level='代理公司';
  13. break;
  14. }
  15. return $level;
  16. }
  17. function judge_level_name($level){
  18. switch ($level){
  19. case '销售主管':
  20. $level=1;
  21. break;
  22. case '销售经理':
  23. $level=2;
  24. break;
  25. case '代理公司':
  26. $level=3;
  27. break;
  28. }
  29. return $level;
  30. }
  31. function make_excerpt($value, $length = 200)
  32. {
  33. $excerpt = trim(preg_replace('/\r\n|\r|\n+/', ' ', strip_tags($value)));
  34. return str_limit($excerpt, $length);
  35. }
  36. function str_limit($value, $limit = 100, $end = '...')
  37. {
  38. return Str::limit($value, $limit, $end);
  39. }
  40. function code($phone){
  41. $data=md5(uniqid($phone));
  42. // return $data;
  43. $data=substr($data,1,6);
  44. return $data;
  45. }
  46. function str_random($length = 16)
  47. {
  48. return Str::random($length);
  49. }
  50. function auth_code($phone){
  51. $code_1=str_pad(random_int(1, 999), 3, 0, STR_PAD_LEFT);
  52. $code_2=mb_substr($phone,1,3);
  53. $code_3=str_pad(random_int(100, 99999), 6, 0, STR_PAD_LEFT);
  54. $code_4=mb_substr(time(),8,2);
  55. $code='DWBS00'.$code_1.date('ymd',time()).$code_2.$code_3.$code_4;
  56. return $code;
  57. }
  58. //function public_path($path = '')
  59. //{
  60. // return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
  61. //}