mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-22 14:27:42 +01:00
84 lines
2.3 KiB
PHP
84 lines
2.3 KiB
PHP
<?php
|
|
/*
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
* Copyright (C) DevCode s.r.l.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace App\OSM\Prints;
|
|
|
|
use App\OSM\ComponentManagerTrait;
|
|
use Common\Model;
|
|
use Common\SimpleModelTrait;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Models\Group;
|
|
use Models\Module;
|
|
use Traits\LocalPoolTrait;
|
|
|
|
class Template extends Model
|
|
{
|
|
use SimpleModelTrait;
|
|
use LocalPoolTrait;
|
|
use ComponentManagerTrait;
|
|
|
|
protected $table = 'zz_prints';
|
|
protected $main_folder = 'templates';
|
|
|
|
// Attributi Eloquent
|
|
|
|
/**
|
|
* Restituisce un array associativo dalla codifica JSON delle opzioni di stampa.
|
|
*
|
|
* @param string $string
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getOptionsAttribute()
|
|
{
|
|
// Fix per contenuti con newline integrate
|
|
$string = str_replace(["\n", "\r"], ['\\n', '\\r'], $this->options);
|
|
|
|
$result = (array) json_decode($string, true);
|
|
|
|
return $result;
|
|
}
|
|
|
|
/* Relazioni Eloquent */
|
|
|
|
public function module()
|
|
{
|
|
return $this->belongsTo(Module::class, 'id_module');
|
|
}
|
|
|
|
/*
|
|
public function groups()
|
|
{
|
|
return $this->morphToMany(Group::class, 'permission', 'zz_permissions', 'external_id', 'group_id')->where('permission_level', '!=', '-')->withPivot('permission_level');
|
|
}*/
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::addGlobalScope('enabled', function (Builder $builder) {
|
|
$builder->where('enabled', true);
|
|
});
|
|
|
|
static::addGlobalScope('permission', function (Builder $builder) {
|
|
//$builder->with('groups');
|
|
});
|
|
}
|
|
}
|