-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Info.php
87 lines (70 loc) · 2.14 KB
/
Info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace App\Utilities;
use App\Models\Auth\User;
use App\Models\Common\Company;
use App\Models\Common\Contact;
use App\Models\Document\Document;
use Composer\InstalledVersions;
use Illuminate\Support\Facades\DB;
class Info
{
public static function all()
{
static $info = [];
if (! empty($info)) {
return $info;
}
$info = array_merge(static::versions(), [
'api_key' => setting('apps.api_key'),
'ip' => static::ip(),
'companies' => Company::count(),
'users' => User::count(),
'invoices' => Document::invoice()->count(),
'customers' => Contact::customer()->count(),
'php_extensions' => static::phpExtensions(),
]);
return $info;
}
public static function versions()
{
static $versions = [];
if (! empty($versions)) {
return $versions;
}
$versions = [
'akaunting' => version('short'),
'laravel' => InstalledVersions::getPrettyVersion('laravel/framework'),
'php' => static::phpVersion(),
'mysql' => static::mysqlVersion(),
'guzzle' => InstalledVersions::getPrettyVersion('guzzlehttp/guzzle'),
'livewire' => InstalledVersions::getPrettyVersion('livewire/livewire'),
'omnipay' => InstalledVersions::getPrettyVersion('league/omnipay'),
];
return $versions;
}
public static function phpVersion()
{
return phpversion();
}
public static function phpExtensions()
{
return get_loaded_extensions();
}
public static function mysqlVersion()
{
static $version;
if (empty($version) && (config('database.default') === 'mysql')) {
$version = DB::selectOne('select version() as mversion')->mversion;
}
if (isset($version)) {
return $version;
}
return 'N/A';
}
public static function ip()
{
return request()->header('CF_CONNECTING_IP')
? request()->header('CF_CONNECTING_IP')
: request()->ip();
}
}