mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?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));
|
|
}
|
|
|
|
}
|