Passed
Push — MODEL_LIB_240928 ( 74ce72...807d7f )
by Rafael
49:53
created

BomBom::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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
rs 10
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\Bom\Model;
20
21
use Carbon\Carbon;
22
use Dolibarr\Code\UserGroup\Model\User;
23
use Dolibarr\Core\Base\Model;
24
use Illuminate\Database\Eloquent\Collection;
25
26
/**
27
 * Class BomBom
28
 *
29
 * @property int $rowid
30
 * @property int $entity
31
 * @property string $ref
32
 * @property int|null $bomtype
33
 * @property string|null $label
34
 * @property int|null $fk_product
35
 * @property string|null $description
36
 * @property string|null $note_public
37
 * @property string|null $note_private
38
 * @property int|null $fk_warehouse
39
 * @property float|null $qty
40
 * @property float|null $efficiency
41
 * @property float|null $duration
42
 * @property Carbon $date_creation
43
 * @property Carbon|null $date_valid
44
 * @property Carbon|null $tms
45
 * @property int $fk_user_creat
46
 * @property int|null $fk_user_modif
47
 * @property int|null $fk_user_valid
48
 * @property string|null $import_key
49
 * @property string|null $model_pdf
50
 * @property int $status
51
 *
52
 * @property User $user
53
 * @property Collection|BomBomline[] $bom_bomlines
54
 */
55
class BomBom extends Model
56
{
57
    public $timestamps = false;
58
    protected $table = 'bom_bom';
59
    protected $casts = [
60
        'entity' => 'int',
61
        'bomtype' => 'int',
62
        'fk_product' => 'int',
63
        'fk_warehouse' => 'int',
64
        'qty' => 'float',
65
        'efficiency' => 'float',
66
        'duration' => 'float',
67
        'date_creation' => 'datetime',
68
        'date_valid' => 'datetime',
69
        'tms' => 'datetime',
70
        'fk_user_creat' => 'int',
71
        'fk_user_modif' => 'int',
72
        'fk_user_valid' => 'int',
73
        'status' => 'int'
74
    ];
75
76
    protected $fillable = [
77
        'entity',
78
        'ref',
79
        'bomtype',
80
        'label',
81
        'fk_product',
82
        'description',
83
        'note_public',
84
        'note_private',
85
        'fk_warehouse',
86
        'qty',
87
        'efficiency',
88
        'duration',
89
        'date_creation',
90
        'date_valid',
91
        'tms',
92
        'fk_user_creat',
93
        'fk_user_modif',
94
        'fk_user_valid',
95
        'import_key',
96
        'model_pdf',
97
        'status'
98
    ];
99
100
    public function user()
101
    {
102
        return $this->belongsTo(User::class, 'fk_user_creat');
103
    }
104
105
    public function bom_bomlines()
106
    {
107
        return $this->hasMany(BomBomline::class, 'fk_bom');
108
    }
109
}
110