Controller.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php namespace App\Http\Controllers;
  2. // 基础控制器
  3. use Illuminate\Routing\Controller as BaseController;
  4. /**
  5. * 控制器总控
  6. *
  7. */
  8. class Controller extends BaseController
  9. {
  10. /**
  11. * 构造方法,初始化
  12. *
  13. * */
  14. public function __construct(){
  15. // 初始化
  16. if( method_exists($this, '_initialize') ) $this->_initialize();
  17. // 初始化
  18. if( method_exists($this, '__init') ) $this->__init();
  19. }
  20. /**
  21. * 操作错误跳转的快捷方法
  22. * @param Mixed $msg 提示信息
  23. * @param String $url 跳转的URL地址
  24. * @param Int $wait 跳转等待时间
  25. *
  26. * @return Void
  27. */
  28. protected function error($msg = '', $url = null, $wait = 3)
  29. {
  30. if ( is_null($url) ) {
  31. $url = request()->ajax() ? '' : 'javascript:history.back(-1);';
  32. } elseif ('' !== $url) {
  33. $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : url($url);
  34. }
  35. // 返回结果
  36. return view('error',['msg'=>$msg,'url'=>$url,'wait'=>$wait]);
  37. }
  38. /**
  39. * 保存用户操作历史
  40. *
  41. * @param Int $uid 用户ID
  42. * @param String $table 操作表
  43. * @param Int $type 操作类型
  44. * @param Array $oldData 旧数据
  45. * @param Array $oldData 新数据
  46. *
  47. */
  48. protected function addAdminHistory($uid,$table,$id,$type,$oldData,$newData) {
  49. //记录详细操作历史
  50. $AdminHistory = (new AdminHistory());
  51. // 记录数据
  52. $AdminHistory->addAll($uid,$table,$id,$type,$oldData,$newData);
  53. }
  54. }