Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

insert into database with seeder

<?php
 
namespace DatabaseSeeders;
 
use IlluminateDatabaseSeeder;
use IlluminateSupportFacadesDB;
use IlluminateSupportFacadesHash;
use IlluminateSupportStr;
 
class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeders.
     *
     * @return void
     */
    public function run()
    {
        DB::table('users')->insert([
            'name' => Str::random(10),
            'email' => Str::random(10).'@gmail.com',
            'password' => Hash::make('password'),
        ]);
    }
}
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #insert #database #seeder
ADD COMMENT
Topic
Name
5+7 =