<?php

namespace App\Repositories;

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

class SmsMessageRepository
{
    public function __construct(protected SmsMessage $model) {}

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

    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): ?SmsMessage
    {
        return $this->query()->find($id);
    }

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

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