Files
admin-php-module/commands/GETReports.php
miroman-afk fb46c8e739 v.2.27
Fixed reports
2023-05-02 15:21:54 +03:00

42 lines
1019 B
PHP

<?php
namespace App\Commands;
use App\Component\Models\Report;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETReports extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getreports';
public function command($input, $output = null) {
$reports = Report::select('id', 'name', 'report_type', 'start_date', 'end_date')->orderBy('id', 'desc')->get();
if ($reports) {
foreach ($reports as $key => $report) {
$data[] = array(
'id' => $report['id'],
'name' => $report['name'],
'type' => $report['report_type'],
'start_date' => date('d.m.Y', strtotime($report['start_date'])),
'end_date' => date('d.m.Y', strtotime($report['end_date'])),
);
}
if (isset($data)) {
return [
'status' => 'success',
'reports' => $data,
];
} else {
return [
'status' => 'success',
'reports' => [],
];
}
} else {
return [
'status' => 'success',
'reports' => [],
];
}
}
}