MyriadOrder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 39
ccs 4
cts 12
cp 0.3333
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A packages() 0 3 1
A agentContact() 0 3 1
A getNameAttribute() 0 3 1
A invoiceContact() 0 3 1
A getTable() 0 3 1
A despatchContact() 0 3 1
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