51 lines
1.6 KiB
PHP
51 lines
1.6 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' => 'Ошибка данных запроса',
|
|
];
|
|
}
|
|
}
|
|
} |