| Install | |
|---|---|
composer require aichadigital/lara-content |
|
| PHP: | ^8.3 |
ALPHA VERSION: This package is in early development. The API may change without notice. Not recommended for production use yet.
Content management package for Laravel with pages, posts, blocks and menus. Supports Blade templates with optional Livewire components for interactivity. Includes multilingual support via Spatie Translatable.
Install via composer:
composer require aichadigital/lara-content
Publish and run migrations:
php artisan vendor:publish --tag="lara-content-migrations"
php artisan migrate
Publish the config file:
php artisan vendor:publish --tag="lara-content-config"
Optionally publish views for customization:
php artisan vendor:publish --tag="lara-content-views"
Key configuration options in config/content.php:
return [
// User ID type: 'auto', 'int', 'uuid', 'ulid'
'user_id_type' => env('CONTENT_USER_ID_TYPE', 'auto'),
// Author model for posts
'author_model' => env('CONTENT_AUTHOR_MODEL', 'App\\Models\\User'),
// Cache settings
'cache' => [
'enabled' => env('CONTENT_CACHE_ENABLED', true),
'default_ttl' => env('CONTENT_CACHE_TTL', 3600),
],
// Security: allowed HTML tags and attributes
'security' => [
'allowed_tags' => ['p', 'br', 'strong', 'em', 'a', 'img', ...],
'allowed_attributes' => [...],
],
];
Pages support flexible layouts with multiple content zones:
use AichaDigital\LaraContent\Models\Page;
// Create a page
$page = Page::create([
'title' => 'About Us',
'slug' => 'about-us',
'layout' => 'sidebar-right',
'status' => 'published',
]);
// Add blocks to zones
$page->blocks()->create([
'zone' => 'main',
'block_type' => 'html',
'content' => ['html' => '<p>Welcome to our company...</p>'],
'order' => 1,
]);
Blog posts with author attribution:
use AichaDigital\LaraContent\Models\Post;
$post = Post::create([
'title' => 'Getting Started',
'slug' => 'getting-started',
'content' => '# Introduction...',
'author_id' => auth()->id(),
'status' => 'published',
'published_at' => now(),
]);
Hierarchical menus with nested items:
use AichaDigital\LaraContent\Models\Menu;
$menu = Menu::create([
'name' => 'Main Navigation',
'slug' => 'main-nav',
]);
$menu->items()->create([
'title' => 'Home',
'url' => '/',
'order' => 1,
]);
Render blocks in your views:
@foreach($page->blocks as $block)
{!! app(BlockRenderer::class)->render($block) !!}
@endforeach
| Slug | Name | Zones |
|---|---|---|
single |
Single Column | main |
sidebar-left |
Sidebar Left | main, sidebar |
sidebar-right |
Sidebar Right | main, sidebar |
two-column |
Two Column | left, right |
three-column |
Three Column | left, center, right |
| Slug | Name | Interactive | Description |
|---|---|---|---|
html |
HTML Block | No | Raw HTML content |
recent-posts |
Recent Posts | No | List of recent posts |
menu |
Menu Block | No | Render a menu |
contact-form |
Contact Form | Yes | Livewire contact form |
Register custom layouts in your service provider:
use AichaDigital\LaraContent\Registries\LayoutRegistry;
use App\Content\Layouts\CustomLayout;
public function boot(): void
{
app(LayoutRegistry::class)->register(new CustomLayout());
}
Register custom blocks:
use AichaDigital\LaraContent\Registries\BlockRegistry;
use App\Content\Blocks\CustomBlock;
public function boot(): void
{
app(BlockRegistry::class)->register(new CustomBlock());
}
composer test
Please see CHANGELOG for recent changes.
AGPL-3.0-or-later. See License File for details.
VERSION ALPHA: Este paquete está en desarrollo inicial. La API puede cambiar sin previo aviso. No recomendado para producción todavía.
Paquete de gestión de contenido para Laravel con páginas, posts, bloques y menús. Soporta plantillas Blade con componentes Livewire opcionales para interactividad. Incluye soporte multilingüe via Spatie Translatable.
Instalar via composer:
composer require aichadigital/lara-content
Publicar y ejecutar migraciones:
php artisan vendor:publish --tag="lara-content-migrations"
php artisan migrate
Publicar archivo de configuración:
php artisan vendor:publish --tag="lara-content-config"
Opcionalmente publicar vistas para personalización:
php artisan vendor:publish --tag="lara-content-views"
use AichaDigital\LaraContent\Models\Page;
// Crear una página
$page = Page::create([
'title' => 'Sobre Nosotros',
'slug' => 'sobre-nosotros',
'layout' => 'sidebar-right',
'status' => 'published',
]);
// Añadir bloques a zonas
$page->blocks()->create([
'zone' => 'main',
'block_type' => 'html',
'content' => ['html' => '<p>Bienvenido a nuestra empresa...</p>'],
'order' => 1,
]);
use AichaDigital\LaraContent\Models\Post;
$post = Post::create([
'title' => 'Primeros Pasos',
'slug' => 'primeros-pasos',
'content' => '# Introducción...',
'author_id' => auth()->id(),
'status' => 'published',
'published_at' => now(),
]);
use AichaDigital\LaraContent\Models\Menu;
$menu = Menu::create([
'name' => 'Navegación Principal',
'slug' => 'nav-principal',
]);
$menu->items()->create([
'title' => 'Inicio',
'url' => '/',
'order' => 1,
]);
| Slug | Nombre | Zonas |
|---|---|---|
single |
Una Columna | main |
sidebar-left |
Sidebar Izquierda | main, sidebar |
sidebar-right |
Sidebar Derecha | main, sidebar |
two-column |
Dos Columnas | left, right |
three-column |
Tres Columnas | left, center, right |
| Slug | Nombre | Interactivo | Descripción |
|---|---|---|---|
html |
Bloque HTML | No | Contenido HTML |
recent-posts |
Posts Recientes | No | Lista de posts recientes |
menu |
Bloque Menú | No | Renderiza un menú |
contact-form |
Formulario Contacto | Sí | Formulario Livewire |
use AichaDigital\LaraContent\Registries\LayoutRegistry;
use App\Content\Layouts\MiLayout;
public function boot(): void
{
app(LayoutRegistry::class)->register(new MiLayout());
}
use AichaDigital\LaraContent\Registries\BlockRegistry;
use App\Content\Blocks\MiBloque;
public function boot(): void
{
app(BlockRegistry::class)->register(new MiBloque());
}
composer test
AGPL-3.0-or-later. Ver archivo de licencia para detalles.