How do I seed my database for column that is a foreign key referencing to other table?



How do I seed my database for column that is a foreign key referencing to other table?..

Answer / Mohd Shahnawaz Qureshi

To seed a database with data for a foreign key column, you can use the factory method on the related model and call it within your seeder class's run() method. Make sure to set the relationship before saving the instance.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

What is meant by Implicit Controllers

2 Answers  


Tell me does laravel support caching?

1 Answers  


Name some inbuilt authentication controllers of laravel.

1 Answers  


Tell me what are the feature of laravel 5.0?

1 Answers  


What is response in laravel?

1 Answers  


What do you know about facades in laravel? Explain.

1 Answers  


What is gate in laravel?

1 Answers  


How to generate pretty urls in laravel?

1 Answers  


What is dd() function in laravel?

1 Answers  


Explain laravel contracts?

1 Answers  


What are policies?

1 Answers  


What is laravel horizon?

1 Answers  


Categories