ErrorMessageService.php 758B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: guanxl
  5. * Date: 2018/6/5
  6. * Time: 16:32
  7. */
  8. namespace App\Services;
  9. use Illuminate\Support\Facades\Log;
  10. class ErrorMessageService
  11. {
  12. public static function redirect($message=""){
  13. Log::info("User agent");
  14. Log::info($_SERVER['HTTP_USER_AGENT']);
  15. $url = env("ERROR_MESSAGE_URL");
  16. if($message) $url.="?error=".$message;
  17. header("location: ".$url);
  18. die;
  19. }
  20. public static function forward($message=""){
  21. Log::info("User agent");
  22. Log::info($_SERVER['HTTP_USER_AGENT']);
  23. $url = env("ERROR_MESSAGE_URL");
  24. if($message) $url.="?error=".$message;
  25. die(json_encode(["error"=>302,"message"=>$message,"redirect"=>$url]));
  26. }
  27. }