Completed
Push — develop ( 6deca1...bf40a6 )
by Adolfo
01:08
created

PlanFeature::make()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
4
namespace Sagitarius29\LaravelSubscriptions\Entities;
5
6
7
use Illuminate\Database\Eloquent\Model;
8
use Sagitarius29\LaravelSubscriptions\Contracts\PlanFeatureContract;
9
10
class PlanFeature extends Model implements PlanFeatureContract
11
{
12
    protected $table = 'plan_features';
13
14
    protected $fillable = [
15
        'code', 'value', 'sort_order', 'is_consumable'
16
    ];
17
18
    public function plan()
19
    {
20
        return $this->belongsTo(config('subscription.entities.plan'));
21
    }
22
23
    public function isConsumable(): bool
24
    {
25
        return $this->is_consumable;
26
    }
27
28
    public function getValue(): int
29
    {
30
        return $this->value;
31
    }
32
33
    public static function make(string $code, int $value, int $sortOrder, bool $isConsumable = false): Model
34
    {
35
        $attributes = [
36
            'code'          => $code,
37
            'value'         => $value,
38
            'sort_order'    => $sortOrder,
39
            'is_consumable' => $isConsumable,
40
        ];
41
42
        return new self($attributes);
43
    }
44
}
45