gps_system/app/Console/Commands/TestTraccarConnection.php
sackey 6b878bb0a0
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Initial commit
2025-09-12 16:19:56 +00:00

56 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Services\TraccarService;
class TestTraccarConnection extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'traccar:test';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Test Traccar API connection';
/**
* Execute the console command.
*/
public function handle(TraccarService $traccarService)
{
$this->info('Testing Traccar API connection...');
try {
// Test connection
if ($traccarService->testConnection()) {
$this->info('✅ Connection successful!');
// Get server info
$serverInfo = $traccarService->getServerInfo();
$this->info('Server Version: ' . ($serverInfo['version'] ?? 'Unknown'));
// Get devices
$devices = $traccarService->getDevices();
$this->info('Total devices: ' . count($devices));
// Get positions
$positions = $traccarService->getPositions();
$this->info('Total positions: ' . count($positions));
} else {
$this->error('❌ Connection failed!');
}
} catch (\Exception $e) {
$this->error('❌ Error: ' . $e->getMessage());
}
}
}