mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CheckForStorageInvoiceByOrderId
|
|
{
|
|
|
|
/** @var CheckStorageInvoiceTransactionProcessor */
|
|
private $storageInvoiceTransactionProcessor;
|
|
|
|
|
|
public function __construct(CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
|
{
|
|
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
|
}
|
|
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Request $request
|
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
$orderId = $request->route('id');
|
|
$storages = [];
|
|
try{
|
|
$storages = $this->storageInvoiceTransactionProcessor->execute($orderId);
|
|
} catch (\Exception $exception) {
|
|
$storages = [];
|
|
}
|
|
$request->merge(['storages' => $storages]);
|
|
return $next($request);
|
|
}
|
|
}
|