Skip to content

Commit 49c79f6

Browse files
committed
fix: gestione barcode
1 parent ba4feba commit 49c79f6

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

modules/articoli/src/Articolo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ public function dettaglioFornitore($id_fornitore)
410410
->first();
411411
}
412412

413+
public function barcodes()
414+
{
415+
return $this->hasMany(Barcode::class, 'idarticolo');
416+
}
417+
413418
public static function getTranslatedFields()
414419
{
415420
return self::$translated_fields;

modules/articoli/src/Barcode.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
namespace Modules\Articoli;
21+
22+
use Common\SimpleModelTrait;
23+
use Illuminate\Database\Eloquent\Model;
24+
use Traits\RecordTrait;
25+
26+
class Barcode extends Model
27+
{
28+
use SimpleModelTrait;
29+
use RecordTrait;
30+
31+
protected $table = 'mg_articoli_barcode';
32+
33+
protected $fillable = [
34+
'idarticolo',
35+
'barcode',
36+
];
37+
38+
public static function build($idarticolo = null, $barcode = null)
39+
{
40+
$model = new static();
41+
$model->idarticolo = $idarticolo;
42+
$model->barcode = $barcode;
43+
$model->save();
44+
45+
return $model;
46+
}
47+
48+
public function articolo()
49+
{
50+
return $this->belongsTo(Articolo::class, 'idarticolo');
51+
}
52+
53+
public function getModuleAttribute()
54+
{
55+
return 'Articoli';
56+
}
57+
}

0 commit comments

Comments
 (0)