<?php

namespace App\Services;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Exception;

abstract class BaseService
{
    protected function transaction(callable $callback)
    {
        return DB::transaction($callback);
    }

    protected function logError(string $message, Exception $e, array $context = []): void
    {
        Log::error($message, array_merge([
            'exception' => $e->getMessage(),
            'trace' => $e->getTraceAsString(),
        ], $context));
    }

    protected function logInfo(string $message, array $context = []): void
    {
        Log::info($message, $context);
    }
}
