public static function eventAuditLogger($target)
    {
        // exists flag is set on an existing record.
        if ($target->exists) {
            $message = 'UPDATE';
        } else {
            $message = 'INSERT';
        }

        // Fetch the currently logged in user
        $username = ApplogHelper::currentUserName();

        // Get the list of client IP addresses
        $clientIp = ApplogHelper::getClientIps();

        // Also get any addresses in _SERVER["HTTP_X_FORWARDED_FOR"]
        $forwardAddress = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
        if (empty($clientIp)) {
            $clientIp = $forwardAddress;
        } elseif (! empty($forwardAddress)) {
            $clientIp = $clientIp . ',' . $forwardAddress;
        }

        // Store the audit log.
        try {
            DB::table('applogs')->insert([
                'type'          => 'audit',
                'modelname'     => get_class($target),
                'foreign_id'    => $target->id,
                'classname'     => __CLASS__,
                'traitname'     => __TRAIT__,
                'functionname'  => __FUNCTION__,
                'filename'      => __FILE__,
                'linenumber'    => __LINE__,
                'message'       => $message,
                'details'       => $message . ' in ' . $target->getTable() . ' table.',
                'ipaddr'        => $clientIp,
                'created_by'    => $username,
                'updated_by'    => $username,
                'created_at'    => date('Y-m-d H:i:s'),
                'updated_at'    => date('Y-m-d H:i:s'),
            ]);
        } catch (\Exception $e) {
            // Do nothing
        }
    }