Passed
Push — master ( 6da38c...408d25 )
by Andrey
17:24 queued 14:36
created

BaseModel::scopeSearchBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helldar\Roles\Models;
4
5
use Helldar\Roles\Facades\Config;
6
use Helldar\Roles\Facades\Database\Search;
7
use Helldar\Roles\Traits\Searchable;
8
use Helldar\Roles\Traits\SetAttribute;
9
use Illuminate\Database\Eloquent\Builder;
10
use Illuminate\Database\Eloquent\Model;
11
12
/**
13
 * @property int $id
14
 * @property string $name
15
 *
16
 * @method static Model|self create(array $values)
17
 * @method static Builder|self searchBy(string $value)
18
 */
19
abstract class BaseModel extends Model
20
{
21
    use SetAttribute;
22
    use Searchable;
23
24
    public $timestamps = false;
25
26
    protected $fillable = ['name'];
27
28 48
    public function __construct(array $attributes = [])
29
    {
30 48
        $this->setConnection(
31 48
            Config::connection()
32
        );
33
34 48
        parent::__construct($attributes);
35 48
    }
36
37
    /**
38
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
39
     * @param  \Helldar\Roles\Models\BaseModel|int|string  $value
40
     *
41
     * @return \Illuminate\Database\Eloquent\Builder
42
     */
43
    protected function scopeSearchBy(Builder $builder, $value)
44
    {
45
        return Search::by($builder, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Helldar\Roles\Fac...h::by($builder, $value) also could return the type Illuminate\Database\Eloquent\Relations\Relation which is incompatible with the documented return type Illuminate\Database\Eloquent\Builder.
Loading history...
46
    }
47
}
48