Completed
Push — master ( e68c06...8ce3f9 )
by Adolfo
14s queued 11s
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
namespace Sagitarius29\LaravelSubscriptions\Entities;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Sagitarius29\LaravelSubscriptions\Contracts\PlanFeatureContract;
7
8
class PlanFeature extends Model implements PlanFeatureContract
9
{
10
    protected $table = 'plan_features';
11
12
    protected $fillable = [
13
        'code', 'value', 'sort_order', 'is_consumable',
14
    ];
15
16
    public function plan()
17
    {
18
        return $this->belongsTo(config('subscription.entities.plan'));
19
    }
20
21
    public function isConsumable(): bool
22
    {
23
        return $this->is_consumable;
24
    }
25
26
    public function getValue(): int
27
    {
28
        return $this->value;
29
    }
30
31
    public static function make(string $code, int $value, int $sortOrder, bool $isConsumable = false): Model
32
    {
33
        $attributes = [
34
            'code'          => $code,
35
            'value'         => $value,
36
            'sort_order'    => $sortOrder,
37
            'is_consumable' => $isConsumable,
38
        ];
39
40
        return new self($attributes);
41
    }
42
}
43