<?php

namespace App\Filters;

use Essa\APIToolKit\Filters\QueryFilters;

class ChickenLoadingFilters extends QueryFilters
{
    protected array $allowedFilters = [];

    protected array $columnSearch = [
        "farm_name",
        "building_name",
        "batch_no",
        "loading_date",
        "status",
    ];

    public function status($status)
    {
        return $this->builder
            ->when($status == "draft", function ($query) {
                $query->where("status", "draft");
            })
            ->when($status == "submitted", function ($query) {
                $query->where("status", "submitted");
            })
            ->when($status == "saved", function ($query) {
                $query->where("status", "saved");
            })
            ->when($status == "void", function ($query) {
                $query->where("status", "void");
            });
    }
}
