mercredi 12 décembre 2018

Create Dynamic Database Connection in Laravel

I tried to change the database connection from laravel model,

This is my code,

namespace App\model;

use Illuminate\Database\Eloquent\Model;

use Config;
use DB;
class Process extends Model
{

    config(['database.connections.newsql' => [
            'host' => '127.0.0.1',
            'password' => '',
            'database' => 'gps_bizspecific',
            'username' => 'root'
        ]]);

But I got an error

syntax error, unexpected 'config' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

How to solve this ???

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire