/** * Run the database seeds. * * @return void */ public function run() { Frequency::create(['id' => 1, 'desc' => 'Weekly']); Frequency::create(['id' => 2, 'desc' => 'Bi-Weekly']); Frequency::create(['id' => 3, 'desc' => 'Semi-Weekly']); Frequency::create(['id' => 4, 'desc' => 'Monthly']); Frequency::create(['id' => 5, 'desc' => 'Bi-Monthly']); Frequency::create(['id' => 6, 'desc' => 'Quarterly']); Frequency::create(['id' => 7, 'desc' => 'Annually']); }
public function get_user_income($user_id) { if ($user = User::find($user_id)) { $income = $user->income; for ($i = 0; $i < count($income); $i++) { $income[$i]->frequency = Frequency::find($income[$i]->frequency); } return response()->json(['response' => 'success', 'found' => true, 'accounts' => $user->income]); } else { return response()->json(['response' => 'success', 'found' => false]); } }
public function frequencies() { return response()->json(['response' => 'success', 'types' => Frequency::all()]); }