Feature::scopeForBucket()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace A17\Twill\Models;
4
5
use Illuminate\Database\Eloquent\Model as BaseModel;
6
7
class Feature extends BaseModel
8
{
9
    protected $fillable = [
10
        'featured_id',
11
        'featured_type',
12
        'position',
13
        'bucket_key',
14
        'starred',
15
    ];
16
17
    public function featured()
18
    {
19
        return $this->morphTo();
20
    }
21
22
    public function scopeForBucket($query, $bucketKey)
23
    {
24
        return $query->where('bucket_key', $bucketKey)->get()->map(function ($feature) {
25
            return $feature->featured;
26
        })->filter();
27
    }
28
29
    public function getTable()
30
    {
31
        return config('twill.features_table', 'twill_features');
32
    }
33
34
}
35