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:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Page;
|
||||
|
||||
class PageObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Page "saving" event.
|
||||
*
|
||||
* Bir sayfa homepage olarak işaretlendiğinde,
|
||||
* diğer tüm sayfaların homepage işaretini kaldır.
|
||||
*/
|
||||
public function saving(Page $page): void
|
||||
{
|
||||
// Eğer bu sayfa homepage olarak işaretleniyorsa
|
||||
if ($page->is_homepage) {
|
||||
// Diğer tüm sayfaların homepage işaretini kaldır
|
||||
Page::where('id', '!=', $page->id)
|
||||
->where('is_homepage', true)
|
||||
->update(['is_homepage' => false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user