<?php

namespace App\Repositories;

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

class ResellerRepository
{
    public function __construct(protected Reseller $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): ?Reseller
    {
        return $this->query()->find($id);
    }

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

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

    public function delete(Reseller $reseller): bool
    {
        return $reseller->delete();
    }
}
