mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?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));
|
|
}
|
|
|
|
}
|