'boolean', 'data' => 'array', ]; public static function getByName(string $name): ?self { return static::where('name', $name)->where('is_active', true)->first(); } // Рендерит блок через соответствующий Blade-шаблон, возвращает готовый HTML public function render(): string { if (!$this->layout || !$this->data) { return ''; } $view = 'blocks.' . $this->layout; if (!view()->exists($view)) { return ''; } return view($view, ['data' => $this->data])->render(); } // Определение макета из реестра (null если макет не задан или не найден) public function layoutDefinition(): ?array { return $this->layout ? BlockLayoutRegistry::get($this->layout) : null; } // Страницы, на которых размещён этот блок public function pages(): BelongsToMany { return $this->belongsToMany(Page::class, 'page_sections')->withPivot('sort_order'); } }