<?php

namespace App\Repositories;

use App\Models\SmsGateway;
use Illuminate\Pagination\LengthAwarePaginator;

class SmsGatewayRepository
{
    public function __construct(protected SmsGateway $model) {}

    public function query()
    {
        return $this->model->newQuery();
    }

    public function getForDataTable()
    {
        return $this->query();
    }

    public function paginate(int $perPage = 25): LengthAwarePaginator
    {
        return $this->query()->latest('id')->paginate($perPage);
    }

    public function find(int $id): ?SmsGateway
    {
        return $this->query()->find($id);
    }

    public function create(array $data): SmsGateway
    {
        return $this->model->create($data);
    }

    public function update(SmsGateway $gateway, array $data): bool
    {
        return $gateway->update($data);
    }

    public function delete(SmsGateway $gateway): bool
    {
        return $gateway->delete();
    }
}
