Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'second_database' => [
- 'driver' => env('DB_CONNECTION_2'),
- 'host' => env('DB_HOST_2'),
- 'port' => env('DB_PORT_2'),
- 'database' => env('DB_DATABASE_2'),
- 'username' => env('DB_USERNAME_2'),
- 'password' => env('DB_PASSWORD_2'),
- ],
- //main database
- DB_CONNECTION=mysql
- DB_HOST=mysql.myhost.com
- DB_PORT=22
- DB_DATABASE=main_database
- DB_USERNAME=johnny
- DB_PASSWORD=pass123
- //second database
- DB_CONNECTION_2=mysql
- DB_HOST_2=mysql.myhost.com
- DB_PORT_2=22
- DB_DATABASE_2=second_database
- DB_USERNAME_2=johnny
- DB_PASSWORD_2=pass123
- //first approach
- DB::connection('second_database')->create('users', function($table){
- $table->email = $data['email'];
- $table->name = $data['name'];
- $table->password = 123123;
- $table->save();
- });
- //other approach
- DB::connection('second_database')->table('users')->create([
- 'name' => $data['name'],
- 'email' => $data['email'],
- 'password' => Hash::make($data['password']),
- ]);
Add Comment
Please, Sign In to add comment