Skip to content

Commit b6326c5

Browse files
authored
Merge pull request #82 from SneherAdor/patch-1
Added whereMeta scope in Metable.php
2 parents bd6eb21 + 8b94deb commit b6326c5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Kodeine/Metable/Metable.php

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ trait Metable
1313
// Static property registration sigleton for save observation and slow large set hotfix
1414
public static $_isObserverRegistered;
1515
public static $_columnNames;
16+
17+
/**
18+
* whereMeta scope for easier join
19+
* -------------------------
20+
*/
21+
public function scopeWhereMeta($query, $key, $value, $alias = null)
22+
{
23+
$alias = (empty($alias)) ? $this->getMetaTable() : $alias;
24+
return $query->join($this->getMetaTable() . ' AS ' . $alias, $this->getQualifiedKeyName(), '=', $alias . '.' . $this->getMetaKeyName())->where('key', '=', $key)->where('value', '=', $value)->select($this->getTable() . '.*');
25+
}
1626

1727
/**
1828
* Meta scope for easier join

0 commit comments

Comments
 (0)