Passed
Pull Request — master (#11)
by Fatih
04:10
created

BaseModel::lines()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace NeptuneSoftware\Invoice\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class BaseModel extends Model
9
{
10
11
    use SoftDeletes;
12
13
    /**
14
     * The attributes that are mass assignable.
15
     *
16
     * @var array
17
     */
18
    protected $fillable = [
19
        'related_id', 'related_type', 'tax',  'total', 'discount', 'currency',
20
        'reference', 'status', 'receiver_info', 'sender_info', 'payment_info', 'note', 'is_bill'
21
    ];
22
23
    protected $guarded = [];
24
25
    public $incrementing = false;
26
27
    /**
28
     * Get the invoice lines for this invoice
29
     */
30 36
    public function lines()
31
    {
32 36
        return $this->hasMany(InvoiceLine::class, 'invoice_id');
33
    }
34
35
    /**
36
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
37
     */
38 2
    public function related()
39
    {
40 2
        return $this->morphTo();
41
    }
42
43
}
44