- Add highly optimized Dockerfile with Nginx and PHP-FPM 8.4 - Add docker-compose.yml configured with Redis and MariaDB 10.11 - Implement entrypoint.sh and supervisord.conf for background workers - Refactor legacy IMAP scripts into scheduled Artisan Commands - Secure app by removing old routes with hardcoded basic auth credentials - Configure email attachments to use Laravel Storage instead of insecure public/tmp
42 lines
965 B
PHP
42 lines
965 B
PHP
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ArrayHelper
|
|
{
|
|
/**
|
|
* Get value from array using dot notation.
|
|
*/
|
|
public static function getValueFromArray(string $key, array $array)
|
|
{
|
|
$keys = explode('.', $key);
|
|
|
|
foreach ($keys as $segment) {
|
|
if (! isset($array[$segment])) {
|
|
return null;
|
|
}
|
|
$array = $array[$segment];
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
|
|
public static function jsonEncodeSafe(mixed $value): string
|
|
{
|
|
try {
|
|
return json_encode(
|
|
$value,
|
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
|
|
);
|
|
} catch (\JsonException $e) {
|
|
// Optional: Log the error
|
|
Log::error('JSON encode failed: '.$e->getMessage());
|
|
|
|
// Fallback: return empty object instead of crashing
|
|
return '{}';
|
|
}
|
|
}
|
|
}
|