Passed
Push — MODEL_LIB_240928 ( 143dd3...d1103d )
by Rafael
57:04 queued 21s
created

Expedition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 68
c 1
b 0
f 0
dl 0
loc 87
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A c_shipment_mode() 0 3 1
A expeditiondets() 0 3 1
A societe() 0 3 1
A user() 0 3 1
1
<?php
2
3
/* Copyright (C) 2024       Rafael San José         <[email protected]>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace Dolibarr\Code\Expedition\Model;
20
21
use Carbon\Carbon;
22
use Dolibarr\Code\Societe\Model\Societe;
23
use Dolibarr\Code\UserGroup\Model\User;
24
use Dolibarr\Core\Base\Model;
25
use Dolibarr\Core\Model\CShipmentMode;
26
use Illuminate\Database\Eloquent\Collection;
27
28
/**
29
 * Class Expedition
30
 *
31
 * @property int $rowid
32
 * @property Carbon|null $tms
33
 * @property string $ref
34
 * @property int $entity
35
 * @property int $fk_soc
36
 * @property int|null $fk_projet
37
 * @property string|null $ref_ext
38
 * @property string|null $ref_customer
39
 * @property Carbon|null $date_creation
40
 * @property int|null $fk_user_author
41
 * @property int|null $fk_user_modif
42
 * @property Carbon|null $date_valid
43
 * @property int|null $fk_user_valid
44
 * @property Carbon|null $date_delivery
45
 * @property Carbon|null $date_expedition
46
 * @property int|null $fk_address
47
 * @property int|null $fk_shipping_method
48
 * @property string|null $tracking_number
49
 * @property int|null $fk_statut
50
 * @property int|null $billed
51
 * @property float|null $height
52
 * @property float|null $width
53
 * @property int|null $size_units
54
 * @property float|null $size
55
 * @property int|null $weight_units
56
 * @property float|null $weight
57
 * @property int|null $signed_status
58
 * @property string|null $online_sign_ip
59
 * @property string|null $online_sign_name
60
 * @property string|null $note_private
61
 * @property string|null $note_public
62
 * @property string|null $model_pdf
63
 * @property string|null $last_main_doc
64
 * @property int|null $fk_incoterms
65
 * @property string|null $location_incoterms
66
 * @property string|null $import_key
67
 * @property string|null $extraparams
68
 *
69
 * @property CShipmentMode|null $c_shipment_mode
70
 * @property Societe $societe
71
 * @property User|null $user
72
 * @property Collection|Expeditiondet[] $expeditiondets
73
 */
74
class Expedition extends Model
75
{
76
    public $timestamps = false;
77
    protected $table = 'expedition';
78
    protected $casts = [
79
        'tms' => 'datetime',
80
        'entity' => 'int',
81
        'fk_soc' => 'int',
82
        'fk_projet' => 'int',
83
        'date_creation' => 'datetime',
84
        'fk_user_author' => 'int',
85
        'fk_user_modif' => 'int',
86
        'date_valid' => 'datetime',
87
        'fk_user_valid' => 'int',
88
        'date_delivery' => 'datetime',
89
        'date_expedition' => 'datetime',
90
        'fk_address' => 'int',
91
        'fk_shipping_method' => 'int',
92
        'fk_statut' => 'int',
93
        'billed' => 'int',
94
        'height' => 'float',
95
        'width' => 'float',
96
        'size_units' => 'int',
97
        'size' => 'float',
98
        'weight_units' => 'int',
99
        'weight' => 'float',
100
        'signed_status' => 'int',
101
        'fk_incoterms' => 'int'
102
    ];
103
104
    protected $fillable = [
105
        'tms',
106
        'ref',
107
        'entity',
108
        'fk_soc',
109
        'fk_projet',
110
        'ref_ext',
111
        'ref_customer',
112
        'date_creation',
113
        'fk_user_author',
114
        'fk_user_modif',
115
        'date_valid',
116
        'fk_user_valid',
117
        'date_delivery',
118
        'date_expedition',
119
        'fk_address',
120
        'fk_shipping_method',
121
        'tracking_number',
122
        'fk_statut',
123
        'billed',
124
        'height',
125
        'width',
126
        'size_units',
127
        'size',
128
        'weight_units',
129
        'weight',
130
        'signed_status',
131
        'online_sign_ip',
132
        'online_sign_name',
133
        'note_private',
134
        'note_public',
135
        'model_pdf',
136
        'last_main_doc',
137
        'fk_incoterms',
138
        'location_incoterms',
139
        'import_key',
140
        'extraparams'
141
    ];
142
143
    public function c_shipment_mode()
144
    {
145
        return $this->belongsTo(CShipmentMode::class, 'fk_shipping_method');
146
    }
147
148
    public function societe()
149
    {
150
        return $this->belongsTo(Societe::class, 'fk_soc');
151
    }
152
153
    public function user()
154
    {
155
        return $this->belongsTo(User::class, 'fk_user_valid');
156
    }
157
158
    public function expeditiondets()
159
    {
160
        return $this->hasMany(Expeditiondet::class, 'fk_expedition');
161
    }
162
}
163