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
|
|||
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 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.