refactor sitemap generation and navigation handling; remove old GenerateSitemap command, update to use tasks for better organization, and enhance navigation data retrieval
This commit is contained in:
@@ -3,51 +3,19 @@
|
||||
namespace App\Containers\AppStructure\UI\CLI\Commands;
|
||||
|
||||
use App\Ship\Abstracts\Commands\ConsoleCommand as AbstractConsoleCommand;
|
||||
use App\Containers\AppStructure\Models\Page;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Containers\AppStructure\Tasks\RegisterApplicationRoutesTask;
|
||||
|
||||
class RegisterRoutes extends AbstractConsoleCommand
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'routes:register';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Register application routes in the database';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(private readonly RegisterApplicationRoutesTask $registerApplicationRoutesTask)
|
||||
{parent::__construct();}
|
||||
|
||||
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->registerApplicationRoutesTask->run();
|
||||
$this->info('Все маршруты успешно проверены.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user