Completed
Pull Request — master (#372)
by Mike
31:01 queued 16:07
created

BookWithUncachedStore   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 55
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A author() 0 4 1
A comments() 0 4 1
A image() 0 4 1
A publisher() 0 4 1
A stores() 0 4 1
A uncachedStores() 0 4 1
A scopeStartsWith() 0 4 1
1
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Fixtures;
2
3
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
4
use Illuminate\Database\Eloquent\Builder;
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Illuminate\Database\Eloquent\Relations\MorphMany;
8
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
9
use Illuminate\Database\Eloquent\Relations\MorphOne;
10
11
class BookWithUncachedStore extends Model
12
{
13
    use Cachable;
14
15
    protected $casts = [
16
        'price' => 'float',
17
    ];
18
    protected $dates = [
19
        'published_at',
20
    ];
21
    protected $fillable = [
22
        "author_id",
23
        'description',
24
        'published_at',
25
        'title',
26
        "publisher_id",
27
        'price',
28
    ];
29
    protected $table = "books";
30
31
    public function author() : BelongsTo
32
    {
33
        return $this->belongsTo(Author::class);
34
    }
35
36
    public function comments() : MorphMany
37
    {
38
        return $this->morphMany(Comment::class, "commentable");
39
    }
40
41
    public function image() : MorphOne
42
    {
43
        return $this->morphOne(Image::class, "imagable");
44
    }
45
46
    public function publisher() : BelongsTo
47
    {
48
        return $this->belongsTo(Publisher::class);
49
    }
50
51
    public function stores() : BelongsToMany
52
    {
53
        return $this->belongsToMany(Store::class);
54
    }
55
56
    public function uncachedStores() : BelongsToMany
57
    {
58
        return $this->belongsToMany(UncachedStore::class, "book_store", "book_id", "store_id");
59
    }
60
61
    public function scopeStartsWith(Builder $query, string $startOfName) : Builder
62
    {
63
        return $query->where("name", "LIKE", "{$startOfName}%");
64
    }
65
}
66