-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da862a5
commit d56d7b1
Showing
42 changed files
with
752 additions
and
443 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,36 +4,30 @@ | |
|
||
use App\Notifications\TenantCreated; | ||
use App\Tenant; | ||
use Hyn\Tenancy\Models\Customer; | ||
use Illuminate\Console\Command; | ||
|
||
class CreateTenant extends Command | ||
{ | ||
protected $signature = 'tenant:create {name} {email}'; | ||
protected $signature = 'tenant:create {name} {password} {email}'; | ||
|
||
protected $description = 'Creates a tenant with the provided name and email address e.g. php artisan tenant:create boise [email protected]'; | ||
protected $description = 'Creates a tenant with the provided name and email address e.g. php artisan tenant:create boise test [email protected]'; | ||
|
||
public function handle() | ||
{ | ||
$name = $this->argument('name'); | ||
$email = $this->argument('email'); | ||
$password = $this->argument('password'); | ||
|
||
if ($this->tenantExists($name, $email)) { | ||
$this->error("A tenant with name '{$name}' and/or '{$email}' already exists."); | ||
|
||
if (Tenant::tenantExists($name)) { | ||
$this->error("A tenant with name '{$name}' already exists."); | ||
return; | ||
} | ||
|
||
$tenant = Tenant::createFrom($name, $email); | ||
$tenant = Tenant::registerTenant($name, $email, $password); | ||
$this->info("Tenant '{$name}' is created and is now accessible at {$tenant->hostname->fqdn}"); | ||
|
||
// invite admin | ||
$tenant->admin->notify(new TenantCreated($tenant->hostname)); | ||
$this->info("Admin {$email} has been invited!"); | ||
} | ||
|
||
private function tenantExists($name, $email): bool | ||
{ | ||
return Customer::where('name', $name)->orWhere('email', $email)->exists(); | ||
$this->info("Admin {$email} can log in using password {$password}"); | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware; | ||
|
||
class CheckForMaintenanceMode extends Middleware | ||
{ | ||
/** | ||
* The URIs that should be reachable while maintenance mode is enabled. | ||
* | ||
* @var array | ||
*/ | ||
protected $except = [ | ||
// | ||
]; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class MailResetPasswordToken extends Notification | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* The password reset token. | ||
* | ||
* @var string | ||
*/ | ||
public $token; | ||
|
||
/** | ||
* Create a notification instance. | ||
* | ||
* @param string $token | ||
* @return void | ||
*/ | ||
public function __construct($token) | ||
{ | ||
$this->token = $token; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['mail']; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
// Get current Hostname | ||
$hostname = app(\Hyn\Tenancy\Environment::class)->hostname(); | ||
|
||
// Get FQDN (Fully-Qualified Domain Name) by current hostname | ||
$fqdn = $hostname->fqdn; | ||
|
||
return (new MailMessage) | ||
->subject('Reset Password Notification') | ||
->line('You are receiving this email because we received a password reset request for your account.') | ||
->action('Reset Password', $fqdn.route('password.reset', $this->token, false)) | ||
->line('If you did not request a password reset, no further action is required.'); | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
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
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
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
Oops, something went wrong.
d56d7b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm wondering why the commit message is:
With all the references to Models\Customer and CustomerRepository removed, but the multi-tenant package is still at 5.1.2?
d56d7b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still have 5.1.2 in composer.json? Sorry if it does. Just run composer update. This commit works fine with 5.3 and Laravel 5.7 too.
d56d7b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, just recently read issue #16 as well. Thank you.