Dashboard.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace Dcat\Admin\Controllers;
  3. use Dcat\Admin\Admin;
  4. use Dcat\Admin\Widgets\Tab;
  5. use Illuminate\Support\Arr;
  6. class Dashboard
  7. {
  8. /**
  9. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  10. */
  11. public static function title()
  12. {
  13. return view('admin::dashboard.title');
  14. }
  15. public static function tab()
  16. {
  17. return Tab::make()
  18. ->padding(0)
  19. ->custom()
  20. ->add('Environment', static::environment())
  21. ->add('Extensions', static::extensions())
  22. ->add('Dependencies', static::dependencies());
  23. }
  24. /**
  25. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  26. */
  27. public static function environment()
  28. {
  29. $envs = [
  30. ['name' => 'PHP version', 'value' => 'PHP/'.PHP_VERSION],
  31. ['name' => 'Laravel version', 'value' => app()->version()],
  32. ['name' => 'CGI', 'value' => php_sapi_name()],
  33. ['name' => 'Uname', 'value' => php_uname()],
  34. ['name' => 'Server', 'value' => Arr::get($_SERVER, 'SERVER_SOFTWARE')],
  35. ['name' => 'Cache driver', 'value' => config('cache.default')],
  36. ['name' => 'Session driver', 'value' => config('session.driver')],
  37. ['name' => 'Queue driver', 'value' => config('queue.default')],
  38. ['name' => 'Timezone', 'value' => config('app.timezone')],
  39. ['name' => 'Locale', 'value' => config('app.locale')],
  40. ['name' => 'Env', 'value' => config('app.env')],
  41. ['name' => 'URL', 'value' => config('app.url')],
  42. ];
  43. return view('admin::dashboard.environment', compact('envs'));
  44. }
  45. /**
  46. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  47. */
  48. public static function extensions()
  49. {
  50. $extensions = [
  51. 'Dcat Page' => [
  52. 'name' => '一个简洁的静态站点生成工具 - Dcat Page',
  53. 'link' => 'https://github.com/jqhph/dcat-page',
  54. 'icon' => ' fa-file-text-o',
  55. 'key' => 'dcat-page',
  56. ],
  57. 'UEditor' => [
  58. 'name' => '百度在线编辑器 UEditor',
  59. 'link' => 'https://github.com/jqhph/dcat-admin-ueditor',
  60. 'icon' => 'fa-underline',
  61. 'key' => 'ueditor',
  62. ],
  63. '干货集中营' => [
  64. 'name' => '干货集中营',
  65. 'link' => 'https://github.com/jqhph/dcat-admin-gank',
  66. 'icon' => 'fa-newspaper-o',
  67. 'key' => 'gank',
  68. ],
  69. ];
  70. foreach ($extensions as &$extension) {
  71. $extension['installed'] = array_key_exists($extension['key'], Admin::getExtensions());
  72. }
  73. return view('admin::dashboard.extensions', compact('extensions'));
  74. }
  75. /**
  76. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  77. */
  78. public static function dependencies()
  79. {
  80. $json = file_get_contents(base_path('composer.json'));
  81. $dependencies = json_decode($json, true)['require'];
  82. return view('admin::dashboard.dependencies', compact('dependencies'));
  83. }
  84. }