database seeding laravel
#All of them
php artisan db:seed
#One class
php artisan db:seed --class=UserSeeder<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
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'),
]);
}
}php artisan make:seeder NameOfTheSeederphp artisan db:seed --class=UserSeeder<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
'name' => Str::random(10),
'email' => Str::random(10).'@gmail.com',
'password' => Hash::make('password'),
]);
}
}php artisan make:seeder ArticlesTableSeeder
Also in PHP:
- Allowed memory size of 1610612736 b
- Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar
- check website ssl certificate using php openssl_x509_parse
- add another field in existing migration laravel
- database seeding laravel
- catch custom exception php
- apt install php7.4-mbstring php7.4-zip php7.4-xml
- call other seeder class laravel
- SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767
- Laravel 8 seed
- array_column in php
- eloquent remove updated_at
- cache clear laravel command
- Dynamic title on every page laravel blade
- error reporting 0in hph
- create laravel project using cmd
- check if index is undefined php
- Laravel Mix npm run production error
- compress video file size php
- base64 dencode GET variables in PHP
- api header php
- autoload php multiple spl_autoload_register
- command to install laravel 7
- Allowed memory size of 1610612736 bytes exhausted php on mac