public function run()
 {
     DB::table('suppliers')->delete();
     DB::table('categories')->delete();
     $categories = [['slug' => 'otomotif', 'name' => 'Otomotif'], ['slug' => 't-shirt', 'name' => 'T-Shirt', 'childs' => [['slug' => 'woman', 'name' => 'Woman'], ['slug' => 'man', 'name' => 'Man']]], ['slug' => 'electronic', 'name' => 'Electronic', 'childs' => [['slug' => 'laptop', 'name' => 'Laptop'], ['slug' => 'handphone', 'name' => 'Handphone']]]];
     $categories = collect($categories)->map(function ($cat) {
         $category = App\Models\Category::create(['slug' => $cat['slug'], 'name' => $cat['name']]);
         if (array_key_exists('childs', $cat)) {
             foreach ($cat['childs'] as $cate) {
                 App\Models\Category::create(['slug' => $cat['slug'], 'name' => $cat['name'], 'parent_id' => $category->id]);
             }
         }
         return $category;
     });
     $users = App\Models\User::all();
     $users->each(function ($user) use($categories) {
         $suppliers = factory(App\Models\Supplier::class, 10)->create();
         $suppliers->each(function ($supplier) use($categories, $user) {
             $supplier->users()->attach($user);
             $cat_ids = $categories->pluck('id');
             $cat_pick = $cat_ids->random();
             factory(App\Models\Product::class, 15)->create(['supplier_id' => $supplier->id, 'category_id' => $cat_pick]);
         });
     });
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     App\Models\Question::truncate();
     $users = App\Models\User::all();
     factory('App\\Models\\Question', 200)->create()->each(function ($question) use($users) {
         $question->user()->associate($users->random())->save();
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $adminIds = App\Models\User::all()->where('is_admin', 1)->lists('id');
     //echo('Investor Ids');
     //var_dump($investorIds);
     foreach ($adminIds as $id) {
         //factory('App\Models\Investor', $id)->create();
         Admin::create(['user_id' => $id, 'fname' => $faker->firstName, 'lname' => $faker->lastName, 'home_street' => $faker->streetAddress, 'home_city' => $faker->city, 'home_state' => $faker->state, 'home_zip' => $faker->postcode, 'home_phone' => $faker->phoneNumber, 'security_level' => $faker->numberBetween($min = 5, $max = 15)]);
     }
 }
Beispiel #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     try {
         // DB::table('osu_favouritemaps')->delete();
         // DB::table('osu_user_beatmap_playcount')->delete();
         // DB::table('osu_leaders')->delete();
         $allusers = App\Models\User::all()->toArray();
         $userids = [];
         for ($ct = 0; $ct < count($allusers); $ct++) {
             $userids[] = $allusers[$ct]['user_id'];
         }
         // FAVOURITE BEATMAPS AND BEATMAP PLAYCOUNTS FOR EACH USER
         foreach (App\Models\User::all() as $usr) {
             $bms = $usr->scoresBestOsu()->get();
             if (count($bms) < 1) {
                 $this->command->info('Can\'t seed favourite maps, map playcounts or leaders due to having no beatmap data.');
                 return;
             }
             $usr_id = $usr->user_id;
             foreach ($bms as $bm) {
                 DB::table('osu_favouritemaps')->where('user_id', $usr_id)->where('beatmapset_id', $bm['beatmapset_id'])->delete();
                 $fav = new App\Models\FavouriteBeatmapSet();
                 $fav->beatmapset_id = $bm['beatmapset_id'];
                 $fav->user_id = $usr_id;
                 $fav->save();
                 // Add a random couple few first place ranks
                 $bm = $bms[rand(0, count($bms) - 1)];
                 DB::table('osu_user_beatmap_playcount')->where('user_id', $usr_id)->where('beatmap_id', $bm['beatmap_id'])->delete();
                 $playcount = new App\Models\BeatmapPlaycount();
                 $playcount->user_id = $usr_id;
                 $playcount->beatmap_id = $bm['beatmap_id'];
                 $playcount->playcount = rand(0, 1500);
                 $playcount->save();
                 $bm = $bms[rand(0, count($bms) - 1)];
                 if (DB::table('osu_leaders')->where('beatmap_id', $bm['beatmap_id'])->first()) {
                     $bm = $bms[rand(0, count($bms) - 1)];
                     // try once more
                     if (DB::table('osu_leaders')->where('beatmap_id', $bm['beatmap_id'])->first()) {
                         DB::table('osu_leaders')->where('beatmap_id', $bm['beatmap_id'])->delete();
                     }
                 }
                 $leader = new App\Models\BeatmapLeader\Osu();
                 $leader->beatmap_id = $bm['beatmap_id'];
                 $leader->user_id = $usr_id;
                 $leader->score_id = $bm['score_id'];
                 $leader->save();
             }
         }
     } catch (\Illuminate\Database\QueryException $e) {
         $this->command->error("Error: Unable to save User Profile Data\r\n" . $e->getMessage());
     } catch (Exception $ex) {
         $this->command->error("Error: Unable to save User Profile Data\r\n" . $ex->getMessage());
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('subscribes')->truncate();
     $list = collect()->merge(App\Models\Question::all())->merge(App\Models\Tag::all());
     $users = App\Models\User::all();
     $list->each(function ($item) use($users) {
         for ($i = 0, $count = rand(0, 10); $i < $count; $i++) {
             $item->subscribers()->attach($users->random());
         }
     });
 }
Beispiel #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     App\Models\Answer::truncate();
     $users = App\Models\User::all();
     App\Models\Question::all()->each(function ($question) use($users) {
         for ($i = 0, $count = rand(0, 5); $i < $count; $i++) {
             $question->answers()->save($answer = factory('App\\Models\\Answer')->create());
             $question->update(['is_resolved' => $answer->is_solution]);
             $answer->user()->associate($users->random())->save();
         }
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $foundersIds = App\Models\User::all()->where('is_founder', 1)->lists('id');
     //echo('Founder Ids');
     //var_dump($foundersIds);
     foreach ($foundersIds as $id) {
         //factory('App\Models\Investor', $id)->create();
         //TODO: change faker state to country
         Founder::create(['user_id' => $id, 'fname' => $faker->firstName, 'lname' => $faker->lastName, 'company_name' => $faker->company, 'company_street' => $faker->streetAddress, 'company_city' => $faker->city, 'company_state' => $faker->state, 'company_zip' => $faker->postcode, 'company_phone' => $faker->phoneNumber, 'company_industry' => $faker->sentence(), 'company_mktcap' => $faker->numberBetween($min = 1000, $max = 1000000)]);
     }
 }
Beispiel #8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     App\Models\Comment::truncate();
     $list = collect()->merge(App\Models\Question::all())->merge(App\Models\Answer::all());
     $users = App\Models\User::all();
     $list->each(function ($item) use($users) {
         for ($i = 0, $count = rand(0, 5); $i < $count; $i++) {
             $item->comments()->save($comment = factory('App\\Models\\Comment')->create());
             $comment->user()->associate($users->random())->save();
         }
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /*
     [ErrorException]
     Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the
     type array, string given, called in /home/vagrant/group4-project/vendor/laravel/framework/
     src/Illuminate/Database/Query/Grammars/Grammar.php on line 654 and defined
     
            foreach($investorIds as $id) {
                factory('App\Models\Investor',10, $id)->create();
            }
     */
     $faker = Faker::create();
     $investorIds = App\Models\User::all()->where('is_investor', 1)->lists('id');
     //echo('Investor Ids');
     //var_dump($investorIds);
     foreach ($investorIds as $id) {
         //factory('App\Models\Investor', $id)->create();
         Investor::create(['user_id' => $id, 'fname' => $faker->firstName, 'lname' => $faker->lastName, 'profile_name' => $faker->colorName, 'street' => $faker->streetAddress, 'city' => $faker->city, 'state' => $faker->state, 'zip' => $faker->postcode, 'phone' => $faker->phoneNumber, 'invst_objective' => $faker->sentence(), 'invst_amount_total' => $faker->randomFloat($nbMaxDecimals = 2, $min = 100.0, $max = 100000.0)]);
     }
 }
Beispiel #10
0
 public function run()
 {
     // DB::table('osu_events')->delete();
     App\Models\Event::unguard();
     $beatmapCount = App\Models\Beatmap::count();
     if ($beatmapCount === 0) {
         $this->command->info('Can\'t seed events due to having no beatmap data.');
         return;
     }
     $faker = Faker::create();
     $users = App\Models\User::all();
     $generateEventText = function ($bm, $bms, $u, $rank) {
         switch ($bm->playmode) {
             case 0:
                 $playmode = 'osu!';
                 break;
             case 1:
                 $playmode = 'Taiko';
                 break;
             case 2:
                 $playmode = 'Catch the Beat';
                 break;
             case 3:
                 $playmode = 'osu!mania';
                 break;
         }
         $rank_letters = ['X', 'S', 'A'];
         $rank_letter = array_rand_val($rank_letters);
         $string = "<img src='/images/" . $rank_letter . "_small.png'/> <b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> achieved rank #' . $rank . " on <a href='/b/" . $bm->beatmap_id . "?m=0'>" . $bms->artist . ' - ' . $bms->title . ' [' . $bm->version . ']' . '</a> (' . $playmode . ')';
         return $string;
     };
     foreach ($users as $u) {
         if ($beatmapCount > 0) {
             $all_beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
             for ($c = 0; $c < 4; $c++) {
                 if ($all_beatmaps[$c]) {
                     $bm = $all_beatmaps[$c];
                     $bms = App\Models\BeatmapSet::find($bm->beatmapset_id);
                     if (isset($bms)) {
                         $is_rank_1 = $faker->boolean(20);
                         if ($is_rank_1 === true) {
                             $rank = 1;
                             $epicfactor = 2;
                         } else {
                             $rank = strval(rand(1, 499));
                             $epicfactor = 1;
                         }
                         $txt = $generateEventText($bm, $bms, $u, $rank);
                         $ev = $u->events()->save(App\Models\Event::create(['user_id' => $u->user_id, 'text' => $txt, 'text_clean' => $txt, 'epicfactor' => $epicfactor, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'date' => rand(1451606400, time())]));
                     }
                 }
             }
         }
         // end rank events
         // Create a random supporter/name change event
         $string = '';
         switch (rand(1, 4)) {
             case 1:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has once again chosen to support osu! - thanks for your generosity!';
                 break;
             case 2:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has become an osu! supporter - thanks for your generosity!';
                 break;
             case 3:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has received the gift of osu! supporter!';
                 break;
             case 4:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $faker->userName . '</a></b> has changed their username to ' . $u->username . '!';
                 break;
         }
         $ev2 = $u->events()->save(App\Models\Event::create(['user_id' => $u->user_id, 'text' => $string, 'text_clean' => $string, 'epicfactor' => 1, 'date' => rand(1451606400, time())]));
     }
     // END EVENTS
     App\Models\Event::reguard();
 }
Beispiel #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // DB::table('osu_scores')->delete();
     // DB::table('osu_scores_high')->delete();
     // DB::table('osu_scores_taiko')->delete();
     // DB::table('osu_scores_taiko_high')->delete();
     // DB::table('osu_scores_fruits')->delete();
     // DB::table('osu_scores_fruits_high')->delete();
     $beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
     $beatmapCount = count($beatmaps);
     if ($beatmapCount === 0) {
         $this->command->info('Can\'t seed Scores due to having no beatmap data.');
         return;
     }
     $faker = Faker::create();
     $users = App\Models\User::all();
     App\Models\Score\Model::unguard();
     $allBeatmapsets = App\Models\Beatmapset::all();
     $possible_ranks = ['A', 'S', 'B', 'SH', 'XH', 'X'];
     foreach ($users as $k => $u) {
         $osuBeatmaps = $beatmaps->where('playmode', 0)->take(20);
         $taikoBeatmaps = $beatmaps->where('playmode', 1)->take(20);
         $fruitsBeatmaps = $beatmaps->where('playmode', 2)->take(20);
         $maniaBeatmaps = $beatmaps->where('playmode', 3)->take(20);
         //add 20 osu! Standard scores
         foreach ($osuBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             // hr, hd/hr, dt, hd/dt
             $sc = App\Models\Score\Osu::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85), 'rank' => array_rand_val($possible_ranks)]);
             $sc2 = App\Models\Score\Best\Osu::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.5 * $bm->difficultyrating, 'rank' => array_rand_val($possible_ranks)]);
         }
         //Taiko scores
         foreach ($taikoBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             $sc3 = App\Models\Score\Taiko::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85), 'rank' => array_rand_val($possible_ranks)]);
             $sc4 = App\Models\Score\Best\Taiko::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating]);
         }
         // end taiko
         //Fruits scores
         foreach ($fruitsBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             $sc5 = App\Models\Score\Fruits::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85)]);
             $sc6 = App\Models\Score\Best\Fruits::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating]);
         }
         // end fruits
         //Mania scores
         foreach ($maniaBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             // hr, hd/hr, dt, hd/dt
             $sc7 = App\Models\Score\Mania::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85)]);
             $sc8 = App\Models\Score\Best\Mania::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 2 * $bm->difficultyrating]);
         }
         // end mania
     }
     App\Models\Score\Model::reguard();
 }
