public function latestPayments() { $this->_fetchLastInvoice(); $q = APTransaction::where('type', 'cr')->where('user_id', $this->account->id)->where('created_at', '<', $this->generated_on)->select(DB::raw('sum(amount) as amount')); if ($this->lastInvoice != NULL) { $q->where('created_at', '>', $this->lastInvoice->generated_on); } $payment = $q->first(); $amount = $payment->amount ?: 0; return number_format((double) $amount, 2, '.', ''); }
public function getTransactions($user_id) { $profile = Subscriber::findOrFail($user_id); $txns = APTransaction::where('user_id', $user_id)->orderby('created_at', 'DESC')->paginate(10); $view = View::make('admin.accounts.ap-transactions', ['txns' => $txns, 'profile' => $profile]); $ap_settings = APUserSetting::where('user_id', $user_id)->first(); if ($ap_settings != NULL) { $view->with('ap_settings', $ap_settings); } return $view; }