### Install and publish migrations with composer and artisan Source: https://github.com/roundly-consulting/posts-for-laravel/blob/main/README.md Run these commands to install the package and publish all required migrations before running migrate. Requires PHP 8.4 and Laravel 12 or 13. Set POSTS_KEY_TYPE (and POSTS_PRIMARY_KEY_TYPE) before migrating if using UUID/ULID keys. ```bash composer require roundly-consulting/posts-for-laravel php artisan vendor:publish --tag="posts-migrations" php artisan vendor:publish --tag="media-migrations" php artisan vendor:publish --tag="likes-migrations" php artisan vendor:publish --tag="reports-migrations" php artisan vendor:publish --tag="approvals-migrations" php artisan migrate ``` -------------------------------- ### Create and publish a multilingual post with Posts facade Source: https://github.com/roundly-consulting/posts-for-laravel/blob/main/README.md Use the Posts facade to build a draft, set localized titles, perex, content, author, tags, and SEO data, then publish it. The by() method accepts any author model keyed by bigint, uuid, or ulid. Tags are found or created by name. The getTranslation() call returns the Slovak title. ```php use RoundlyConsulting\Posts\DataTransferObjects\SeoData; use RoundlyConsulting\Posts\Facades\Posts; $post = Posts::draft() ->title('en', 'Hello world')->title('sk', 'Ahoj svet') ->perex('en', 'A short intro') ->content('en', '

…

') ->by($user) // any author model, bigint/uuid/ulid keyed ->tags(['laravel', 'php']) // found or created by name ->seo(new SeoData(canonical: 'https://example.test/hello-world')) ->publish(); $post->getTranslation('title', 'sk'); // 'Ahoj svet' ``` -------------------------------- ### Read posts by slug, published, archive, and route binding Source: https://github.com/roundly-consulting/posts-for-laravel/blob/main/README.md Find posts by slug with locale fallback, query published posts, archive or unpublish a post, and bind the {post} route parameter by slug. The findBySlug method checks current locale, then fallback, then any locale. ```php use RoundlyConsulting\Posts\Models\Post; Posts::findBySlug('hello-world'); // current locale → fallback → any locale Posts::published()->latest('published_at')->paginate(); Posts::archive($post); // or unpublish() back to draft Route::get('/posts/{post}', fn (Post $post) => view('posts.show', compact('post')))->name('posts.show'); ``` -------------------------------- ### Render post SEO tags, JSON-LD, and content in Blade Source: https://github.com/roundly-consulting/posts-for-laravel/blob/main/README.md Use these Blade directives to output SEO meta tags, schema.org BlogPosting JSON-LD, the localized title, and raw HTML content. The renderContent() method outputs trusted or sanitized content only. ```blade {!! $post->renderMetaTags() !!} {{-- , description, canonical, og:*, twitter:*, robots --}} {!! $post->renderJsonLd() !!} {{-- schema.org BlogPosting --}} <h1>{{ $post->title }}</h1> {{-- current locale, with fallback --}} {!! $post->renderContent() !!} {{-- raw HTML: trusted or sanitized content only --}} ```