<?php

namespace App\Repositories\Ecommerce\Filter;

use Illuminate\Http\Request;
use Laravel\Nova\Makeable;

class FilterParamRepository
{
    use Makeable;

    /**
     * Validate
     */
    protected bool $validationPassed = true;

    /**
     * Request object to work with
     */
    protected Request $request;

    /**
     * Filter Repo
     */
    public function __construct(Request $request)
    {
        $this->request = $request;

        if ($this->validateRequest()->fails()) {
            $this->validationPassed = false;
        }
    }

    /**
     * Check if response should be filtered by collection
     */
    public function shouldFilterByCategory(): bool
    {
        return $this->validationPassed && $this->request->filled('category_id');
    }

    /**
     * Check if response should be filtered by collection
     */
    public function shouldFilterByCollection(): bool
    {
        return $this->validationPassed && $this->request->filled('collection_id');
    }

    /**
     * Check if response should be filtered by collection
     */
    public function shouldFilterByBrand(): bool
    {
        return $this->validationPassed && $this->request->filled('brand_id');
    }
}
