mercredi 31 juillet 2019

How to specify a specific connection (or the database name) for Datatables in Laravel 5

I'm using Laravel 5 with Jajra/Datatables

The project use 3 databases, one is MySQL and 2 are commercial SQL databases.

The SQL databases have the tables with exactly same names.

If I want to display a table from MySql database I use in controller:

return  Datatables::of(DB::table('coeficientVR_VanzariNoi')
        ->get(['id','marca','model','capacitate','combustibil', 'caroserie', 'altaClasaSchimb', 'coeficient',
              ]))->make(true);

and it's working great!

How to specify a table from one of the the SQL databases?

I have models associated to them, and models have the connection specified.

Example for one of table which is named "version":

class version_Jato extends Model
{
    //
    protected $connection = 'sqlJato';
    protected $table = 'version';
    protected $primaryKey = 'vehicle_id';

....

So I need to specify the SQL database but I don't know how.

Thank you for your time!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32YZCaF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire