add report for machines
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Http\Traits\ApiResponse;
|
||||
use App\Models\CMMSMachine;
|
||||
use App\Models\Mission;
|
||||
use App\Models\MissionViolation;
|
||||
use App\Models\Rahdaran;
|
||||
use App\Models\RahdariPoint;
|
||||
use App\Services\Cartables\Mission\DailyMoveMachineService;
|
||||
use Carbon\Carbon;
|
||||
@@ -47,7 +48,6 @@ class ViolationManagementController extends Controller
|
||||
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
||||
$user = auth()->user();
|
||||
$zone = $request->zone;
|
||||
$state = MissionStates::END_MISSION->value;
|
||||
$machine = CMMSMachine::query()->where('machine_code', '=', $violation->machine_code)->first(['id', 'machine_code']);
|
||||
|
||||
$mission = Mission::query()->create([
|
||||
@@ -70,8 +70,8 @@ class ViolationManagementController extends Controller
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'start_time' => $request->start_date,
|
||||
'finish_time' => $request->end_date,
|
||||
'state_id' => $state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
'state_id' => MissionStates::END_MISSION->value,
|
||||
'state_name' => MissionStates::END_MISSION->label(),
|
||||
'explanation' => $request->explanation,
|
||||
'request_date' => now(),
|
||||
'machine_id' => $machine->id,
|
||||
@@ -79,10 +79,11 @@ class ViolationManagementController extends Controller
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
'km' => $violation->km ?? null,
|
||||
'driver_id' => $request->driver,
|
||||
'driver_name' => Rahdaran::query()->find($request->driver)->name,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
||||
|
||||
$violation->update(['status' => 1]);
|
||||
|
||||
@@ -135,5 +136,4 @@ class ViolationManagementController extends Controller
|
||||
$violation->delete();
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user