91 lines
2.2 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Utilities;
2019-12-18 15:29:59 +03:00
use App\Models\Auth\User;
2018-06-10 02:48:51 +03:00
use App\Models\Common\Company;
2022-09-22 00:57:54 +03:00
use App\Models\Common\Contact;
use App\Models\Document\Document;
2023-05-06 16:34:49 +03:00
use App\Traits\Cloud;
2021-12-24 18:44:10 +03:00
use Composer\InstalledVersions;
2022-09-22 00:57:54 +03:00
use Illuminate\Support\Facades\DB;
2017-09-14 22:21:00 +03:00
class Info
{
2019-12-18 15:29:59 +03:00
public static function all()
2017-09-14 22:21:00 +03:00
{
2023-05-06 00:24:18 +03:00
static $info = [];
2023-05-06 16:34:49 +03:00
$is_cloud = (new class { use Cloud; })->isCloud();
if (! empty($info) || $is_cloud) {
2023-05-06 00:24:18 +03:00
return $info;
}
$info = array_merge(static::versions(), [
2019-12-18 15:29:59 +03:00
'api_key' => setting('apps.api_key'),
2022-09-22 00:57:54 +03:00
'ip' => static::ip(),
2020-03-03 16:09:05 +03:00
'companies' => Company::count(),
'users' => User::count(),
2022-09-22 00:57:54 +03:00
'invoices' => Document::invoice()->count(),
'customers' => Contact::customer()->count(),
2020-05-19 15:48:24 +03:00
'php_extensions' => static::phpExtensions(),
2019-12-18 15:29:59 +03:00
]);
2023-05-06 00:24:18 +03:00
return $info;
2017-09-14 22:21:00 +03:00
}
2019-12-18 15:29:59 +03:00
public static function versions()
2017-09-14 22:21:00 +03:00
{
2023-05-06 00:24:18 +03:00
static $versions = [];
if (! empty($versions)) {
return $versions;
}
$versions = [
2019-12-18 15:29:59 +03:00
'akaunting' => version('short'),
2022-09-22 00:57:54 +03:00
'laravel' => InstalledVersions::getPrettyVersion('laravel/framework'),
2019-12-18 15:29:59 +03:00
'php' => static::phpVersion(),
'mysql' => static::mysqlVersion(),
2022-09-22 00:57:54 +03:00
'guzzle' => InstalledVersions::getPrettyVersion('guzzlehttp/guzzle'),
2021-12-24 18:44:10 +03:00
'livewire' => InstalledVersions::getPrettyVersion('livewire/livewire'),
2022-09-22 00:57:54 +03:00
'omnipay' => InstalledVersions::getPrettyVersion('league/omnipay'),
2019-12-18 15:29:59 +03:00
];
2023-05-06 00:24:18 +03:00
return $versions;
2017-09-14 22:21:00 +03:00
}
public static function phpVersion()
{
return phpversion();
}
2020-03-03 16:09:05 +03:00
2020-05-19 15:48:24 +03:00
public static function phpExtensions()
{
return get_loaded_extensions();
}
2017-09-14 22:21:00 +03:00
public static function mysqlVersion()
{
2020-05-19 15:48:24 +03:00
static $version;
if (empty($version) && (config('database.default') === 'mysql')) {
$version = DB::selectOne('select version() as mversion')->mversion;
}
if (isset($version)) {
return $version;
}
2017-09-14 22:21:00 +03:00
2019-12-18 15:29:59 +03:00
return 'N/A';
2017-09-14 22:21:00 +03:00
}
2022-09-22 00:57:54 +03:00
public static function ip()
{
return request()->header('CF_CONNECTING_IP')
? request()->header('CF_CONNECTING_IP')
: request()->ip();
}
2020-03-03 16:09:05 +03:00
}