model helper

Posted 2 years ago by jaheller

What's the best way to store a function like for example this (like an Accessor):

public function getTotalInvestmentsAttribute($id)
        return number_format( (Transaction::where('currency_id', $this->id)->sum('amount') / 100000000 ), 2, '.', '' );

Inside my blade view I would like to call:


to save a lot of code inside my view itself.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.