<?php

namespace App\Services;

use App\Models\ProviderServicesType;
use Illuminate\Database\Eloquent\Collection;

class ProviderServicesTypeService
{
    public function getByProvider(int $providerId): Collection
    {
        return ProviderServicesType::with('serviceType')
            ->where('provider_id', $providerId)
            ->orderBy('created_at', 'desc')
            ->get();
    }

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

    public function delete(int $id): bool
    {
        $providerServicesType = ProviderServicesType::findOrFail($id);

        return $providerServicesType->delete();
    }
}
