<?php

// use Illuminate\Database\Capsule\Manager as DB;
use Webuccino\Install\Core\App;
use Webuccino\Install\Core\Database;

$db = App::resolve(Database::class);

$field = htmlspecialchars($_POST['field']);

$value = htmlspecialchars($_POST[$field]);


if ($field === 'username') {
  $checkExists = $db->checkExist('Users', [['user_name', $value]]);
  if ($checkExists)
    echo json_encode(false);
  else
    echo json_encode(true);
} else if ($field === 'email') {

  $checkExists = $db->checkExist('Users', [['Email', $value]]);
  if ($checkExists)
    echo json_encode(false);
  else
    echo json_encode(true);
}