43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use App\Component\Models\Terminal;
|
|
use App\Console\Commands\HRCCommand;
|
|
use App\Console\Commands\HRCCommandInterface;
|
|
|
|
class POSTTerminals extends HRCCommand implements HRCCommandInterface
|
|
{
|
|
protected $signature = 'postterminals';
|
|
|
|
public function command($input, $output = null)
|
|
{
|
|
|
|
if (isset($input['method'])) {
|
|
$method = $input['method'];
|
|
if ($method == 'update') {
|
|
if (isset($input['data'])) {
|
|
$data = $input['data'];
|
|
$data = json_decode(base64_decode(urldecode($data)), true);
|
|
$terminals = Terminal::get();
|
|
foreach ($terminals as $terminal) {
|
|
if ($terminal['work_group'] == $data['work_group']) {
|
|
$item = Terminal::find($terminal['id']);
|
|
$item->name = $data['name'];
|
|
$item->save();
|
|
}
|
|
}
|
|
$terminals = Terminal::get();
|
|
return [
|
|
'status' => 'success',
|
|
'terminals' => $terminals
|
|
];
|
|
}
|
|
}
|
|
}
|
|
return [
|
|
'status' => 'fail',
|
|
'error_message' => 'Проверьте введенные данные',
|
|
];
|
|
}
|
|
} |