Controller.php 1.9 KB

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