/**
  * 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'));
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $transaction = Transaction::findOrFail($id);
     $transaction->delete();
     $message = 'Transaction #' . $transaction->id . ' was deleted successfully!';
     if ($request->ajax()) {
         return response()->json(['id' => $transaction->id, 'message' => $message]);
     }
     Session::flash('message', $message);
     return redirect()->route('transactions.index');
 }
Exemple #3
0
 public static function filterAndPaginate($id, $user_id)
 {
     return Transaction::id($id)->where('user_id', $user_id)->orderBy('id', 'DESC')->paginate(50);
 }