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
This commit is contained in:
F4ilji
2025-05-12 08:47:43 +05:00
parent 76deaf75f3
commit c01016a154
620 changed files with 16218 additions and 6073 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Ship\Services;
use App\Containers\AppStructure\Models\Page;
use App\Ship\Contracts\SeoServiceInterface;
use App\Ship\Enums\CacheKeys;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Route;
class SeoPageService implements SeoServiceInterface
{
public function getSeoForModel(Model $model): ?array
{
return $model->seo?->toArray();
}
public function getSeoForCurrentPage(): array|null
{
$path = $this->getCurrentPath();
$page = Cache::remember(
CacheKeys::PAGE_PREFIX->value . $path,
now()->addHours(1),
fn() => Page::where('path', $path)->first()
);
if ($page && $page->seo) {
return $page->seo->toArray();
}
return null;
}
private function getCurrentPath(): string
{
if (Route::currentRouteName() === 'page.view') {
return request()->path();
}
$routeUrl = route(Route::currentRouteName());
return ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
}
}