You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
821 B

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Routing\Controller as BaseController;
  4. use Illuminate\Support\Facades\DB;
  5. use Log;
  6. class Controller extends BaseController
  7. {
  8. public function __construct()
  9. {
  10. }
  11. /**
  12. * 获取当前控制器名
  13. *
  14. * @return string
  15. */
  16. public function getCurrentControllerName()
  17. {
  18. return self::getCurrentAction()['controller'];
  19. }
  20. /**
  21. * 获取当前方法名
  22. *
  23. * @return string
  24. */
  25. public function getCurrentMethodName()
  26. {
  27. return self::getCurrentAction()['method'];
  28. }
  29. /**
  30. * 获取当前控制器与方法
  31. *
  32. * @return array
  33. */
  34. public function getCurrentAction()
  35. {
  36. $action = \Route::current()->getActionName();
  37. list($class, $method) = explode('@', $action);
  38. return ['controller' => $class, 'method' => $method];
  39. }
  40. }