68 lines
2.1 KiB
PHP
68 lines
2.1 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(
|
|
'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,
|
|
];
|
|
}
|
|
}
|
|
} |