/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); for ($i = 0; $i < 500; $i++) { $types = array('Ingreso', 'Egreso'); $categories = array(1, 2, 3); Transaction::create(array('account_id' => '1', 'date' => $faker->dateTimeThisYear($max = 'now'), 'type' => $types[array_rand($types)], 'category_id' => $categories[array_rand($categories)], 'amount' => $faker->randomFloat(3, 2), 'user_id' => '1')); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Transaction::create(['type' => $request->get('type'), 'date' => $request->get('date'), 'account_id' => $request->get('account'), 'category_id' => $request->get('category'), 'subcategory_id' => $request->get('subcategory'), 'entity_id' => $request->get('entity'), 'amount' => $request->get('amount'), 'notes' => $request->get('notes'), 'user_id' => Auth::user()->id]); return redirect()->route('transactions.index'); }