first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Models\Page;
|
||||
|
||||
|
||||
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 registered: " . $route->uri);
|
||||
} else {
|
||||
$this->info("Route already registered: " . $route->uri);
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('All routes have been processed.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user