Files
admin-php-module/commands/GETRoomMap.php
miroman-afk 4d3ad7727d v.2.24
1. Редактор карты зала.
2022-10-27 15:48:02 +03:00

59 lines
1.9 KiB
PHP

<?php
namespace App\Commands;
use App\Component\Models\Places;
use App\Component\Models\Tables;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETRoomMap extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'getroommap';
public function command($input, $output = null)
{
if (isset($input['type'])) {
$roommap = [];
if ($input['type'] == 'places') {
$places = Places::all();
return [
'status' => 'success',
'places' => $places,
];
}
if ($input['type'] == 'place' && isset($input['id'])) {
$place_name = Places::getName($input['id']);
$tables = Tables::where('place_id', $input['id'])
->get();
return [
'status' => 'success',
'place_id' => $input['id'],
'place' => $place_name,
'tables' => $tables,
];
}
if ($input['type'] == 'full') {
$places = Places::all();
foreach ($places as $place) {
$tables = Tables::where('place_id', $place['id'])
->get();
$roommap[] = array(
'place_id' => $place['id'],
'place_name' => $place['name'],
'tables' => $tables
);
}
return [
'status' => 'success',
'roommap' => $roommap,
];
}
} else {
return [
'status' => 'success',
'message' => 'Ошибка данных запроса',
];
}
}
}