<?php

namespace App\Services;

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

class BankService
{
    public function getAll(): Collection
    {
        return Bank::query()
            ->orderBy('name')
            ->get();
    }

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

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

    public function update(int $id, array $data): ?Bank
    {
        $model = $this->findById($id);

        if (!$model) {
            return null;
        }

        $model->update($data);

        return $model->fresh();
    }

    public function delete(int $id): bool
    {
        $model = $this->findById($id);

        if (!$model) {
            return false;
        }

        return $model->delete();
    }

    // Add custom business logic methods here
}
