Laravel 8 Store Record In Diffrent Database Example


Share:
 | Published By: Admin | Published On: Dec 28, 2021 | Category: Laravel 8 Laravel


Hello Dev,

Now let's see example of how to store record in different database example. We will check how to store record in different database. This is a short guide on store record in different database in laravel 8. Let's get started with how to store record in different database in laravel 8.

Here i will give you many example how to store record in different database using laravel 8.

Solution
//Store record in first database
User::create($input);

//Store record in different database
$userModel = new User();
$userData = $userModel->setConnection('mysql2')
            ->create($input);

It will help you...

Share: