Commit 740819d41c8ca39207e25967bb5a61c05ed3d72b
1 parent
3d4c8f83
Images fix
Showing
2 changed files
with
22 additions
and
2 deletions
Show diff stats
common/behaviors/MultipleImgBehavior.php
... | ... | @@ -23,6 +23,13 @@ |
23 | 23 | * @var array |
24 | 24 | */ |
25 | 25 | public $links = []; |
26 | + | |
27 | + /** | |
28 | + * Will be passed to get image and get images queries | |
29 | + * | |
30 | + * @var array | |
31 | + */ | |
32 | + public $conditions = []; | |
26 | 33 | |
27 | 34 | /** |
28 | 35 | * Full namespaced image model |
... | ... | @@ -51,7 +58,12 @@ |
51 | 58 | * @var ActiveRecord $owner |
52 | 59 | */ |
53 | 60 | $owner = $this->owner; |
54 | - return $owner->hasOne($this->model, $this->links); | |
61 | + $query = $owner->hasOne($this->model, $this->links); | |
62 | + $conditions = $this->conditions; | |
63 | + foreach($conditions as $condition) { | |
64 | + $query->andWhere($condition); | |
65 | + } | |
66 | + return $query; | |
55 | 67 | } |
56 | 68 | |
57 | 69 | /** |
... | ... | @@ -65,7 +77,12 @@ |
65 | 77 | * @var ActiveRecord $owner |
66 | 78 | */ |
67 | 79 | $owner = $this->owner; |
68 | - return $owner->hasMany($this->model, $this->links); | |
80 | + $query = $owner->hasMany($this->model, $this->links); | |
81 | + $conditions = $this->conditions; | |
82 | + foreach($conditions as $left => $right) { | |
83 | + $query->andWhere([$left => $right]); | |
84 | + } | |
85 | + return $query; | |
69 | 86 | } |
70 | 87 | |
71 | 88 | /** | ... | ... |
common/modules/product/models/Product.php