Files
shipping-portal/app/Classes/Modules/PackingLists/ControllersLogic/UpdateDispatchDatePackingListLogic.php
T
2021-10-03 21:22:59 +08:00

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\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));
}
}