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 | |
| return [ | |
| 'default' => env('DB_CONNECTION', 'main'), | |
| 'connections' => [ | |
| 'main' => [ | |
| 'driver' => env('DB_DRIVER', 'mysql'), |
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 | |
| use Illuminate\Support\Facades\Schema; | |
| use Illuminate\Database\Schema\Blueprint; | |
| use Illuminate\Database\Migrations\Migration; | |
| class CreateCompaniesTable extends Migration | |
| { | |
| /** | |
| * Run the migrations. |
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 | |
| use Illuminate\Support\Facades\Schema; | |
| use Illuminate\Database\Schema\Blueprint; | |
| use Illuminate\Database\Migrations\Migration; | |
| class CreateUsersTable extends Migration | |
| { | |
| /** | |
| * Run the migrations. |
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 | |
| use Illuminate\Support\Facades\Schema; | |
| use Illuminate\Database\Schema\Blueprint; | |
| use Illuminate\Database\Migrations\Migration; | |
| class CreatePostsTable extends Migration | |
| { | |
| /** | |
| * Run the migrations. |
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 Tests\Feature; | |
| use App\Models\Tenant\Post; | |
| use Tests\TenantTestCase; | |
| class PostsTest extends TenantTestCase | |
| { | |
| /** |
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 Tests; | |
| use App\Models\Main\User; | |
| use Illuminate\Foundation\Testing\RefreshDatabase; | |
| abstract class TenantTestCase extends TestCase | |
| { | |
| use RefreshDatabase; |
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 | |
| use App\Models\Main\User; | |
| use App\Models\Main\Company; | |
| use Faker\Generator as Faker; | |
| $factory->define(User::class, function (Faker $faker) { | |
| static $password; | |
| return [ |
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 | |
| use App\Models\Main\Company; | |
| use Faker\Generator as Faker; | |
| $factory->define(Company::class, function (Faker $faker) { | |
| $hostname = '127.0.0.1'; | |
| $username = $faker->userName; | |
| $password = $faker->password; |
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 | |
| use Illuminate\Support\Facades\Artisan; | |
| use Illuminate\Support\Facades\Config; | |
| use Illuminate\Support\Facades\DB; | |
| use Illuminate\Support\Facades\Schema; | |
| if (! function_exists('tenant_connect')) { | |
| /** | |
| * Establish a tenant database connection. |
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\Models; | |
| use Illuminate\Database\Eloquent\Model; | |
| class MainModel extends Model | |
| { | |
| protected $connection = 'main'; | |
| } |