Files
admin-php-module/commands/ClientGroup.php
2021-06-03 16:59:31 +03:00

28 lines
750 B
PHP

<?php
namespace App\Commands;
use App\Component\Models\ClientsGroup;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETClientGroup extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getclientgroup';
public function command($input, $output = null) {
if (ClientsGroup::where('code', '0')->count() == 0) {
$group = new ClientsGroup;
$group->code = '0';
$group->name = 'Без группы';
$group->save();
}
$client_groups = ClientsGroup::orderBy('code')->get();
foreach ($client_groups as $client_group) {
$out[] = array('id' => $client_group['id'], 'name' => $client_group['name']);
}
return [
'status' => 'success',
'groups' => $out,
];
}
}