<?php

namespace App\Services;

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

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

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

    public function delete(int $id): bool
    {
        $providerSpeciality = ProviderSpeciality::findOrFail($id);

        return $providerSpeciality->delete();
    }
}
