database seeding in laravel
php artisan make:model MODEL_PATH\MODEL_NAME -ms
-m, --migration Create a new migration file for the model.
-s, --seeder Create a new seeder file for the model.<?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'),
]);
}
}
Also in PHP:
- create new laravel 7 project
- date- format php a string
- date formate with pc time in php
- add errors php
- check data type in php
- 500 server error heroku laravel
- Class 'App\Http\Controllers\Session' not found
- convert date object to string php
- current time php
- ->store() laravel change name
- $db new PDO php
- doesn't appear favicon php
- advanced custom field repeater
- E: Unable to locate package php7.2-mbstring
- Connecting that to Database using PHP.
- check if substring present in string in php
- convert any phone number in us number format php
- Arr::pull()
- convert timestamp to date php code
- Laravel route not calling function of controller
- cache delete or forget in laravel
- clean cache laravel
- extend php maximum execution time
- delete route method in laravel