osb/app/Console/Commands/TestEmail.php

52 lines
962 B
PHP
Raw Normal View History

2020-01-21 09:59:10 +00:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
2022-06-13 10:55:39 +00:00
use Illuminate\Support\Facades\Config;
2020-01-21 09:59:10 +00:00
use Illuminate\Support\Facades\Mail;
use App\Mail\TestEmail as MailTest;
2022-06-13 10:55:39 +00:00
use App\Models\{Site,User};
2020-01-21 09:59:10 +00:00
class TestEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
2022-06-13 10:55:39 +00:00
protected $signature = 'test:email {site : Site ID} {id : User ID} {email? : Alternative Email}';
2020-01-21 09:59:10 +00:00
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send a test email';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
2022-06-13 10:55:39 +00:00
Config::set('site',Site::findOrFail($this->argument('site')));
2020-01-21 09:59:10 +00:00
$uo = User::find($this->argument('id'));
2022-06-13 10:55:39 +00:00
Mail::to($this->argument('email') ?? $uo->email)
2020-01-21 09:59:10 +00:00
->send(new MailTest($uo));
}
}