1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hideyo\Ecommerce\Framework\Services\Order; |
4
|
|
|
|
5
|
|
|
use Hideyo\Ecommerce\Framework\Services\Order\Entity\OrderStatusEmailTemplate; |
6
|
|
|
|
7
|
|
|
use Hideyo\Ecommerce\Framework\Services\Order\Entity\OrderStatusEmailTemplateRepository; |
8
|
|
|
use Hideyo\Ecommerce\Framework\Services\BaseService; |
9
|
|
|
use Validator; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class OrderStatusEmailTemplateService extends BaseService |
12
|
|
|
{ |
13
|
|
|
public function __construct(OrderStatusEmailTemplateRepository $orderStatusEmailTemplate) |
14
|
|
|
{ |
15
|
|
|
$this->repo = $orderStatusEmailTemplate; |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The validation rules for the model. |
23
|
|
|
* |
24
|
|
|
* @param integer $id id attribute model |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
private function rules($id = false, $attributes = false) |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$rules = array( |
30
|
|
|
'title' => 'required|unique_with:order_status_email_template, shop_id', |
31
|
|
|
'subject' => 'required', |
32
|
|
|
'content' => 'required' |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
if ($id) { |
|
|
|
|
36
|
|
|
$rules['title'] = 'required|unique_with:order_status_email_template, shop_id,'.$id; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return $rules; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function create(array $attributes) |
43
|
|
|
{ |
44
|
|
|
$attributes['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
|
|
|
|
45
|
|
|
$validator = \Validator::make($attributes, $this->rules()); |
46
|
|
|
|
47
|
|
|
if ($validator->fails()) { |
48
|
|
|
return $validator; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$this->repo->getModel()->fill($attributes); |
52
|
|
|
|
53
|
|
|
$this->repo->getModel()->save(); |
54
|
|
|
|
55
|
|
|
return $this->repo->getModel(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function selectAllByShopId($shopId) { |
59
|
|
|
return $this->repo->selectAllByShopId($shopId); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function updateById(array $attributes, $id) |
63
|
|
|
{ |
64
|
|
|
$attributes['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
|
|
|
|
65
|
|
|
$validator = \Validator::make($attributes, $this->rules($id, $attributes)); |
66
|
|
|
|
67
|
|
|
if ($validator->fails()) { |
68
|
|
|
return $validator; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
$model = $this->find($id); |
73
|
|
|
|
74
|
|
|
$model->fill($attributes); |
75
|
|
|
|
76
|
|
|
$model->save(); |
77
|
|
|
|
78
|
|
|
return $model; |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
} |
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