ECOMMERCE/app/Repositories/Catalog/GenderRepository.php

37 lines
1.1 KiB
PHP

<?php
namespace App\Repositories\Catalog;
use App\Models\Gender;
use App\Models\Brand;
use DB;
use Carbon\Carbon;
use Image;
use Storage;
class GenderRepository
{
public function getList($params){
$category_id = @$params["category_id"];
$brand_id = @$params["brand_id"];
if ($category_id && $brand_id){
$brand = Brand::find((int) $brand_id);
$ids = DB::select("select distinct gender from store_category_map a
left join item_dimension b
left join items on b.no = items.number
on a.category1 = b.category1
and (a.category2 = b.category2 or a.category2 is null)
and (a.category3 = b.category3 or a.category3 is null)
and (a.category4 = b.category4 or a.category4 is null)
where store_category_id = ? and brand = ?
and items.is_publish = true ",[$category_id, $brand->name]);
$ids = collect($ids)->pluck("gender");
return Gender::whereIn("name",$ids)->get();
}
return Gender::get();
}
}