<?php

namespace Modules\Inventory\DTO;

use Illuminate\Http\Request;

class PurchasePaymentAccountFilter
{
    public function __construct(
        public readonly ?string $search,
        public readonly ?int $perPage = 15,
    ) {}

    public static function fromRequest(Request $request): self
    {
        return new self(
            search: $request->filled('search') ? trim($request->search) : null,
            perPage: $request->filled('per_page') ? (int) $request->per_page : 15,
        );
    }
}
