<?php

namespace App\Filters;

use App\Models\Goods;
use App\Models\GoodsSku;

class GoodsSkuLocationFilter extends Filters
{
    public function date($value)
    {
        return $this->builder->where('date', $value);
    }

    public function goodsTitle($value)
    {
        $goodsId = Goods::query()->where('title', $value)->value('id');

        return $this->builder->where('goods_id', $goodsId);
    }

    public function goodsCode($value)
    {
        $goodsId = Goods::query()->where('goods_code', $value)->value('id');

        return $this->builder->where('goods_id', $goodsId);
    }

    public function externalSkuId($value)
    {
        return $this->builder->where('external_sku_id', $value);
    }

    public function location($value)
    {
        return $this->builder->where('location', $value);
    }

    public function status($value)
    {
        return $this->builder->where('status', $value);
    }
}
