migration rollback at path, additional info routs

This commit is contained in:
2024-12-13 14:27:46 +03:00
parent 967bcc28b5
commit 73a64ff717
13 changed files with 156 additions and 76 deletions

View File

@ -64,6 +64,11 @@ class Out
echo $this->get($string, $foreground_color, $background_color) . "\n";
}
public function inLine($string, $foreground_color = null, $background_color = null): void
{
echo $this->get($string, $foreground_color, $background_color) ;
}
// Returns all foreground color names
public function getForegroundColors()
{

View File

@ -16,10 +16,23 @@ class MainController extends ConsoleController
public function actionHelp(): void
{
// Debug::dd(App::$collector->getData());
// foreach (App::$collector->getDescriptions() as $description){
// $this->out->r($description, "green");
// }
$routs = App::$collector->getData()->getStaticRoutes();
foreach ($routs as $rout => $data){
$additionalInfo = $data['GET'][3];
if (isset($additionalInfo['description']) and $additionalInfo['type'] === "console"){
$this->out->inLine($rout . " - ", "green");
$this->out->inLine($additionalInfo['description'], 'yellow');
$this->out->r("");
if (isset($additionalInfo['params'])){
foreach ($additionalInfo['params'] as $key => $param){
$this->out->inLine($key . " - ", "green");
$this->out->inLine($param, 'yellow');
$this->out->r("");
}
}
$this->out->r("");
}
}
}
}

View File

@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public string $migration;
/**
* Run the migrations.
*/

View File

@ -1,16 +1,26 @@
<?php
use kernel\App;
use kernel\console\controllers\MigrationController;
use Phroute\Phroute\RouteCollector;
App::$collector->console("hello", [\kernel\console\controllers\MainController::class, "indexAction"]);
App::$collector->console("help", [\kernel\console\controllers\MainController::class, "actionHelp"]);
App::$collector->group(["prefix" => "migration"], callback: function (RouteCollector $router){
App::$collector->console('run', [\kernel\console\controllers\MigrationController::class, 'actionRun']);
App::$collector->console('init', [\kernel\console\controllers\MigrationController::class, 'actionCreateMigrationTable']);
App::$collector->console('create', [\kernel\console\controllers\MigrationController::class, 'actionCreate']);
App::$collector->console('rollback', [\kernel\console\controllers\MigrationController::class, 'actionRollback']);
App::$collector->console('run',
[MigrationController::class, 'actionRun'],
additionalInfo: ['description' => 'Запуск существующих миграций']
);
App::$collector->console('init',
[MigrationController::class, 'actionCreateMigrationTable'],
additionalInfo: ['description' => 'Инициализация миграций']
);
App::$collector->console('create',
[MigrationController::class, 'actionCreate'],
additionalInfo: ['description' => 'Создание миграции', 'params' => ['--name' => 'Название миграции', '--path' => 'Путь по которому будет создана миграция']]
);
App::$collector->console('rollback', [MigrationController::class, 'actionRollback']);
});
App::$collector->group(["prefix" => "admin-theme"], callback: function (RouteCollector $router){