} catch (PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } } public static function type_translate($type) { if ($type == "cash_in") { return "Insättning"; } elseif ($type == "cash_out") { return "Uttag"; } elseif ($type == "bonus") { return "Bonus"; } elseif ($type == "correction") { return "Rättelse"; } } } if (isset($_GET['c']) && $_GET['c'] == "create") { $transaction = new transaction(); $transaction->account_id = $_POST['account_id']; $transaction->type = $_POST['type']; $transaction->amount = $_POST['amount']; $transaction->datetime = $_POST['datetime']; $transaction->comment = $_POST['comment']; $id = $transaction->create(); return $id; } elseif (isset($_GET['c']) && $_GET['c'] == "all") { $transactions = transaction::all(); echo json_encode($transactions); exit; }
public function loadBank() { /* athan */ $btransaction = transaction::all()->take(8); return response()->success(compact('btransaction')); }