<?php


namespace App\Filters;


use Illuminate\Http\Request;

class ConfigurationFilters
{
    protected $request;
    protected $queryBuilder;
    protected $filters = [];
    protected $array_filter;
    protected $params = [
        'name', 'contact_man', 'phone', 'invoice_title', 'bank', 'bank_account', 'opening_bank'
    ];

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    public function apply($builder)
    {
        $this->queryBuilder = $builder;
        $filters = array_filter($this->request->only($this->filters));
        foreach ($filters as $filter => $value) {
            if (method_exists($this, $filter)) {
                $this->$filter($value, $this->queryBuilder);
            }
        }
        $this->afterApply();
        return $this->queryBuilder;
    }

    private function afterApply()
    {

    }

    private function name($name)
    {

    }

    private function contact_man($contact_man)
    {

    }

    private function phone($phone)
    {

    }

    private function invoice_title($invoice_title)
    {

    }

    private function opening_bank($opening_bank)
    {

    }

    private function bank($bank)
    {

    }
}
