yajra / laravel-datatables

jQuery DataTables API for Laravel

Home Page:https://yajrabox.com/docs/laravel-datatables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It's possible to change connection ?

franciscoarnaldog opened this issue · comments

Summary of problem or feature request

It's possible to change connection ?

Code snippet of problem

// $query = Model::from('model as m')
$builder = Model::query();
$builder->from('model as m')
    ...
$query 				= $builder->getQuery();
$conn 				= DB::connection('other_db');
$query->connection 	= $conn;
$query->grammar 	        = $conn->query()->getGrammar();
$query->processor 	       = $conn->query()->getProcessor();
$builder 			       = $builder->setQuery($query);

return Datatables::of($builder)
   ...
   ->toJson();

System details

Laravel on Linux

  • Linux Mint 21
  • PHP 8.0
  • Laravel 9
  • Laravel-Datatables 10

I think this is out of scope. Anyways, are you trying some multitenant stuff? You can change the model connection via middleware

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been inactive for 7 days since being marked as stale.