Files
admin-php-module/commands/GETSettings.php
miroman-afk c4dc6e02a0 v.2.30
Добавлен расширенный отчет по реализации
Добавлен монитор активности
2023-08-03 11:05:15 +03:00

70 lines
2.2 KiB
PHP

<?php
namespace App\Commands;
use App\Component\Models\Settings;
use App\Component\Commands\Methods\Cache;
use App\Component\Models\Terminal;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETSettings extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'getsettings';
public function command($input, $output = null)
{
if (isset($input['method'])) {
$method = $input['method'];
if ($method == 'terminals') {
$out = [];
$terminals = Terminal::get();
foreach ($terminals as $terminal) {
if ($terminal['is_active'] === 1) {
$is_active = true;
} else {
$is_active = false;
}
$out[] = array(
'id' => $terminal['id'],
'name' => $terminal['name'],
'work_code' => $terminal['work_code'],
'work_group' => $terminal['work_group'],
'soft' => $terminal['soft'],
'is_active' => $is_active,
'key' => $terminal['key'],
'last_activity' => $terminal['last_activity'],
);
}
return [
'status' => 'success',
'terminals' => $out,
];
}
}
if (isset($input['code'])) {
$setting = Settings::where('code', $input['code'])
->first();
if ($setting) {
return [
'status' => 'success',
'code' => $setting['code'],
'value' => $setting['value'],
];
} else {
return [
'status' => 'error',
'more' => 'Setting not found',
];
}
} else {
$settings = Settings::all();
return [
'status' => 'success',
'settings' => $settings,
];
}
}
}