fix code
This commit is contained in:
@@ -32,12 +32,11 @@ class DailyMovingMachineCommand extends Command
|
|||||||
public function handle(DailyMovingMachinesService $dailyMovingMachines): void
|
public function handle(DailyMovingMachinesService $dailyMovingMachines): void
|
||||||
{
|
{
|
||||||
$vehiclesInfo = $dailyMovingMachines->run();
|
$vehiclesInfo = $dailyMovingMachines->run();
|
||||||
$response =$vehiclesInfo->get('vehiclesInfo', collect());
|
$response = collect($vehiclesInfo['vehiclesInfo']);
|
||||||
|
|
||||||
$date = now()->toDateString();
|
$date = now()->toDateString();
|
||||||
|
|
||||||
$cmms = $response
|
$cmms = $response->pluck('machineCode');
|
||||||
->pluck('machineCode');
|
|
||||||
|
|
||||||
$mission = Mission::query()
|
$mission = Mission::query()
|
||||||
->whereDate('start_time',$date)
|
->whereDate('start_time',$date)
|
||||||
@@ -60,12 +59,13 @@ class DailyMovingMachineCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($missionOnly as $code) {
|
foreach ($missionOnly as $code) {
|
||||||
$missionRecord = Mission::query()->where('machine_code', $code)
|
$missionId = Mission::query()->where('machine_code', $code)
|
||||||
->whereDate('start_time', today())
|
->whereDate('start_time', today())
|
||||||
->get();
|
->value('id');
|
||||||
|
|
||||||
AssignmentFails::query()->create([
|
AssignmentFails::query()->create([
|
||||||
'machine_code' => $code,
|
'machine_code' => $code,
|
||||||
'mission_id' => $missionRecord->id,
|
'mission_id' => $missionId,
|
||||||
'type' => ActivityMachineType::ADAM_TAHAROK->label(),
|
'type' => ActivityMachineType::ADAM_TAHAROK->label(),
|
||||||
'request_date' => $date,
|
'request_date' => $date,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class DetailController extends Controller
|
|||||||
|
|
||||||
public function machines(Mission $mission): JsonResponse
|
public function machines(Mission $mission): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->successResponse($mission->machines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number']));
|
return $this->successResponse($mission->machine()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rahdaran(Mission $mission): JsonResponse
|
public function rahdaran(Mission $mission): JsonResponse
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ class DailyMovingMachinesService
|
|||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function run(): Collection
|
public function run(): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return collect( $this->sendRequest());
|
return $this->sendRequest();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::channel($this->channelName)
|
Log::channel($this->channelName)
|
||||||
->error(get_class($this),
|
->error(get_class($this),
|
||||||
|
|||||||
Reference in New Issue
Block a user