<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Storage;

class ExportUsersToJson extends Command
{
    protected $signature = 'users:export';
    protected $description = 'Export all users to a JSON file';

    public function handle()
    {
        $users = User::all();
        $json = $users->toJson(JSON_PRETTY_PRINT);
        Storage::disk('local')->put('users.json', $json);
        $this->info('Users have been exported to storage/app/users.json.');
    }
}
