|
1
|
|
|
<?php |
|
2
|
|
|
namespace Hideyo\Ecommerce\Framework\Services\Product\Entity; |
|
3
|
|
|
|
|
4
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\Entity\ProductExtraFieldValue; |
|
5
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\Entity\ProductRepository; |
|
6
|
|
|
use Hideyo\Ecommerce\Framework\Services\BaseRepository; |
|
7
|
|
|
|
|
8
|
|
|
class ProductExtraFieldValueRepository extends BaseRepository |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
protected $model; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct(ProductExtraFieldValue $model, ProductRepository $product) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->model = $model; |
|
16
|
|
|
$this->product = $product; |
|
|
|
|
|
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
public function selectAllByProductId($productId) |
|
21
|
|
|
{ |
|
22
|
|
|
return $this->model->where('shop_id', auth('hideyobackend')->user()->selected_shop_id)->where('product_id', '=', $productId)->get(); |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function selectByProductIdAndExtraFieldId($productId, $extraFieldId) |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
return $this->model->where('shop_id', auth('hideyobackend')->user()->selected_shop_id)->where('product_id', '=', $productId)->where('extra_field_id', '=', $extraFieldId)->get(); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function selectOneByShopIdAndSlug($shopId, $slug) |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
return $this->model->with(array('productCategory', 'productImages'))->where('shop_id', $shopId)->where('slug', $slug)->get()->first(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function selectOneByShopIdAndId($shopId, $id) |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
return $this->model->with(array('productCategory', 'productImages'))->where('shop_id', $shopId)->where('id', $id)->get()->first(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function selectAllByProductCategoryId($productCategoryId, $shopId) |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
|
|
44
|
|
|
return $this->model-> |
|
45
|
|
|
whereHas('product', function ($query) use ($productCategoryId, $shopId) { |
|
46
|
|
|
$query->where('product_category_id', '=', $productCategoryId); |
|
47
|
|
|
$query->where('active', 1); |
|
48
|
|
|
$query->where('shop_id', $shopId); |
|
49
|
|
|
})->with( |
|
50
|
|
|
array( |
|
51
|
|
|
'extraFieldDefaultValue', |
|
52
|
|
|
'extraField' => function ($q) { |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
) |
|
55
|
|
|
)->get(); |
|
56
|
|
|
} |
|
57
|
|
|
} |