Ejemplo n.º 1
0
 public function run()
 {
     // Permite obtener campos de forma arbitraria.
     $faker = Faker::create();
     $departament = Departament::all()->lists('id');
     $category = Category::all()->lists('id');
     $type = 'client';
     // Permitre identificar origen de la solicitud.
     $geoIp = new GeoIp(app_path('database/GeoLite2-City.mmdb'));
     foreach (range(1, 100) as $index) {
         if ($index > 90) {
             $type = 'technical';
         }
         $ip = $faker->ipv4;
         try {
             $record = $geoIp->city($ip);
             $user = new User();
             $user->full_name = $faker->name;
             $user->username = $faker->numberBetween($min = 2011000000, $max = 2015000000);
             $user->email = $faker->email;
             $user->password = '******';
             $user->category_id = $faker->randomElement($departament);
             $user->departament_id = $faker->randomElement($category);
             $user->type = $type;
             $user->ip_address = $ip;
             $user->country = $record->country->names['es'];
             $user->city = $record->mostSpecificSubdivision->names['es'];
             $user->authorized = $faker->randomElement([true, false]);
             $user->save();
         } catch (Exception $e) {
             echo "undefined location for ip: " . $ip . "\n";
         }
     }
     $user = new User();
     $user->full_name = 'Cristian Gerardo Jaramillo Cruz';
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->category_id = '5';
     $user->departament_id = '7';
     $user->type = 'admin';
     $user->authorized = true;
     $user->ip_address = '201.141.89.52';
     $record = $geoIp->city($user->ip_address);
     $user->country = $record->country->names['es'];
     $user->city = $record->mostSpecificSubdivision->names['es'];
     $user->save();
 }
Ejemplo n.º 2
0
 public function run()
 {
     $faker = Faker::create();
     $user = User::where('type', 'client')->lists('id');
     foreach (range(1, 10) as $index) {
         Report::create(['title' => $faker->company, 'message' => $faker->text, 'client_id' => $faker->randomElement($user)]);
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     $faker = Faker::create();
     $report = Report::all()->lists('id');
     $user = User::all()->lists('id');
     foreach (range(1, 100) as $index) {
         Post::create(['report_id' => $faker->randomElement($report), 'user_id' => $faker->randomElement($user), 'message' => $faker->text, 'type' => $faker->randomElement(['private', 'public'])]);
     }
 }