Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Fix scope #189

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Fix scope #189

wants to merge 1 commit into from

Conversation

ruchengtang
Copy link

$this->ofInput('name', $searchData, 'and', true)
    ->ofInput('cellphone', $searchData, 'and', true)
    ->findAll();

Custom base model method:

    /**
     * Search from request input.
     *
     * @param Builder $query
     * @param string $field
     * @param string|array $value
     * @param string $boolean
     * @param bool $like
     *
     * @return Builder
     */
    public function scopeOfInput($query, $field, $value, $boolean = 'and', $like = false)
    {
        if (is_array($value) && !isset($value[$field])) {
            return $query;
        }

        return $this->_where($query, $field, $value[$field], $boolean, $like);
    }

```
$this->ofInput('name', $searchData, 'and', true)
    ->ofInput('cellphone', $searchData, 'and', true)
    ->findAll();
```


Custom base model method:

```
    /**
     * Search from request input.
     *
     * @param Builder $query
     * @param string $field
     * @param string|array $value
     * @param string $boolean
     * @param bool $like
     *
     * @return Builder
     */
    public function scopeOfInput($query, $field, $value, $boolean = 'and', $like = false)
    {
        if (is_array($value) && !isset($value[$field])) {
            return $query;
        }

        return $this->_where($query, $field, $value[$field], $boolean, $like);
    }
```
@codeclimate
Copy link

codeclimate bot commented Mar 6, 2019

Code Climate has analyzed commit 60a37b8 and detected 0 issues on this pull request.

View more on Code Climate.

@Omranic Omranic changed the base branch from master to develop June 1, 2019 10:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant