'Voyager get records from another database and show in table. (customized view)
There are two databse one is used for voyager and another is exiting database which filled data, I have to show in table form same as voyager do, I am newby and searched about to connect another database in voyager.
Customized controller to show listinf of domains
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// use Illuminate\Routing\Controller as BaseController;
use TCG\Voyager\Http\Controllers\VoyagerBaseController as BaseController;
use TCG\Voyager\Facades\Voyager;
use App\Models\Domain;
class DomainController extends BaseController {
//
public function domainListing(){
dd(Domain::limit(5)->get()->toArray());
$data['abc'] = 'test';
return view('domain-list');
}
}
Routing file where I have wrote routing which is showing correctly,
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
Route::get('domains', ['uses' => 'App\Http\Controllers\DomainController@domainListing', 'as' => 'domains']);
});
Domain Model from another database
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Domain extends Model {
protected $connection = 'mysql-connection2';
protected $table = 'domain';
protected $guarded=[];
public $timestamps = true;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
