-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the admin tasks from routes and added them as a Command
- Loading branch information
1 parent
4adf222
commit 180ddaf
Showing
2 changed files
with
57 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User\User; | ||
use App\Notifications\UserRegistered; | ||
use App\Utils\Translator; | ||
use Illuminate\Console\Command; | ||
|
||
class TestAdminTasks extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:test-admin-tasks'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'This command is used to test the availability of some tasks, like the external translation service and the emailing service.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() { | ||
$task = $this->choice('Which task would you like to test?', ['Translate service', 'Test email', 'Test Sentry error']); | ||
|
||
if ($task === 'Translate service') { | ||
$this->info('Testing the translation service...'); | ||
$texts = ['Hello', 'How are you?', 'Good morning']; | ||
$lang_code = 'fr'; | ||
$translations = Translator::translateTexts($texts, $lang_code); | ||
$this->info('Translations:'); | ||
foreach ($translations as $translation) { | ||
$this->info($translation); | ||
} | ||
$this->info('API Key: ' . config('app.google_translate_key')); | ||
} elseif ($task === 'Test email') { | ||
$this->info('Testing the email service...'); | ||
$email = $this->ask('Enter the email address to send the test email to:'); | ||
User::where(['email' => $email])->first()->notify(new UserRegistered); | ||
$this->info('The test email has been sent to ' . $email); | ||
} elseif ($task === 'Test Sentry error') { | ||
$this->info('Testing the Sentry error reporting service...'); | ||
$message = $this->ask('Enter the message for the Sentry error:'); | ||
throw new \Exception('Test Sentry error: ' . $message); | ||
} | ||
} | ||
} |
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