mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-30 09:54:16 +00:00
Merge branch 'packaging-list-schedule' into 'master'
create package list ui See merge request CIEFWorldwideSdnBhd/shipping-portal!66
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CompletePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReschedulePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDispatchDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDropDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\CompletePackingListLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CompletePackingListController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CompletePackingListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function complete(Request $request, CompletePackingListLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\ReschedulePackingListLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReschedulePackingListController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ReschedulePackingListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function reschedule(Request $request, ReschedulePackingListLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\UpdateDispatchDatePackingListLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDispatchDatePackingListController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateDispatchDatePackingListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateDispatchDatePackingListLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\UpdateDropDatePackingListLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDropDatePackingListController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateDropDatePackingListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateDropDatePackingListLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user