Implement dynamic template rendering and page observer: Enhanced PageController to support dynamic header and footer templates, utilizing TemplateService for placeholder replacement. Introduced PageObserver to manage homepage status across pages. Updated routes for improved debugging and dynamic homepage display. Refactored views to accommodate new templating system.
This commit is contained in:
+54
-3
@@ -3,11 +3,62 @@
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\PageController;
|
||||
use App\Http\Controllers\BlogController;
|
||||
use App\Models\Page;
|
||||
|
||||
// Home -> admin'de işaretli anasayfayı (veya 'home' slug'ını) göster
|
||||
Route::get('/', [PageController::class, 'index'])->name('home');
|
||||
Route::get('/{slug}', [PageController::class, 'show'])->name('page.show');
|
||||
// Debug Route - Veritabanı kontrolü
|
||||
Route::get('/debug-homepage', function () {
|
||||
$page = Page::with(['headerTemplate', 'footerTemplate'])
|
||||
->where('is_homepage', true)
|
||||
->where('status', 'published')
|
||||
->latest('updated_at')
|
||||
->first();
|
||||
|
||||
if (!$page) {
|
||||
return response()->json([
|
||||
'error' => 'Homepage bulunamadı!',
|
||||
'all_pages' => Page::select('id', 'title', 'slug', 'is_homepage', 'status')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'page' => [
|
||||
'id' => $page->id,
|
||||
'title' => $page->title,
|
||||
'slug' => $page->slug,
|
||||
'is_homepage' => $page->is_homepage,
|
||||
'status' => $page->status,
|
||||
],
|
||||
'header_template' => [
|
||||
'id' => $page->header_template_id,
|
||||
'exists' => $page->headerTemplate ? true : false,
|
||||
'title' => $page->headerTemplate?->title,
|
||||
'data_filled' => !empty($page->header_data),
|
||||
'data' => $page->header_data,
|
||||
],
|
||||
'footer_template' => [
|
||||
'id' => $page->footer_template_id,
|
||||
'exists' => $page->footerTemplate ? true : false,
|
||||
'title' => $page->footerTemplate?->title,
|
||||
'data_filled' => !empty($page->footer_data),
|
||||
'data' => $page->footer_data,
|
||||
],
|
||||
'sections' => [
|
||||
'count' => is_array($page->sections) ? count($page->sections) : 0,
|
||||
'data' => $page->sections,
|
||||
],
|
||||
'sections_data' => [
|
||||
'count' => is_array($page->sections_data) ? count($page->sections_data) : 0,
|
||||
'data' => $page->sections_data,
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
// Homepage -> admin panelinde "is_homepage" olarak işaretli sayfa dinamik olarak gösterilir
|
||||
Route::get('/', [PageController::class, 'index'])->name('homepage');
|
||||
|
||||
// Blog
|
||||
Route::get('/blog', [BlogController::class, 'index'])->name('blog.index');
|
||||
Route::get('/blog/{slug}', [BlogController::class, 'show'])->name('blog.show');
|
||||
|
||||
// Pages (en sonda olmalı - catch-all)
|
||||
Route::get('/{slug}', [PageController::class, 'show'])->name('page.show');
|
||||
|
||||
Reference in New Issue
Block a user