I am trying to develop a multi-tenancy application without using Package in Laravel-5.8.
I am using traits and scopes
Models
class Company extends Model
{
protected $table = 'companies';
protected $fillable = [
'id',
'company_code',
'company_name'
];
}
class User extends Authenticatable
{
protected $fillable = [
'name',
'company_id',
'email',
];
}
The main domain is:
https://myapp.com
Sub domains are:
https://company1.myapp.com
https://company2.myapp.com
I using socialite for login authentication. For the main company:
config/services.php
'azure' => [
'client_id' => env('AZURE_KEY','23333-ff333-9103-fgghhh-cc8b955ed23c'),
'client_secret' => env('AZURE_SECRET','ffjjfnfhfhhhhff'),
'redirect' => env('AZURE_REDIRECT_URI','https://myapp.com/login/azure/callback')
],
config/mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.office365.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'COMPANY1'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','[email protected]'),
'password' => env('MAIL_PASSWORD','maincompany'),
'sendmail' => '/usr/sbin/sendmail -bs',
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
How do I treat:
config/services.php and config/mail.php
for the three companies https://myapp.com, https://company1.myapp.com and https://company2.myapp.com
Thanks
question from:
https://stackoverflow.com/questions/65887455/single-db-multi-tenancy-without-using-package-in-laravel