| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | <?phpnamespace App\Console\Commands;use Illuminate\Console\Command;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Storage;use Symfony\Component\Process\Process;class BackupInterface extends Command{    /**     * The name and signature of the console command.     *     * @var string     */    protected $signature = 'tty:backupInterface';    /**     * The console command description.     *     * @var string     */    protected $description = '备份数据库';    protected $process;    /**     * Create a new command instance.     *     * @return void     */    public function __construct()    {        parent::__construct();    }    /**     * Execute the console command.     *     * @return int     */    public function handle()    {        $this->exportData();        return 0;    }    private function exportData()    {        $list = DB::table('dep_interface')->get();        foreach ($list as $row) {            $row = get_object_vars($row);            $websiteId = $row['website_id'];            $row['request_settings'] = json_decode($row['request_settings'], true);            $row['condition_settings'] = json_decode($row['condition_settings'], true);            $row['sort_settings'] = json_decode($row['sort_settings'], true);            $row['result_settings'] = json_decode($row['result_settings'], true);            $row['conditions'] = json_decode($row['conditions'], true);            unset($row['id']);            unset($row['mid']);            unset($row['weight']);            unset($row['is_delete']);            unset($row['created_at']);            unset($row['updated_at']);            $assemble_id = $row['assemble_id'];            $assembleInfo = DB::table('sys_assemble')->where('id', $assemble_id)->first();            if ($assembleInfo) {                $row['assemble_id'] = $assembleInfo->schema;            } else {                $row['assemble_id'] = 0;            }            if (!file_exists(storage_path('interface/' . $websiteId))) {                mkdir(storage_path('interface/' . $websiteId), "0777", true);            }            file_put_contents(storage_path('interface/' . $websiteId . '/' . $row['en_alias'] . '.js'), 'return ' . json_encode($row));        }    }}
 |