AddressBuilder::whereAddressLike()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 7
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Sfneal\Address\Builders;
4
5
use Sfneal\Builders\QueryBuilder;
6
7
class AddressBuilder extends QueryBuilder
8
{
9
    /**
10
     * Scope query results to Address's associated with a particular model.
11
     *
12
     * @param  string  $addressableType
13
     * @param  string  $operator
14
     * @param  string  $boolean
15
     * @return $this
16
     */
17
    public function whereType(string $addressableType, string $operator = '=', string $boolean = 'and'): self
18
    {
19
        $this->where('addressable_type', $operator, $addressableType, $boolean);
20
21
        return $this;
22
    }
23
24
    /**
25
     * Use a 'wildcard' like search to several attributes for a match.
26
     *
27
     * @param  string  $search
28
     * @return $this
29
     */
30
    public function whereAddressLike(string $search): self
31
    {
32
        $this->where(function (self $builder) use ($search) {
33
            $builder->whereLike('address_1', $search);
34
            $builder->orWhereLike('address_2', $search);
35
            $builder->orWhereLike('city', $search);
36
            $builder->orWhereLike('state', $search);
37
            $builder->orWhereLike('zip', $search);
38
        });
39
40
        return $this;
41
    }
42
}
43