51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use App\Component\Models\Client;
|
|
use App\Component\Models\ClientsActions;
|
|
use App\Component\Models\ClientsPresale;
|
|
use App\Component\Models\ExchangeOrders;
|
|
use App\Component\Models\ShiftOnlineOrders;
|
|
use App\Component\Models\Staff;
|
|
use App\Console\Commands\HRCCommand;
|
|
use App\Console\Commands\HRCCommandInterface;
|
|
|
|
class GETClientLog extends HRCCommand implements HRCCommandInterface
|
|
{
|
|
protected $signature = 'getclientlog';
|
|
|
|
public function command($input, $output = null)
|
|
{
|
|
if (isset($input['id'])) {
|
|
$client = Client::where('id', $input['id'])->first();
|
|
$client_guid = $client['user_code'];
|
|
$logs = ClientsActions::where('user_id', $client_guid)->orderByDesc('created')->get();
|
|
$info = [];
|
|
foreach ($logs as $log) {
|
|
$info[] = array(
|
|
'action' => $log['action'],
|
|
'value' => round($log['action_value'], 2),
|
|
'who' => Staff::getName($log['who']),
|
|
'time' => $log['created'],
|
|
'type' => $log['action_type']
|
|
);
|
|
}
|
|
$result = array(
|
|
'id' => $client['id'],
|
|
'name' => $client['name'],
|
|
'info' => $info
|
|
);
|
|
return [
|
|
'status' => 'success',
|
|
'client' => $result,
|
|
];
|
|
} else {
|
|
return [
|
|
'status' => 'error',
|
|
'more' => 'Проверьте введенные данные',
|
|
];
|
|
}
|
|
|
|
}
|
|
} |