/** * Run the database seeds. * * @return void */ public function run() { DebtType::create(['id' => 1, 'desc' => 'Credit Card', 'icon' => 'fa-credit-card']); DebtType::create(['id' => 2, 'desc' => 'Mortgage', 'icon' => 'fa-home']); DebtType::create(['id' => 3, 'desc' => 'Line of Credit', 'icon' => 'fa-line-chart']); DebtType::create(['id' => 4, 'desc' => 'Loan', 'icon' => 'fa-money']); }
public function get_user_debts($user_id) { if ($user = User::find($user_id)) { $debts = $user->debts; for ($i = 0; $i < count($debts); $i++) { $debts[$i]->type = DebtType::find($debts[$i]->type); } return response()->json(['response' => 'success', 'found' => true, 'accounts' => $user->debts]); } else { return response()->json(['response' => 'success', 'found' => false]); } }
public function debts() { return response()->json(['response' => 'success', 'types' => DebtType::all()]); }