Tuesday, 8 December 2020

Factory and Seeder

Below is default factory.  Factories ->UserFactory..

<?php

use App\User;
use Faker\Generator as Faker;
use Illuminate\Support\Str;

$factory->define(User::class, function (Faker $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'email_verified_at' => now(),
        'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
        'remember_token' => Str::random(10),
    ];
});

Below is default Databaseseeders ->UserFactory..

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{     
    public function run()
    {
       factory(App\User::class, 100)->create();
    }
}

Run

php artisan db:seed

No comments:

Post a Comment

Machine Learning - Potato Leaf Disease Prediction

Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...