database/seeders/PaymentSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        $purpose = ['school fees', 'add and drop', 'hostel accommodation', 'exam card'];
        $amount = [1000, 5000, 40000, 1600];
        for ($i=0; $i < 2000; $i++) { 
            Payment::create([
                'user_id' => random_int(2, User::all()->count()),
                'purpose' => $purpose[array_rand($purpose)],
                'amount' => $amount[array_rand($amount)],
                'reference' => Str::random(10),
                'date_payed' => Carbon::now()->subYears(random_int(1, 4))->subDays(random_int(2, 50))
            ]);
        }
    }
public function run ( ) { $ purpose = [ 'school fees' , 'add and drop' , 'hostel accommodation' , 'exam card' ] ; $ amount = [ 1000 , 5000 , 40000 , 1600 ] ; for ( $ i = 0 ; $ i < 2000 ; $ i ++ ) { Payment :: create ( [ 'user_id' => random_int ( 2 , User :: all ( ) -> count ( ) ) , 'purpose' => $ purpose [ array_rand ( $ purpose ) ] , 'amount' => $ amount [ array_rand ( $ amount ) ] , 'reference' => Str :: random ( 10 ) , 'date_payed' => Carbon :: now ( ) -> subYears ( random_int ( 1 , 4 ) ) -> subDays ( random_int ( 2 , 50 ) ) ] ) ; } }
Run the database seeds.
Run the database seeds .