Exemplo n.º 1
0
 public function details($id)
 {
     $currencyController = new CurrencyController();
     $data = array('pageTitle' => 'Income', 'secondaryCurrencyMoney' => $currencyController->convert(\Auth::user()->currentMoney, \Auth::user()->mainCurrency, \Auth::user()->secondaryCurrency));
     $incomes = \DB::table('pemasukan')->where('id', $id)->where('idUser', \Auth::user()->id)->get();
     foreach ($incomes as $income) {
         $date = Carbon::parse($income->nextPayment);
         if ($income->frequency == "monthly") {
             while ($date->isPast()) {
                 $date->addMonth();
             }
         } elseif ($income->frequency = "daily") {
             while ($date->isPast()) {
                 $date->addDay();
             }
         }
         $nextPayment[$income->id] = $date->toFormattedDateString();
     }
     return \View::make('income.details')->with('data', $data)->with('incomes', $incomes)->with('nextPayment', $nextPayment);
 }
Exemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $currencyController = new CurrencyController();
     $data = array('pageTitle' => 'Spending', 'secondaryCurrencyMoney' => $currencyController->convert(\Auth::user()->currentMoney, \Auth::user()->mainCurrency, \Auth::user()->secondaryCurrency));
     $spendings = \DB::table('pengeluaran')->where('idUser', \Auth::user()->id)->get();
     $nextPayment = array();
     // $nextPayment = array();
     foreach ($spendings as $spending) {
         $date = Carbon::parse($spending->nextPayment);
         if ($spending->frequency == "monthly") {
             while ($date->isPast()) {
                 $date->addMonth();
             }
         } elseif ($spending->frequency = "daily") {
             while ($date->isPast()) {
                 $date->addDay();
             }
         }
         $nextPayment[$spending->id] = $date->toFormattedDateString();
     }
     return \View::make('spending.spending')->with('data', $data)->with('spendings', $spendings)->with('nextPayment', $nextPayment);
 }