|
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\Categories\Model; |
|
20
|
|
|
|
|
21
|
|
|
use Carbon\Carbon; |
|
22
|
|
|
use Dolibarr\Code\Bank\Model\CategorieAccount; |
|
23
|
|
|
use Dolibarr\Code\Comm\Model\Actioncomm; |
|
24
|
|
|
use Dolibarr\Code\Contact\Model\CategorieContact; |
|
25
|
|
|
use Dolibarr\Code\Fourn\Model\CategorieFournisseur; |
|
26
|
|
|
use Dolibarr\Code\KnowledgeManagement\Model\CategorieKnowledgemanagement; |
|
27
|
|
|
use Dolibarr\Code\Members\Model\CategorieMember; |
|
28
|
|
|
use Dolibarr\Code\Product\Model\Product; |
|
29
|
|
|
use Dolibarr\Code\ProductStock\Model\CategorieWarehouse; |
|
30
|
|
|
use Dolibarr\Code\Projet\Model\CategorieProject; |
|
31
|
|
|
use Dolibarr\Code\Societe\Model\Societe; |
|
32
|
|
|
use Dolibarr\Code\Ticket\Model\Ticket; |
|
33
|
|
|
use Dolibarr\Code\UserGroup\Model\User; |
|
34
|
|
|
use Dolibarr\Code\Website\Model\WebsitePage; |
|
35
|
|
|
use Dolibarr\Core\Base\Model; |
|
36
|
|
|
use Dolibarr\Core\Model\ElementCategorie; |
|
37
|
|
|
use Illuminate\Database\Eloquent\Collection; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Class Categorie |
|
41
|
|
|
* |
|
42
|
|
|
* @property int $rowid |
|
43
|
|
|
* @property int $entity |
|
44
|
|
|
* @property int $fk_parent |
|
45
|
|
|
* @property string $label |
|
46
|
|
|
* @property string|null $ref_ext |
|
47
|
|
|
* @property int $type |
|
48
|
|
|
* @property string|null $description |
|
49
|
|
|
* @property string|null $color |
|
50
|
|
|
* @property int|null $position |
|
51
|
|
|
* @property int|null $fk_soc |
|
52
|
|
|
* @property int $visible |
|
53
|
|
|
* @property Carbon|null $date_creation |
|
54
|
|
|
* @property Carbon|null $tms |
|
55
|
|
|
* @property int|null $fk_user_creat |
|
56
|
|
|
* @property int|null $fk_user_modif |
|
57
|
|
|
* @property string|null $import_key |
|
58
|
|
|
* |
|
59
|
|
|
* @property Collection|CategorieAccount[] $categorie_accounts |
|
60
|
|
|
* @property Collection|Actioncomm[] $actioncomms |
|
61
|
|
|
* @property Collection|CategorieContact[] $categorie_contacts |
|
62
|
|
|
* @property Collection|CategorieFournisseur[] $categorie_fournisseurs |
|
63
|
|
|
* @property Collection|CategorieKnowledgemanagement[] $categorie_knowledgemanagements |
|
64
|
|
|
* @property Collection|CategorieLang[] $categorie_langs |
|
65
|
|
|
* @property Collection|CategorieMember[] $categorie_members |
|
66
|
|
|
* @property Collection|Product[] $products |
|
67
|
|
|
* @property Collection|CategorieProject[] $categorie_projects |
|
68
|
|
|
* @property Collection|Societe[] $societes |
|
69
|
|
|
* @property Collection|Ticket[] $tickets |
|
70
|
|
|
* @property Collection|User[] $users |
|
71
|
|
|
* @property Collection|CategorieWarehouse[] $categorie_warehouses |
|
72
|
|
|
* @property Collection|WebsitePage[] $website_pages |
|
73
|
|
|
* @property Collection|ElementCategorie[] $element_categories |
|
74
|
|
|
*/ |
|
75
|
|
|
class Categorie extends Model |
|
76
|
|
|
{ |
|
77
|
|
|
public $timestamps = false; |
|
78
|
|
|
protected $table = 'categorie'; |
|
79
|
|
|
protected $casts = [ |
|
80
|
|
|
'entity' => 'int', |
|
81
|
|
|
'fk_parent' => 'int', |
|
82
|
|
|
'type' => 'int', |
|
83
|
|
|
'position' => 'int', |
|
84
|
|
|
'fk_soc' => 'int', |
|
85
|
|
|
'visible' => 'int', |
|
86
|
|
|
'date_creation' => 'datetime', |
|
87
|
|
|
'tms' => 'datetime', |
|
88
|
|
|
'fk_user_creat' => 'int', |
|
89
|
|
|
'fk_user_modif' => 'int' |
|
90
|
|
|
]; |
|
91
|
|
|
|
|
92
|
|
|
protected $fillable = [ |
|
93
|
|
|
'entity', |
|
94
|
|
|
'fk_parent', |
|
95
|
|
|
'label', |
|
96
|
|
|
'ref_ext', |
|
97
|
|
|
'type', |
|
98
|
|
|
'description', |
|
99
|
|
|
'color', |
|
100
|
|
|
'position', |
|
101
|
|
|
'fk_soc', |
|
102
|
|
|
'visible', |
|
103
|
|
|
'date_creation', |
|
104
|
|
|
'tms', |
|
105
|
|
|
'fk_user_creat', |
|
106
|
|
|
'fk_user_modif', |
|
107
|
|
|
'import_key' |
|
108
|
|
|
]; |
|
109
|
|
|
|
|
110
|
|
|
public function categorie_accounts() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->hasMany(CategorieAccount::class, 'fk_categorie'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function actioncomms() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->belongsToMany(Actioncomm::class, 'alx_categorie_actioncomm', 'fk_categorie', 'fk_actioncomm') |
|
118
|
|
|
->withPivot('import_key'); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function categorie_contacts() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->hasMany(CategorieContact::class, 'fk_categorie'); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function categorie_fournisseurs() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->hasMany(CategorieFournisseur::class, 'fk_categorie'); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function categorie_knowledgemanagements() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->hasMany(CategorieKnowledgemanagement::class, 'fk_categorie'); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function categorie_langs() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->hasMany(CategorieLang::class, 'fk_category'); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function categorie_members() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->hasMany(CategorieMember::class, 'fk_categorie'); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function products() |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->belongsToMany(Product::class, 'alx_categorie_product', 'fk_categorie', 'fk_product') |
|
149
|
|
|
->withPivot('import_key'); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function categorie_projects() |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->hasMany(CategorieProject::class, 'fk_categorie'); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function societes() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->belongsToMany(Societe::class, 'alx_categorie_societe', 'fk_categorie', 'fk_soc') |
|
160
|
|
|
->withPivot('import_key'); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function tickets() |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->belongsToMany(Ticket::class, 'alx_categorie_ticket', 'fk_categorie', 'fk_ticket') |
|
166
|
|
|
->withPivot('import_key'); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function users() |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->belongsToMany(User::class, 'alx_categorie_user', 'fk_categorie', 'fk_user') |
|
172
|
|
|
->withPivot('import_key'); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public function categorie_warehouses() |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->hasMany(CategorieWarehouse::class, 'fk_categorie'); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
public function website_pages() |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->belongsToMany(WebsitePage::class, 'alx_categorie_website_page', 'fk_categorie', 'fk_website_page') |
|
183
|
|
|
->withPivot('import_key'); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
public function element_categories() |
|
187
|
|
|
{ |
|
188
|
|
|
return $this->hasMany(ElementCategorie::class, 'fk_categorie'); |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|