diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/CompletePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/CompletePackingListLogic.php new file mode 100644 index 00000000..a96074c0 --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/CompletePackingListLogic.php @@ -0,0 +1,61 @@ + 'Updated PackingList', + 'message' => 'You have successfully updated the PackingList' + ]; + } + + + /** @var UpdatesPackingListStatus */ + private $updatesPackingListStatus; + + /** @var FetchesPackingList */ + private $fetchesPackingList; + + /** + * CompletePackingListLogic constructor. + * @param CanUpdatePackingList $canUpdatePackingList + * @param UpdatesPackingListStatus $updatesPackingListStatus + * @param FetchesPackingList $fetchesPackingList + */ + public function __construct(UpdatesPackingListStatus $updatesPackingListStatus, FetchesPackingList $fetchesPackingList) + { + $this->updatesPackingListStatus = $updatesPackingListStatus; + $this->fetchesPackingList = $fetchesPackingList; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + $query = $this->updatesPackingListStatus->execute($packing_list, ApprovalStatus::COMPLETED); + return $this->resourceResponse(new PackingListResource($packing_list)); + } + +} diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/ReschedulePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/ReschedulePackingListLogic.php new file mode 100644 index 00000000..097b7e1e --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/ReschedulePackingListLogic.php @@ -0,0 +1,83 @@ + 'Reschedule Packing List', + 'message' => 'You have successfully Reschedule Packing List' + ]; + } + + /** @var FetchesPackingList */ + private $fetchesPackingList; + + /** @var UpdatesScheduleStatus */ + private $updatesScheduleStatus; + + /** @var CreatesSchedule */ + private $createsSchedule; + + /** + * DeleteContainerControllersLogic constructor. + * @param FetchesPackingList $fetchesPackingList + * @param CreatesSchedule $createsSchedule + */ + public function __construct(FetchesPackingList $fetchesPackingList, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule) + { + $this->fetchesPackingList = $fetchesPackingList; + $this->updatesScheduleStatus = $updatesScheduleStatus; + $this->createsSchedule = $createsSchedule; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + + $transport = $packing_list->transports()->first(); + + $old_sechedule = $transport->schedules()->first(); + + $this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED); + + $scheduleObject = new ScheduleObject( + Carbon::parse($request->input('eta')), + Carbon::parse($request->input('etd')), + ApprovalStatus::APPROVED + ); + $schedule = $this->createsSchedule->execute($transport, $scheduleObject); + + return $this->resourceResponse(new PackingListResource($packing_list)); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + +} diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDispatchDatePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDispatchDatePackingListLogic.php new file mode 100644 index 00000000..85970894 --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDispatchDatePackingListLogic.php @@ -0,0 +1,60 @@ + 'Updated Dispatch Date Packing List', + 'message' => 'You have successfully updated the Dispatch Date Packing List' + ]; + } + + + /** @var UpdatesDispatchDateTransport */ + private $updatesDispatchDateTransport; + + /** @var FetchesPackingList */ + private $fetchesPackingList; + + /** + * UpdateDispatchDatePackingListLogic constructor. + * @param CanUpdateContainer $canUpdateContainer + * @param UpdatesDispatchDateTransport $updatesDispatchDateTransport + * @param FetchesPackingList $fetchesPackingList + */ + public function __construct(UpdatesDispatchDateTransport $updatesDispatchDateTransport, FetchesPackingList $fetchesPackingList) + { + $this->updatesDispatchDateTransport = $updatesDispatchDateTransport; + $this->fetchesPackingList = $fetchesPackingList; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + $transport = $packing_list->transports()->first(); + $query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date'))); + return $this->resourceResponse(new PackingListResource($packing_list)); + } + +} diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDropDatePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDropDatePackingListLogic.php new file mode 100644 index 00000000..3ee81faa --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDropDatePackingListLogic.php @@ -0,0 +1,60 @@ + 'Updated Drop Date Packing List', + 'message' => 'You have successfully updated the Drop Date Packing List' + ]; + } + + + /** @var UpdatesDropDateTransport */ + private $updatesDropDateTransport; + + /** @var FetchesPackingList */ + private $fetchesPackingList; + + /** + * UpdateDispatchDatePackingListLogic constructor. + * @param CanUpdateContainer $canUpdateContainer + * @param UpdatesDropDateTransport $updatesDropDateTransport + * @param FetchesPackingList $fetchesPackingList + */ + public function __construct(UpdatesDropDateTransport $updatesDropDateTransport, FetchesPackingList $fetchesPackingList) + { + $this->updatesDropDateTransport = $updatesDropDateTransport; + $this->fetchesPackingList = $fetchesPackingList; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + $transport = $packing_list->transports()->first(); + $query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date'))); + return $this->resourceResponse(new PackingListResource($packing_list)); + } + +} diff --git a/app/Http/Controllers/PackingLists/CompletePackingListController.php b/app/Http/Controllers/PackingLists/CompletePackingListController.php new file mode 100644 index 00000000..504c7b51 --- /dev/null +++ b/app/Http/Controllers/PackingLists/CompletePackingListController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/app/Http/Controllers/PackingLists/ReschedulePackingListController.php b/app/Http/Controllers/PackingLists/ReschedulePackingListController.php new file mode 100644 index 00000000..b92e672e --- /dev/null +++ b/app/Http/Controllers/PackingLists/ReschedulePackingListController.php @@ -0,0 +1,19 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/PackingLists/UpdateDispatchDatePackingListController.php b/app/Http/Controllers/PackingLists/UpdateDispatchDatePackingListController.php new file mode 100644 index 00000000..af3e818d --- /dev/null +++ b/app/Http/Controllers/PackingLists/UpdateDispatchDatePackingListController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/app/Http/Controllers/PackingLists/UpdateDropDatePackingListController.php b/app/Http/Controllers/PackingLists/UpdateDropDatePackingListController.php new file mode 100644 index 00000000..8580246d --- /dev/null +++ b/app/Http/Controllers/PackingLists/UpdateDropDatePackingListController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/routes/packing_list.php b/routes/packing_list.php index 9d2fc80d..cf5062cf 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -10,6 +10,12 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::put('/status/{id}/update/{status}', 'UpdatePackingListStatusController@update')->name('status.update'); Route::delete('/delete/{id}', 'DeletePackingListController@delete')->name('delete'); + Route::put('/reschedule/{id}', 'ReschedulePackingListController@reschedule')->name('reschedule'); + Route::put('/update-dispatch-date/{id}', 'UpdateDispatchDatePackingListController@update')->name('update_dispatch_date'); + Route::put('/update-drop-date/{id}', 'UpdateDropDatePackingListController@update')->name('update_drop_date'); + Route::put('/complete/{id}', 'CompletePackingListController@complete')->name('complete'); + + Route::group(['namespace' => 'Containers', 'prefix' => 'container', 'as' => 'container.'], function () { Route::get('/{id}/show', 'FetchContainerController@fetch')->name('show'); Route::get('/list', 'ListContainersController@list')->name('list');