Controller.php 1.6 KB

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