The existing sync commands have been enhanced with the following improvements:
Add these to your .env file for dynamic URL configuration:
# API Base URL (includes full path structure)
BASE_URL=http://localhost/staff/
# API Configuration
STAFF_API_TOKEN=YWZyY2FjZGNzdGFmZnRyYWNrZXI
STAFF_API_USERNAME=your_username
STAFF_API_PASSWORD=your_password
# Basic sync
php artisan staff:sync
# Force sync even if counts match
php artisan staff:sync --force
# Basic sync
php artisan divisions:sync
# Force sync even if counts match
php artisan divisions:sync --force
# Basic sync
php artisan directorates:sync
# Force sync even if counts match
php artisan directorates:sync --force
BASE_URL from environmentSTAFF_API_TOKENconfig/services.php==================================================
SYNC RESULTS
==================================================
Source API Records: 250
Database Records: 250
Created: 5
Updated: 245
Failed: 0
Skipped: 0
✅ SUCCESS: Source count matches database count
==================================================
The sync commands now use dynamic configuration from config/services.php:
'staff_api' => [
'base_url' => env('BASE_URL', 'http://localhost/staff/'),
'token' => env('STAFF_API_TOKEN', 'YWZyY2FjZGNzdGFmZnRyYWNrZXI'),
'username' => env('STAFF_API_USERNAME'),
'password' => env('STAFF_API_PASSWORD'),
'endpoints' => [
'staff' => '/share/get_current_staff',
'divisions' => '/share/divisions',
'directorates' => '/share/directorates',
],
],
# Check staff count
php artisan tinker
>>> \App\Models\Staff::count()
# Check divisions count
>>> \App\Models\Division::count()
# Check directorates count
>>> \App\Models\Directorate::count()
# Run all sync commands
php artisan staff:sync
php artisan divisions:sync
php artisan directorates:sync
# Watch sync logs in real-time
tail -f storage/logs/laravel-$(date +%Y-%m-%d).log | grep -i sync
# Run with verbose output
php artisan staff:sync -vvv
# Check API configuration
php artisan tinker
>>> config('services.staff_api')
The improved sync commands provide better reliability, visibility, and maintainability for your data synchronization needs.