Passed
Push — master ( 611578...f9e565 )
by Stephen
02:59 queued 11s
created

People::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sfneal\Testing\Models;
4
5
use Database\Factories\PeopleFactory;
6
use Illuminate\Database\Eloquent\Builder;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
use Sfneal\Builders\QueryBuilder;
9
use Sfneal\Models\Model;
10
11
class People extends Model
12
{
13
    use HasFactory;
14
15
    /**
16
     * The attributes that should be mutated to dates.
17
     *
18
     * @var array
19
     */
20
    protected $dates = ['deleted_at', 'updated_at', 'created_at'];
21
22
    protected $table = 'people';
23
    protected $primaryKey = 'person_id';
24
25
    protected $fillable = [
26
        'person_id',
27
        'name_first',
28
        'name_last',
29
        'email',
30
        'age',
31
    ];
32
33
    /**
34
     * Model Factory.
35
     *
36
     * @return PeopleFactory
37
     */
38
    protected static function newFactory(): PeopleFactory
39
    {
40
        return new PeopleFactory();
41
    }
42
43
    /**
44
     * Query Builder.
45
     *
46
     * @param $query
47
     * @return QueryBuilder
48
     */
49
    public function newEloquentBuilder($query)
50
    {
51
        return new QueryBuilder($query);
52
    }
53
54
    /**
55
     * Query Builder method for improved type hinting.
56
     *
57
     * @return QueryBuilder|Builder
58
     */
59
    public static function query()
60
    {
61
        return parent::query();
62
    }
63
64
    public function getNameFullAttribute(): string
65
    {
66
        return "{$this->name_first} {$this->name_last}";
0 ignored issues
show
Bug introduced by
The property name_first does not seem to exist on Sfneal\Testing\Models\People. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property name_last does not seem to exist on Sfneal\Testing\Models\People. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
67
    }
68
69
    public function getNameLastFirstAttribute(): string
70
    {
71
        return "{$this->name_last}, {$this->name_first}";
0 ignored issues
show
Bug introduced by
The property name_last does not seem to exist on Sfneal\Testing\Models\People. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property name_first does not seem to exist on Sfneal\Testing\Models\People. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
72
    }
73
74
    public function getAgeAttribute($value): int
75
    {
76
        return intval($value);
77
    }
78
}
79