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:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ship\Middleware;
|
||||
|
||||
use App\Containers\AppStructure\Models\Page;
|
||||
use App\Ship\Resources\Breadcrumb\ClientBreadcrumbPage;
|
||||
use App\Ship\Resources\Breadcrumb\ClientBreadcrumbSection;
|
||||
use App\Ship\Resources\Breadcrumb\ClientBreadcrumbSubSection;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GenerateBreadcrumbs
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$path = $request->path();
|
||||
$page = Page::where('path', '=', $path)
|
||||
->with('section.pages.section', 'section.mainSection')
|
||||
->first();
|
||||
|
||||
if ($page && isset($page->section)) {
|
||||
$breadcrumbs = [
|
||||
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
|
||||
'subSection' => new ClientBreadcrumbSubSection($page->section),
|
||||
'page' => new ClientBreadcrumbPage($page),
|
||||
];
|
||||
} else {
|
||||
$breadcrumbs = null;
|
||||
}
|
||||
|
||||
$request->merge(['breadcrumbs' => $breadcrumbs]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user