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\Database\Seeder; | |
class TenancyDatabaseSeeder extends Seeder | |
{ | |
/** | |
* Run the database seeds. | |
* | |
* @return void |
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 Faker\Generator as Faker; | |
$factory->define(App\Customer\Models\User::class, function (Faker $faker) { | |
return [ | |
'name' => $faker->name, | |
'email' => $faker->unique()->safeEmail, | |
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret |
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 Faker\Generator as Faker; | |
$factory->define(App\Customer\Models\Post::class, function (Faker $faker) { | |
return [ | |
'name' => $faker->sentence, | |
'body' => $faker->text(100), | |
]; | |
}); |
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\Customer\Models\User; | |
use Hyn\Tenancy\Models\Customer; | |
Route::get('customers', function () { | |
return Customer::all(); | |
}); | |
Route::get('users', function () { |
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
DB_CONNECTION=system | |
DB_HOST=127.0.0.1 | |
DB_PORT=3306 | |
DB_DATABASE=system_tenancy | |
DB_USERNAME=root | |
DB_PASSWORD= | |
LIMIT_UUID_LENGTH_32=true | |
TENANCY_DATABASE_AUTO_DELETE=true | |
TENANCY_DATABASE_AUTO_DELETE_USER=true |
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\Customer\Models; | |
use Hyn\Tenancy\Traits\UsesTenantConnection; | |
use Illuminate\Database\Eloquent\Model; | |
class Post extends Model | |
{ | |
use UsesTenantConnection; |
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\Customer\Models; | |
use App\Shared\Models\User as Shared; | |
use Hyn\Tenancy\Traits\UsesTenantConnection; | |
class User extends Shared | |
{ | |
use UsesTenantConnection; |
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\System\Models; | |
use App\Shared\Models\User as Shared; | |
use Hyn\Tenancy\Traits\UsesSystemConnection; | |
class User extends Shared | |
{ | |
use UsesSystemConnection; |
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\Shared\Models; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use Illuminate\Notifications\Notifiable; | |
class User extends Authenticatable | |
{ | |
use Notifiable; |
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
Route::domain('{customer}.multi-tenancy.job')->prefix('api/v1')->group(function () { | |
Route::get('users', function ($customer) { | |
return App\Customer\Models\User::all(); | |
}); | |
}); |