|
| 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