82 lines
2.3 KiB
PHP
Executable File
82 lines
2.3 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace kodorvan\neurobot;
|
|
|
|
// Files of the project
|
|
use kodorvan\neurobot\models\account,
|
|
kodorvan\neurobot\models\authorizations,
|
|
kodorvan\neurobot\models\chat,
|
|
kodorvan\neurobot\models\code,
|
|
kodorvan\neurobot\models\bundle,
|
|
kodorvan\neurobot\models\tariff,
|
|
kodorvan\neurobot\models\enumerations\tariff as tariff_type;
|
|
|
|
// Svoboda time
|
|
use svoboda\time\statement as svoboda;
|
|
|
|
// Baza database
|
|
use mirzaev\baza\record;
|
|
|
|
// Enabling debugging
|
|
/* ini_set('error_reporting', E_ALL);
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1); */
|
|
|
|
// Initializing path to the public directory
|
|
define('INDEX', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'public');
|
|
|
|
// Initializing path to the root directory
|
|
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
|
|
|
// Initializing path to the settings directory
|
|
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
|
|
|
// Initializing path to the storage directory
|
|
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
|
|
|
// Initializing path to the databases directory
|
|
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
|
|
|
|
// Initializing path to the localizations directory
|
|
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
|
|
|
|
// Initiailizing telegram key
|
|
define('TELEGRAM_KEY', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
|
|
|
|
// Initializing dependencies
|
|
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
// Initializing counter for generating codes
|
|
$amount = 1;
|
|
|
|
for ($i = 0; $i < $amount; ++$i) {
|
|
// Creating codes
|
|
|
|
// Creating the tariff
|
|
$tariff = new tariff()->write(type: tariff_type::endless);
|
|
|
|
echo "Created the tariff ($tariff)";
|
|
|
|
// Creating the code
|
|
$code = new code()->write(code: 'admin', tariff: $tariff);
|
|
|
|
echo " for the created code ($code)";
|
|
|
|
// Search for the created code
|
|
$created = new code()->read(
|
|
filter: fn(record $record) => $record->identifier === $code,
|
|
);
|
|
|
|
if ($created instanceof code) {
|
|
// Found the created code
|
|
|
|
echo ": $created->value\n";
|
|
} else {
|
|
// Not found the created code
|
|
|
|
echo "\n";
|
|
}
|
|
}
|