<?php

namespace App\Services;

use App\Models\ProviderPaymentMethod;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Log;

class ProviderPaymentMethodService
{
    public function getByProvider(int $providerId): Collection
    {
        return ProviderPaymentMethod::where('provider_id', $providerId)->get();
    }

    public function findById(int $id): ?ProviderPaymentMethod
    {
        return ProviderPaymentMethod::find($id);
    }

    public function create(array $data): ProviderPaymentMethod
    {
        return ProviderPaymentMethod::create($data);
    }

    public function update(ProviderPaymentMethod $paymentMethod, array $data): ProviderPaymentMethod
    {
        $paymentMethod->update($data);
        return $paymentMethod->fresh();
    }

    public function delete(ProviderPaymentMethod $paymentMethod): bool
    {
        return $paymentMethod->delete();
    }
}
