Passed
Push — master ( 522ba7...dac3f8 )
by Andrey
13:44
created

BaseModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A scopeSearchBy() 0 5 1
1
<?php
2
3
namespace Helldar\Roles\Models;
4
5
use Helldar\Roles\Facades\Config;
6
use Helldar\Roles\Traits\Searchable;
7
use Helldar\Roles\Traits\SetAttribute;
8
use Illuminate\Database\Eloquent\Builder;
9
use Illuminate\Database\Eloquent\Model;
10
11
/**
12
 * @property int $id
13
 * @property string $name
14
 *
15
 * @method static \Illuminate\Database\Eloquent\Model|self create(array $values)
16
 * @method static \Illuminate\Database\Eloquent\Builder|self searchBy(string $value)
17
 */
18
abstract class BaseModel extends Model
19
{
20
    use SetAttribute;
21
    use Searchable;
22
23
    public $timestamps = false;
24
25 42
    protected $fillable = ['name'];
26
27 42
    public function __construct(array $attributes = [])
28 42
    {
29
        $this->setConnection(
30
            Config::connection()
31 42
        );
32 42
33
        parent::__construct($attributes);
34
    }
35
36
    protected function scopeSearchBy(Builder $builder, string $value)
37
    {
38
        return $builder
39
            ->where('id', $value)
40
            ->orWhere('name', $value);
41
    }
42
}
43