adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you know what version of laravel do you generally use?

839


How much laravel experience do you have?

815


What is current stable version of laravel?

870


Tell us have you used lumen before?

808


What is latest version of laravel?

869