'Room 1', 'room_rows' => 10, 'room_columns' => 10, ], [ 'room_name' => 'Room 2', 'room_rows' => 5, 'room_columns' => 5, ], ]; foreach ($rooms as $room) { $this->command->info("Creating room {$room['room_name']} for cinema {$cinema->cinema_name}"); $r = new \App\Models\Room(); $r->room_name = $room['room_name']; $r->room_rows = $room['room_rows']; $r->room_columns = $room['room_columns']; $r->user_id = 1; $r->cinema_id = $cinema->cinema_id; $r->save(); for ($row = 1; $row <= $r->room_rows; $row++) { $this->command->info("Creating row {$row} for room {$r->room_name}"); for ($column = 1; $column <= $r->room_columns; $column++) { $s = new \App\Models\Seat(); $s->seat_row = $row; $s->seat_column = $column; $s->room_id = $r->room_id; $s->save(); } } } } } }