1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-10 16:40:52 +01:00
2020-03-09 09:12:41 +01:00

57 lines
1.1 KiB
PHP
Executable File

<?php
namespace Modules\Listini;
use Common\Model;
class Listino extends Model
{
protected $table = 'mg_listini';
public static function build($nome, $percentuale)
{
$model = parent::build();
$model->nome = $nome;
$model->percentuale = $percentuale;
$model->save();
return $model;
}
public function setPercentualeCombinatoAttribute($value)
{
$this->prc_combinato = $value;
}
public function getPercentualeCombinatoAttribute()
{
return $this->prc_combinato;
}
public function setPercentualeAttribute($value)
{
$value = floatval($value);
if (abs($value) > 100) {
$value = ($value > 0) ? 100 : -100;
}
$this->prc_guadagno = $value;
}
public function getPercentualeAttribute()
{
return $this->prc_guadagno;
}
public function save(array $options = [])
{
$combinato = $this->prc_combinato;
if (!empty($combinato)) {
$this->percentuale = parseScontoCombinato($combinato);
}
return parent::save($options);
}
}