- Created ExampleTest and RoutesTest for basic application response and route testing. - Implemented IsolatedDatabaseTestCase for isolated database testing. - Added unit tests for various models and services including Contract, CPE, and LeadDetail. - Developed request validation tests for CreateClientRequest, UpdateClientRequest, and ContractRequest. - Introduced Vite configuration for asset management in the Laravel application.
54 lines
1.9 KiB
PHP
54 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Throwable;
|
|
|
|
class AdminService
|
|
{
|
|
public function info(): array
|
|
{
|
|
$databaseVersion = DB::connection()->getDriverName() === 'mysql'
|
|
? DB::select('SELECT VERSION() as version')[0]->version
|
|
: DB::connection()->getDriverName();
|
|
try {
|
|
$redisVersion = Redis::connection()->client()->info()['redis_version'] ?? 'N/A';
|
|
} catch (Throwable $exception) {
|
|
$redisVersion = 'N/A';
|
|
}
|
|
return [
|
|
'php_version' => PHP_VERSION, 'php_sapi' => PHP_SAPI, 'laravel_version' => app()->version(),
|
|
'environment' => app()->environment(), 'debug_mode' => config('app.debug'),
|
|
'database_driver' => config('database.default'), 'database_version' => $databaseVersion,
|
|
'redis_version' => $redisVersion, 'redis_database' => config('database.redis.cache.database'),
|
|
'cache_driver' => config('cache.default'), 'queue_driver' => config('queue.default'),
|
|
'session_driver' => config('session.driver'), 'memory_limit' => ini_get('memory_limit'), 'system' => php_uname(),
|
|
];
|
|
}
|
|
|
|
public function phpInfo(): string
|
|
{
|
|
ob_start();
|
|
phpinfo();
|
|
return ob_get_clean();
|
|
}
|
|
|
|
public function runMigrations(): array
|
|
{
|
|
$exitCode = Artisan::call('migrate', ['--force' => true]);
|
|
return ['success' => $exitCode === 0, 'exit_code' => $exitCode, 'output' => trim(Artisan::output())];
|
|
}
|
|
|
|
public function testEmail(string $recipient): array
|
|
{
|
|
Mail::raw('Teste de envio de email.', function ($message) use ($recipient) {
|
|
$message->to($recipient)->subject('Teste de envio de email');
|
|
});
|
|
return ['success' => true, 'message' => 'Email de teste enviado com sucesso.'];
|
|
}
|
|
}
|