Relative Content

Tag Archive for laraveleloquentlaravel-seeding

Is there a way to seed a table in Laravel for each record seeded in another table and using columns of each record? (Dependent seeding)

This is more like model event listener creating some number of other records connected to that particular record creating and using a foreign key. However I want this to occur during seeding. Let’s say I have a Flight model/table, I want each time a create a record either through manually or seeding, it automatically creates the seats (On the Seat model or table) which users can book. Also the number of seats created for that flight depends on a column on the flight called “available_seats”. I have already implemented this using model event listeners but it doesn’t seem to work when I seed my flights. Now because seats are usually large in number, I may need ways to optimize the seats creation time both manually and seeding