private function logEventsToDB($model)
    {
        $user = auth()->user();
        $class = get_class($model);
        $trace = debug_backtrace();
        $event = $trace[2] ? $trace[2]['function'] : "Unknown event";

        try {
            UserAction::create(
                array_merge($this->getDiff($model), [
                    'model' => $class,
                    'action' => $event,
                    'user_id' => $user ? $user->id : null,
                    'model_id' => $model->id,
                ])
            );
        } catch (\Exception $e) {
            $message = $e->getMessage();
            Log::error("Could not record user action to db: '{$message}'");
        }
    }