2 months ago

Global setConnection in Laravel

Posted 2 months ago by NithApple

i have create project for multi database whenever that i want to get data I'm always need to set connection before get. but i don't need like this i want to set connection to global when i want to use which database i just call by class name that we already connected in global class

//my current function

    $user = new Users; $user->setConnection('mysql2'); dd($user->find(1));

Please sign in or create an account to participate in this conversation.