Files
ntspi-app/app/Console/Commands/RegisterRoutes.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

43 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Containers\AppStructure\Models\Page;
use Illuminate\Support\Facades\Route;
use Illuminate\Console\Command;
class RegisterRoutes extends Command
{
protected $signature = 'routes:register';
protected $description = 'Register application routes in the database';
public function handle()
{
$routes = Route::getRoutes();
foreach ($routes as $route) {
// Проверяем, существует ли маршрут в базе данных
if (!Page::where('path', '=', $route->uri)->where('is_registered', '=', true)->exists()) {
// Если не существует, создаем новую запись
Page::create([
'path' => $route->uri,
'is_registered' => true,
'is_url' => false,
'searchable' => false,
'code' => 200,
]);
$this->info("Маршрут зарегистрирован: " . $route->uri);
} else {
$this->info("Маршрут уже существует: " . $route->uri);
}
}
$this->info('Все маршруты успешно проверены.');
}
}