Skip to content

Commit

Permalink
Improve function setMoreQuery() for model in view
Browse files Browse the repository at this point in the history
  • Loading branch information
s-cart committed Jul 11, 2023
1 parent 27ec08e commit 1a2bf0e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/Front/Models/ModelTrait.php
Expand Up @@ -43,17 +43,36 @@ public function setSort(array $sort)
return $this;
}


/**
* Add more where
* @param [array] $moreWhere
* NOTE: Will remove in the next versions
*/
public function setMoreWhere(array $moreWhere)
{
if (is_array($moreWhere)) {
return $this->setMoreQuery(['where' => $moreWhere]);
}
return $this;
}



/**
* [setMoreQuery description]
*
* @param string|array $moreQuery [$moreQuery description]
*
* @param array $moreQuery [$moreQuery description]
* EX:
* -- setMoreQuery(['where' => ['columnA','>',12]])
* -- setMoreQuery(['orderBy' => ['columnA','asc']])
*
* @return [type] [return description]
*/

public function setMoreQuery($moreQuery)
public function setMoreQuery(array $moreQuery)
{
if (is_string($moreQuery) || is_array($moreQuery)) {
if (is_array($moreQuery)) {
$this->sc_moreQuery[] = $moreQuery;
}
return $this;
Expand All @@ -69,9 +88,6 @@ public function setMoreQuery($moreQuery)
public function processMoreQuery($query) {
if (count($this->sc_moreQuery)) {
foreach ($this->sc_moreQuery as $key => $where) {
if (is_string($where)) {
$query = $query->whereRaw($where);
}
if (is_array($where) && count($where) == 1) {
foreach ($where as $ope => $obj) {
if (!is_numeric($ope) && is_array($obj)) {
Expand Down

0 comments on commit 1a2bf0e

Please sign in to comment.