<?php

namespace App\Repositories;

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

class MikrotikSecretRepository
{
    public function __construct(protected MikrotikSecret $model) {}

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

    public function getForDataTable()
    {
        return $this->query()->with(['mikrotik']);
    }

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

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

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

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

    public function delete(MikrotikSecret $secret): bool
    {
        return $secret->delete();
    }
}
