Adjustment::adjustable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}