56 lines
1.5 KiB
PHP
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());
|
|
}
|
|
}
|
|
}
|