Laravel 11 tutorial - Seeding

preview_player
Показать описание
In this laravel 8 and 9 version video tutorial, we learn what is seeding and what are important commands for seeding in laravel tutorial a simple way. This video is made by anil Sidhu in the English language.

steps of video
What is Seeding
How to generate seeder file
Data Seeding
Run Seeding for database
Interview Question for seeding
laravel 9 tutorial
laravel tutorial series

Laravel latest playlist
Рекомендации по теме
Комментарии
Автор

Please support me by subscribe, like and comment :) thank you

codestepbystep
Автор

For the interview question I did it by simply adding a for loop to the DB: code as Show Below

for($i = 1; $i < 11; $i++)
{

DB::table('seed')
->insert([
'firstname'=>Str::random(10),
'lastname'=>Str::random(10),
'username'=>Str::random(10)

]);
}
with this I am able to add more rows to the table be simple passing the loop to execute the code for the number of times I want the table to be filled just like above .

destinyobamwonyi
Автор

Interview answer:- To call multiple seeder at a time.
Call all generated Seeder classes in to DatabaseSeeder class in "run()" method (which is default seeder class in laravel application)
example:-
class DatabaseSeeder extends Seeder
{
public function run()
{
$this->call([
SeederClassName::class,
SeederClassName::class,
]);
}
}
And then run php artisan db:seed.

meghanahiregoudar
Автор

#All of them
php artisan db:seed
#One class
php artisan db:seed --class=NameOfTheSeeder

muhammadshaheerkhan
Автор

Best teacher, thanks for your courses!

alecsandrucristea
Автор

the db:seed Artisan command to seed your database. By default, the db:seed command runs the DatabaseSeeder class

saikumarkandikonda
Автор

USING FORLOOP weseeding many values at one

fuadabdurahmanofficials
Автор

Interview question answer:
Run all seeder files.
- php artisan db:seed

dhanrajsakariya
Автор

We would simply type in the cmd or command prompt
Php artisan db:seed😅

Jabo
Автор

php artisan db:seed seeder_class used for all database seeder runs please tell me sir if i am correct or wrong

Prashant-Patil
Автор

How come some people seed with 'create' instead of the 'insert' that the docs show?

ryanm.
Автор

How to add some dummy random integer type data??

reamskamat
Автор

how do i host angular laravel on host please sir...

vidyasagargaikwad
Автор

sir we use str to create random string value what if we want to create dummy value in integers we use int in the place of str????

saurabhgaonkar
Автор

How to add 5 rows of seed data with a single command?

marufmazumder
Автор

New Problem: 'App\Models\Role' not found, how can i use models below here commented lines?

code

<?php



use Illuminate\Database\Seeder;

use App\Models\User;

use App\Models\Role;

class AdminUser extends Seeder

{

/**

* Run the database seeds.

*

* @return void

*/

public function run()

{

//here
$role = Role::create([

'name' => 'customer',

'description' => ' Customer Role'

]);


//here
$role = Role::create([

'name' => 'admin',

'description' => 'Admin Role'

]);


//here
$user = User::create([

'email' => 'emailhere',

'password' => bcrypt('passwordhere'),

'role_id' => $role->id,

]);

}

}

hamzaahmed
Автор

same yahi code run nai ho raha id tu di nai ha

gemabout
Автор

sir what is faker in laravel uspe bhi ek video banna

kaziovesh