ultimatepos/Modules/AssetExchange/Console/AssetExchangeUiCheck.php

76 lines
2.4 KiB
PHP

<?php
namespace Modules\AssetExchange\Console;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class AssetExchangeUiCheck extends Command
{
protected $signature = 'pos:assetexchangeUiCheck';
protected $description = 'Verify AssetExchange routes, views and language files exist';
public function handle(): int
{
$ok = true;
$views = [
'dashboard/index.blade.php',
'listings/index.blade.php',
'appraisals/show.blade.php',
'appraisals/report.blade.php',
'inquiries/index.blade.php',
'inquiries/show.blade.php',
'research/workspace.blade.php',
'deals/show.blade.php',
'portal/listings/create.blade.php',
'portal/inquiries/index.blade.php',
'portal/notifications/index.blade.php',
];
$base = module_path('AssetExchange', 'Resources/views');
foreach ($views as $view) {
$path = $base.'/'.$view;
$exists = File::exists($path);
$this->line(($exists ? '[OK] ' : '[FAIL] ').'view '.$view);
$ok = $ok && $exists;
}
$routes = [
'/asset-exchange/dashboard',
'/asset-exchange/listings',
'/asset-exchange/appraisals',
'/asset-exchange/inquiries',
'/asset-exchange/research',
'/asset-exchange/deals',
'/asset-exchange/notifications',
'/asset-exchange/settings',
'/customer/asset-exchange/listings',
'/supplier/asset-exchange/inquiries',
];
foreach ($routes as $route) {
$registered = collect(app('router')->getRoutes())->contains(fn ($r) => '/'.ltrim($r->uri(), '/') === $route || $r->uri() === ltrim($route, '/'));
$this->line(($registered ? '[OK] ' : '[FAIL] ').'route '.$route);
$ok = $ok && $registered;
}
foreach (['fa', 'en'] as $locale) {
$lang = module_path('AssetExchange', 'Resources/lang/'.$locale.'/lang.php');
$exists = File::exists($lang);
$this->line(($exists ? '[OK] ' : '[FAIL] ').'lang '.$locale);
$ok = $ok && $exists;
}
if ($ok) {
$this->info('AssetExchange UI check passed.');
return self::SUCCESS;
}
$this->error('AssetExchange UI check failed.');
return self::FAILURE;
}
}