MyriadOrder::agentContact()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
namespace MyriadDataStore\Models;
3
4
use Illuminate\Database\Eloquent\Model;
5
use Illuminate\Database\Eloquent\Relations\BelongsTo;
6
use Illuminate\Database\Eloquent\Relations\HasMany;
7
use MyriadDataStore\MyriadDataDownloader;
8
9
/**
10
 * @property \JsonFieldCast\Json\SimpleJsonField $details
11
 */
12
class MyriadOrder extends Model
13
{
14
    public $incrementing = false;
15
16
    protected $guarded = [];
17
18
    protected $casts = [
19
        'details'    => \JsonFieldCast\Casts\SimpleJsonField::class,
20
        'order_date' => 'date',
21
    ];
22
23 3
    public function getTable(): string
24
    {
25 3
        return config('myriad-data-store.tables.orders');
26
    }
27
28
    public function getNameAttribute(): string
29
    {
30
        return $this->order_date?->format('jS F Y') ?? '-';
0 ignored issues
show
Bug introduced by
The property order_date does not seem to exist on MyriadDataStore\Models\MyriadOrder. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
31
    }
32
33 3
    public function packages(): HasMany
34
    {
35 3
        return $this->hasMany(MyriadOrderPackage::class, 'order_id', 'id');
36
    }
37
38
    public function despatchContact(): BelongsTo
39
    {
40
        return $this->belongsTo(MyriadDataDownloader::$contactModel, 'despatch_contact_id', 'id');
41
    }
42
43
    public function invoiceContact(): BelongsTo
44
    {
45
        return $this->belongsTo(MyriadDataDownloader::$contactModel, 'invoice_contact_id', 'id');
46
    }
47
48
    public function agentContact(): BelongsTo
49
    {
50
        return $this->belongsTo(MyriadDataDownloader::$contactModel, 'agent_contact_id', 'id');
51
    }
52
}
53