Skip to content

Commit 7d0880d

Browse files
authored
Merge pull request #4 from php-panel/develop
fix: dynamically obtain the admin version
2 parents a9586ee + d2050f9 commit 7d0880d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

resources/views/partials/footer.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
    
1010

1111
@if(config('admin.show_version'))
12-
<strong>Version</strong>&nbsp;&nbsp; {!! \Ladmin\Admin::VERSION !!}
12+
<strong>Version</strong>&nbsp;&nbsp; {!! \Ladmin\Admin::getVersion() !!}
1313
@endif
1414

1515
</div>

src/Admin.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Ladmin;
44

55
use Closure;
6+
use Composer\InstalledVersions;
67
use Ladmin\Auth\Database\Menu;
78
use Ladmin\Controllers\AuthController;
89
use Ladmin\Layout\Content;
@@ -25,7 +26,7 @@ class Admin
2526
*
2627
* @var string
2728
*/
28-
const VERSION = '1.8.17';
29+
const PACKAGE_NAME = 'php-panel/laravel-admin';
2930

3031
/**
3132
* @var Navbar
@@ -69,7 +70,17 @@ class Admin
6970
*/
7071
public static function getLongVersion()
7172
{
72-
return sprintf('Laravel-admin <comment>version</comment> <info>%s</info>', self::VERSION);
73+
return sprintf('Laravel-admin <comment>version</comment> <info>%s</info>', self::getVersion());
74+
}
75+
76+
/**
77+
* Returns the version of Laravel-admin.
78+
*
79+
* @return string The application version
80+
*/
81+
public static function getVersion()
82+
{
83+
return InstalledVersions::getPrettyVersion(self::PACKAGE_NAME) ?? '0.0.0-dev';
7384
}
7485

7586
/**

0 commit comments

Comments
 (0)