transactionJournals()->count(); } /** * @return Collection */ public function get() { return TransactionCurrency::get(); } /** * @param Preference $preference * * @return TransactionCurrency */ public function getCurrencyByPreference(Preference $preference) { $preferred = TransactionCurrency::whereCode($preference->data)->first(); if (is_null($preferred)) { $preferred = TransactionCurrency::first(); } return $preferred; } /** * @param array $data * * @return TransactionCurrency */ public function store(array $data) { $currency = TransactionCurrency::create( [ 'name' => $data['name'], 'code' => $data['code'], 'symbol' => $data['symbol'], ] ); return $currency; } /** * @param TransactionCurrency $currency * @param array $data * * @return TransactionCurrency */ public function update(TransactionCurrency $currency, array $data) { $currency->code = $data['code']; $currency->symbol = $data['symbol']; $currency->name = $data['name']; $currency->save(); return $currency; } }