Last active
January 17, 2018 19:23
-
-
Save renatoschroepfer/e9e5c364d3271d21e8f9c6e48f9dcca7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Primary/Default database connection | |
'mysql' => [ | |
'driver' => 'mysql', | |
'host' => env('DB_HOST', '127.0.0.1'), | |
'port' => env('DB_PORT', '3306'), | |
'database' => env('DB_DATABASE', 'database2'), | |
'username' => env('DB_USERNAME', 'root'), | |
'password' => env('DB_PASSWORD', ''), | |
'unix_socket' => env('DB_SOCKET', ''), | |
'charset' => 'utf8mb4', | |
'collation' => 'utf8mb4_unicode_ci', | |
'prefix' => '', | |
'strict' => true, | |
'engine' => null, | |
], | |
# Secondary database connection | |
'mysql2' => [ | |
'driver' => 'mysql', | |
'host' => env('DB_HOST_2', '0.0.0.0'), | |
'port' => env('DB_PORT_2', '3306'), | |
'database' => env('DB_DATABASE_2', 'databaseexterno'), | |
'username' => env('DB_USERNAME-2', 'root'), | |
'password' => env('DB_PASSWORD_2', 'password'), | |
'unix_socket' => env('DB_SOCKET', ''), | |
'charset' => 'utf8mb4', | |
'collation' => 'utf8mb4_unicode_ci', | |
'prefix' => '', | |
'strict' => true, | |
'engine' => null, | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use Illuminate\Database\Eloquent\Model; | |
use App\Multimodel; | |
class Multicontroller extends Controller | |
{ | |
// | |
public function test(){ | |
$data = Multimodel::select('customerName as total')->from('customers')->count(); | |
return view('showdata', $data); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Multimodel extends Model | |
{ | |
// | |
/** | |
* @var string | |
*/ | |
protected $connection = 'mysql2'; | |
public static function pegarTodosNomes() | |
{ | |
return Multimodel::All(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
TESTE | |
<ul> </ul> | |
@foreach($data as $customers) | |
<li> Personame Name:{{$customers->username}} and Origin name: {{$customers->customerName}} | |
@endforeach | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/getdata', 'Multicontroller@test'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment