|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hideyo\Ecommerce\Framework\Services\Product; |
|
4
|
|
|
|
|
5
|
|
|
use App\Product; |
|
|
|
|
|
|
6
|
|
|
use Validator; |
|
|
|
|
|
|
7
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\Entity\ProductAmountSeriesRepository; |
|
8
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\ProductFacade as ProductService; |
|
|
|
|
|
|
9
|
|
|
use Hideyo\Ecommerce\Framework\Services\BaseService; |
|
10
|
|
|
|
|
11
|
|
|
class ProductAmountSeriesService extends BaseService |
|
12
|
|
|
{ |
|
13
|
|
|
public function __construct(ProductAmountSeriesRepository $productAmountSeries) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->repo = $productAmountSeries; |
|
|
|
|
|
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* The validation rules for the model. |
|
21
|
|
|
* |
|
22
|
|
|
* @param integer $id id attribute model |
|
23
|
|
|
* @return array |
|
24
|
|
|
*/ |
|
25
|
|
|
private function rules($id = false) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
$rules = array( |
|
28
|
|
|
'series_value' => 'required', |
|
29
|
|
|
'series_max' => 'required', |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
return $rules; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function create(array $attributes, $productId) |
|
36
|
|
|
{ |
|
37
|
|
|
$product = ProductService::find($productId); |
|
38
|
|
|
$attributes['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
|
|
|
|
|
|
39
|
|
|
$attributes['product_id'] = $product->id; |
|
40
|
|
|
$validator = Validator::make($attributes, $this->rules()); |
|
41
|
|
|
|
|
42
|
|
|
if ($validator->fails()) { |
|
43
|
|
|
return $validator; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$attributes['modified_by_user_id'] = auth('hideyobackend')->user()->id; |
|
47
|
|
|
|
|
48
|
|
|
$this->repo->getModel()->fill($attributes); |
|
49
|
|
|
$this->repo->getModel()->save(); |
|
50
|
|
|
|
|
51
|
|
|
return $this->repo->getModel(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function updateById(array $attributes, $productId, $id) |
|
55
|
|
|
{ |
|
56
|
|
|
$model = $this->find($id); |
|
57
|
|
|
$attributes['product_id'] = $productId; |
|
58
|
|
|
$attributes['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
|
|
|
|
|
|
59
|
|
|
$validator = \Validator::make($attributes, $this->rules($id)); |
|
60
|
|
|
|
|
61
|
|
|
if ($validator->fails()) { |
|
62
|
|
|
return $validator; |
|
63
|
|
|
} |
|
64
|
|
|
$attributes['modified_by_user_id'] = auth('hideyobackend')->user()->id; |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$model->fill($attributes); |
|
68
|
|
|
$model->save(); |
|
69
|
|
|
|
|
70
|
|
|
return $model; |
|
71
|
|
|
} |
|
72
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths