Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Y6eZQ0bXQBXdJg9hiYjI53oYGKdGaW2ochFt3T77dLU=
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove committed APP_KEY from test env config

Checking a concrete APP_KEY into source control makes that key public, so any environment that boots with this .env.testing file (for example shared QA/staging or preview deployments) can have forged encrypted cookies, signed URLs, and other Laravel-encrypted payloads. This should be sourced from runtime secrets instead of a tracked file.

Useful? React with 👍 / 👎.

APP_DEBUG=true
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

# PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
# CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
16 changes: 6 additions & 10 deletions app/Http/Controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,10 @@ public function update(Request $request, Order $order)
DB::beginTransaction();
try {
// 1. Revert Stock for OLD items
$order->load(['items.variant']);
foreach ($order->items as $item) {
if ($item->product_variant_id) {
$variant = ProductVariant::find($item->product_variant_id);
if ($variant) {
$variant->increment('quantity', $item->quantity);
}
if ($item->variant) {
$item->variant->increment('quantity', $item->quantity);
}
}

Expand Down Expand Up @@ -554,12 +552,10 @@ public function destroy(Order $order)
DB::beginTransaction();
try {
// Restore Stock
$order->load(['items.variant']);
foreach ($order->items as $item) {
if ($item->product_variant_id) {
$variant = ProductVariant::find($item->product_variant_id);
if ($variant) {
$variant->increment('quantity', $item->quantity);
}
if ($item->variant) {
$item->variant->increment('quantity', $item->quantity);
}
}

Expand Down