Compare commits

..

1 Commits

Author SHA1 Message Date
edmondlang 1578085bab add attached timestamp 2023-12-30 16:55:45 +08:00
13 changed files with 10 additions and 82 deletions
@@ -20,7 +20,7 @@ class AssignsAnnouncementToSegment extends AbstractUpdateRecord
{
try {
$announcement->segments()->attach($segment);
$announcement->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
return $announcement;
@@ -20,7 +20,7 @@ class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
{
try {
$companyConnection->segments()->attach($segment);
$companyConnection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
return $companyConnection;
@@ -22,7 +22,7 @@ class AssignsCompanyToSegment extends AbstractUpdateRecord
try {
$companyModule = $company->companyModules()->where('type', BusinessType::IMPORTER)->first();
$connection = $companyModule->connections()->where('inviter_reference', 'CIEF');
$connection->segments()->attach($segment);
$connection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
return $company;
@@ -18,7 +18,7 @@ class AssignsEmployee extends AbstractUpdateRecord
{
try {
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(),'role_id' => $object->getRoleId()]);
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(), 'role_id' => $object->getRoleId(), 'created_at' => now(), 'updated_at' => now()]);
return $object->getCompanyModule();
@@ -53,7 +53,7 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
foreach ($packing_list as $key => $row) {
$packing_list_item = $this->fetchesPackingList->execute(['id' => $row]);
$container->packingLists()->attach($packing_list_item);
$container->packingLists()->attach($packing_list_item, ['created_at' => now(), 'updated_at' => now()]);
}
return $this->resourceResponse(new ContainerResource($container));
@@ -129,7 +129,7 @@ class FetchContainersFromYdPortalProcessor
try {
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
$container->packingLists()->detach($packingList);
$container->packingLists()->attach($packingList);
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
} catch (ResourceNotFoundException $exception){
if(!($packingList->owner instanceof Order)) continue;
@@ -143,7 +143,7 @@ class FetchContainersFromYdPortalProcessor
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
$container->packingLists()->detach($packingList);
$container->packingLists()->attach($packingList);
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::LOAD_CONTAINER);
@@ -274,7 +274,7 @@ class FetchLoadedContainersFromVTPortalProcessor
}
$container->packingLists()->detach($packingList);
$container->packingLists()->attach($packingList);
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
$packingList->packages()->delete();
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
@@ -385,7 +385,7 @@ class FetchOrderListsFromYdPortalProcessor
try {
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
$container->packingLists()->detach($packingList);
$container->packingLists()->attach($packingList);
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
} catch (ResourceNotFoundException $exception){
if (!$allow_contract) {
-2
View File
@@ -38,13 +38,11 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\WebResponseTimeLog::class,
],
'api' => [
'throttle:300,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\ApiResponseTimeLog::class,
],
'apipub' => [
@@ -1,29 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class ApiResponseTimeLog
{
public function handle(Request $request, Closure $next)
{
// Get route information
$route = $request->route();
$routeName = $route ? $route->getName() : 'undefined';
$uri = $request->getPathInfo();
$startTime = microtime(true); // Start time
$response = $next($request); // Handle the request
$endTime = microtime(true); // End time
$responseTime = $endTime - $startTime; // Calculate the response time
Log::channel('apiResponseTimeLog')->info("\nRequest to route: {$uri} \nRoute name: {$routeName} \nTime Taken: " . number_format($responseTime * 1000, 2) . "ms\n");
return $response;
}
}
@@ -1,29 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class WebResponseTimeLog
{
public function handle(Request $request, Closure $next)
{
// Get route information
$route = $request->route();
$routeName = $route ? $route->getName() : 'undefined';
$uri = $request->getPathInfo();
$startTime = microtime(true); // Start time
$response = $next($request); // Handle the request
$endTime = microtime(true); // End time
$responseTime = $endTime - $startTime; // Calculate the response time
Log::channel('webResponseTimeLog')->info("\nRequest to route: {$uri} \nRoute name: {$routeName} \nTime Taken: " . number_format($responseTime * 1000, 2) . "ms\n");
return $response;
}
}
-12
View File
@@ -112,18 +112,6 @@ return [
'path' => storage_path('logs/paymentUnknownOrderLog.log'),
'level' => 'info',
],
'apiResponseTimeLog' => [
'driver' => 'single',
'path' => storage_path('logs/apiResponseTime.log'),
'level' => 'info',
],
'webResponseTimeLog' => [
'driver' => 'single',
'path' => storage_path('logs/webResponseTimeLog.log'),
'level' => 'info',
],
],
];
+1 -1
View File
@@ -531,7 +531,7 @@ class DummyDataSeeder extends Seeder
$container = $this->faker->randomElement(Container::whereDate('loading_date', '>=', $receiveDate)->get());
// attach packing list to container
$container->packingLists()->attach($shippingPackingList);
$container->packingLists()->attach($shippingPackingList, ['created_at' => now(), 'updated_at' => now()]);
if ($container->status !== ApprovalStatus::COMPLETED) {
// ==== //