Support the ongoing development of Laravel.io →
Configuration Database
Last updated 2 years ago.
0
Solution

I figured it out...

Let’s say your source database is MySQL and you have a client table with client_id and client_name columns. On your Laravel project you have a clients table with id, client_name, created_at, and updated_at columns. Add a new connection to your /app/config/database.php. If you have multiple MySQL databases, it’s okay, just append 2… so you have a mysql and mysql2 connection. So your mysql array connection holds your Laravel database and mysql2 holds your database connection information where you’ll be getting data from. Next edit the /app/database/seeds/DatabaseSeeder.php file. Here’s what I have.

here's the seed code

http://laravel.io/bin/PV6k (version 1)

http://laravel.io/bin/M1lQ (version 2, supports multiple tables)... i meant to use $result[]

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

w1n78 w1n78 Joined 21 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.