This commit is contained in:
denisdulici
2018-04-16 19:01:29 +03:00
parent 7897300cb8
commit d2b0a816e3
12 changed files with 130 additions and 41 deletions

View File

@ -9,6 +9,13 @@ class Tax extends Model
protected $table = 'taxes';
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['title'];
/**
* Attributes that should be mass-assignable.
*
@ -48,4 +55,24 @@ class Tax extends Model
{
$this->attributes['rate'] = (double) $value;
}
/**
* Get the name including rate.
*
* @return string
*/
public function getTitleAttribute()
{
$title = $this->name . ' (';
if (setting('general.percent_position', 'after') == 'after') {
$title .= $this->rate . '%';
} else {
$title .= '%' . $this->rate;
}
$title .= ')';
return $title;
}
}