Adjustment   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A adjustable() 0 4 1
1
<?php
2
3
namespace Mangopixel\Adjuster;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
8
/**
9
 * An Eloquent model used to represent an adjustment made to another model. If you want to
10
 * make any modifications to the model, you can extend it or create your own model from
11
 * scratch. Just make sure to update the adjustable_model key in the configurations.
12
 *
13
 * @package Laravel Adjuster
14
 * @author  Alexander Tømmerås <[email protected]>
15
 * @license The MIT License
16
 */
17
class Adjustment extends Model
18
{
19
    /**
20
     * The attributes that should be cast to native types.
21
     *
22
     * @var array
23
     */
24
    protected $casts = [
25
        'changes' => 'array'
26
    ];
27
28
    /**
29
     * The attributes that aren't mass assignable.
30
     *
31
     * @var array
32
     */
33
    protected $guarded = [
34
        'adjustable_id',
35
        'adjustable_type'
36
    ];
37
38
    /**
39
     * Indicates if the model should be timestamped.
40
     *
41
     * @var bool
42
     */
43
    public $timestamps = false;
44
45
    /**
46
     * Get the adjustable model associated with the adjustment.
47
     *
48
     * @return MorphTo
49
     */
50
    public function adjustable():MorphTo
51
    {
52
        return $this->morphTo( config( 'adjuster.adjustable_column' ) );
53
    }
54
}