Beispiel #12
0
    return ['name' => $faker->firstName, 'surname' => $faker->lastName, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10), 'profileimage' => substr(str_replace(storage_path(), '', $faker->image(storage_path(), 640, 480, 'people')), 1)];
});
$factory->define(App\Models\Article::class, function (Faker\Generator $faker) {
    return ['title' => $faker->sentence, 'user_id' => App\Models\User::all()->random()->id, 'text' => $faker->text(800)];
});
$factory->defineAs(App\Models\Article::class, 'withTask', function (Faker\Generator $faker) use($factory) {
    $article = $factory->raw(App\Models\Article::class);
    return array_merge($article, ['task_id' => App\Models\Task::all()->random()->id]);
});
$factory->defineAs(App\Models\Article::class, 'published', function (Faker\Generator $faker) use($factory) {
    $article = $factory->raw(App\Models\Article::class);
    return array_merge($article, ['state' => \App\Models\Article::PUBLISHED]);
});
$factory->define(App\Models\Tag::class, function (Faker\Generator $faker) {
    return ['name' => $faker->word];
});
$factory->define(App\Models\ArticleTagMapper::class, function (Faker\Generator $faker) {
    return ['article_id' => App\Models\Article::all()->random()->id, 'tag_id' => App\Models\Tag::all()->random()->id];
});
$factory->define(App\Models\Course::class, function (Faker\Generator $faker) {
    return ['name' => $faker->word, 'year' => $faker->year, 'user_id' => App\Models\User::all()->random()->id];
});
$factory->define(App\Models\Task::class, function (Faker\Generator $faker) {
    return ['name' => $faker->word, 'course_id' => App\Models\Course::all()->random()->id];
});
$factory->define(App\Models\Discussion::class, function (Faker\Generator $faker) {
    return ['user_id' => App\Models\User::all()->random()->id, 'text' => $faker->text($faker->numberBetween(100, 400)), 'article_id' => App\Models\Article::all()->random()->id, 'parent' => $faker->boolean(70) && App\Models\Discussion::all()->count() > 0 ? App\Models\Discussion::all()->random()->id : null];
});
$factory->define(App\Models\Rating::class, function (Faker\Generator $faker) {
    return ['user_id' => App\Models\User::all()->random()->id, 'article_id' => App\Models\Article::all()->random()->id, 'rating' => $faker->numberBetween(1, 5)];
});
<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt('password'), 'remember_token' => str_random(10), 'key_id' => str_random(12), 'last_seen' => $faker->dateTime, 'balance' => '500.0'];
});
$factory->define(App\Models\Permission::class, function (Faker\Generator $faker) {
    return ['name' => $faker->slug(6), 'description' => 'You may use the ' . $faker->word . ' machine.'];
});
$factory->define(App\Models\TransactionType::class, function (Faker\Generator $faker) {
    return ['name' => $faker->slug(6), 'description' => 'You purchased a ' . $faker->word, 'cost' => rand(1, 50)];
});
$factory->define(App\Models\Transaction::class, function (Faker\Generator $faker) {
    $transactionType = App\Models\TransactionType::All()->random();
    return ['user_id' => App\Models\User::all()->random()->id, 'amount' => $transactionType->cost, 'transaction_type_id' => $transactionType->id];
});
$factory->define(App\Models\Role::class, function (Faker\Generator $faker) {
    return ['name' => $faker->word];
});
    $user->user_type_id = 3;
    $user->username = '******' . (App\Models\User::count() + 1);
    $user->save();
    return ['occupation' => $faker->word, 'user_id' => $user->id];
});
$factory->define(App\Models\Foundation::class, function ($faker) {
    $user = factory('App\\Models\\User')->make();
    $user->user_type_id = 4;
    $user->username = '******' . (App\Models\User::count() + 1);
    $user->save();
    return ['designation' => $faker->word, 'user_id' => $user->id];
});
$factory->define(App\Models\StudentTimetable::class, function ($faker) {
    $subjects = App\Models\Subject::all();
    $courseSchool = App\Models\CourseSchool::all()->random();
    return ['period' => $faker->numberBetween(1, 7), 'mon' => $subjects->random()->id, 'tue' => $subjects->random()->id, 'wed' => $subjects->random()->id, 'thu' => $subjects->random()->id, 'fri' => $subjects->random()->id, 'sat' => $subjects->random()->id, 'course_school_id' => $courseSchool->id];
});
$factory->define(App\Models\StaffTimetable::class, function ($faker) {
    $course = App\Models\Course::all();
    $staff = App\Models\User::where('user_type_id', 2)->get()->random();
    return ['period' => $faker->numberBetween(1, 7), 'mon' => $course->random()->id, 'tue' => $course->random()->id, 'wed' => $course->random()->id, 'thu' => $course->random()->id, 'fri' => $course->random()->id, 'sat' => $course->random()->id, 'staff_id' => $staff->id];
});
$factory->define(App\Models\Book::class, function ($faker) {
    return ['title' => $faker->sentence(3), 'subject_id' => App\Models\Subject::all()->random()->id, 'description' => $faker->sentence, 'author' => $faker->name, 'publisher' => $faker->sentence(3), 'uploaded_by' => App\Models\Staff::all()->random()->user_id, 'image' => $faker->imageUrl(300, 100, 'transport', true, 'Faker'), 'book_url' => $faker->imageUrl(300, 300, 'people', true, 'Faker') . ".pdf"];
});
$factory->define(App\Models\News::class, function ($faker) {
    return ['title' => $faker->sentence(3), 'level' => ['PUBLIC', 'STUDENT', 'FOUNDATION', 'STAFF', 'PARENT', 'SCHOOL', 'CLASS'][array_rand(['PUBLIC', 'STUDENT', 'FOUNDATION', 'STAFF', 'PARENT', 'SCHOOL', 'CLASS'])], 'image' => $faker->imageUrl(300, 100, null, true, 'Faker'), 'content' => $faker->paragraph, 'creator_id' => App\Models\User::where('user_type_id', 4)->orWhere('user_type_id', 5)->get()->random()->id];
});
$factory->define(App\Models\Talent::class, function ($faker) {
    return ['image' => $faker->imageUrl(300, 100, 'abstract', true, 'Faker'), 'content' => $faker->paragraph, 'posted_by' => App\Models\User::all()->random()->id];
});