currency symbol added to account name
This commit is contained in:
		@@ -18,7 +18,7 @@ class Account extends Model
 | 
			
		||||
     *
 | 
			
		||||
     * @var array
 | 
			
		||||
     */
 | 
			
		||||
    protected $appends = ['balance'];
 | 
			
		||||
    protected $appends = ['balance', 'title'];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attributes that should be mass-assignable.
 | 
			
		||||
@@ -89,6 +89,20 @@ class Account extends Model
 | 
			
		||||
            ->select(['accounts.*', 'accounts.opening_balance as balance']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the name with currency.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function getTitleAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->currency->symbol) {
 | 
			
		||||
            return $this->name . ' (' . $this->currency->symbol . ')';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the current balance.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,18 @@ class Account extends Form
 | 
			
		||||
 | 
			
		||||
    public $accounts;
 | 
			
		||||
 | 
			
		||||
    /** @var bool */
 | 
			
		||||
    public $hideCurrency;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new component instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(bool $hideCurrency = false) {
 | 
			
		||||
        $this->hideCurrency = $hideCurrency;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the view / contents that represent the component.
 | 
			
		||||
     *
 | 
			
		||||
@@ -26,7 +38,7 @@ class Account extends Form
 | 
			
		||||
 | 
			
		||||
        $this->path = route('modals.accounts.create');
 | 
			
		||||
 | 
			
		||||
        $this->accounts = Model::enabled()->orderBy('name')->pluck('name', 'id');
 | 
			
		||||
        $this->accounts = $this->getAccounts();
 | 
			
		||||
 | 
			
		||||
        if (empty($this->selected) && empty($this->getParentData('model'))) {
 | 
			
		||||
            $this->selected = setting('default.account');
 | 
			
		||||
@@ -34,4 +46,13 @@ class Account extends Form
 | 
			
		||||
 | 
			
		||||
        return view('components.form.group.account');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function getAccounts()
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->hideCurrency) {
 | 
			
		||||
            return Model::enabled()->orderBy('name')->pluck('name', 'id');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Model::enabled()->orderBy('name')->get()->pluck('title', 'id');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user