Last active
January 2, 2020 05:58
-
-
Save einnar82/862da5c753111452bbb9dcb77273034a to your computer and use it in GitHub Desktop.
Eloquent from database to database (Single database instance) - Part 1
This file contains hidden or 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\Contracts\Auth\MustVerifyEmail; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use Illuminate\Notifications\Notifiable; | |
class User extends Authenticatable | |
{ | |
use Notifiable; | |
/** | |
* Eloquent grammars can read multiple schema relationships | |
* within the same database instance. | |
* | |
* Just like the regular mysql query, you can declare multiple database relationships | |
* override the $table to 'database-name.table_name' | |
* or defined the connection name via | |
* $connection = 'your_database_connection'; | |
* | |
*/ | |
// protected $table = 'eloquent-test.users'; | |
protected $connection = 'mysql'; | |
public function posts() | |
{ | |
return $this->hasMany(Post::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment