helpers.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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($id){
  51. $code_3=str_pad($id, 6, 0, STR_PAD_LEFT);
  52. $code='TNSJ'.mb_substr($code_3,0,3).date('ymd',time()).mb_substr($code_3,3,3);
  53. return $code;
  54. }
  55. //function public_path($path = '')
  56. //{
  57. // return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
  58. //}