Use faker in laravel

 Use faker in laravel

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Employee;
class EmployeeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */


    public function loadData()
    {
       $faker = \Faker\Factory::create();
        for($i=0; $i<=10; $i++)
        {
            $employee = new Employee;
            $employee->first_name =$faker->firstName;
            $employee->last_name=$faker->lastName;
            $employee->gender ='m';
            $employee->save();
        }

        return "success";
    }
}

Comments