<?php

namespace App\Services;

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

class ProviderBlockedDayService
{
    public function getByProvider(int $providerId): Collection
    {
        return ProviderBlockedDay::where('provider_id', $providerId)
            ->orderBy('date', 'asc')
            ->orderBy('init_hour', 'asc')
            ->get();
    }

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

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

    public function update(ProviderBlockedDay $blockedDay, array $data): ProviderBlockedDay
    {
        $blockedDay->update($data);

        return $blockedDay->fresh();
    }

    public function delete(ProviderBlockedDay $blockedDay): bool
    {
        return $blockedDay->delete();
    }
}
