dominservice / laravel-cms
Laravel CMS Backend
Installs: 120
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/dominservice/laravel-cms
Requires
- php: >=8.0
- ext-gd: *
- astrotomic/laravel-translatable: ^11.13
- dominservice/laravel-config: ^2.2
- dominservice/laravel-media-kit: ^1.0
- kalnoy/nestedset: ^6.0
- laravel/framework: ^9|^10|^11|^12
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0
- dev-main
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.12
- 3.3.11
- 3.3.10
- 3.3.9
- 3.3.8
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2026-01-07 23:22:40 UTC
README
dominservice/laravel-cms
Laravel CMS for multilingual content, categories and media (images & video) — integrated with dominservice/laravel-media-kit.
Installation • Configuration • Upload • Read • Migration v2/v3 → v4 • Tests • Support
Last updated: 2025-10-17 20:38 UTC
Table of Contents
- Highlights
- Requirements
- Installation
- Upgrade from v2/v3 to v4 (data migration)
- Configuration
- Models & relations
- Media: write (backward-compatible & recommended)
- Media: read (DynamicAvatarAccessor)
- Blade components / Variant URLs
- End‑to‑end examples
- Tests
- Support
- License
- Changelog (v4 summary)
Highlights
- Multilingual contents and categories (Astrotomic/Translatable).
- Nested categories tree (Nested Set).
- Media (images & video) with
kindmapped to MediaKit collection. - DynamicAvatarAccessor — dynamic names like
avatar_sm,video_hd,poster_display; if missing ⇒ returnsnull. - Content↔Content links with visibility windows and meta.
- Backward-compatible upload methods (
@deprecated) + new, MediaKit‑based APIs.
Requirements
- PHP 8.2+, Laravel 9–12
- dominservice/laravel-media-kit installed & configured
Installation
composer require dominservice/laravel-cms php artisan vendor:publish --provider="Dominservice\LaravelCms\ServiceProvider" php artisan vendor:publish --provider="Dominservice\MediaKit\MediaKitServiceProvider" php artisan migrate
In v4, all media reads are served via MediaKit. Legacy storage is migrated once (see below).
Upgrade from v2/v3 to v4 (data migration)
php artisan cms:media:migrate-v4
# dry run:
php artisan cms:media:migrate-v4 --dry-run
- Detects legacy tables from
config('cms.tables.*')(e.g.cms_content_files,cms_category_files,cms_content_videos). - Copies records into MediaKit (
media_assets) mapping kind → collection; video renditions stored in meta. - On success, drops legacy tables. On a clean v4 install: no action.
Configuration
CMS: config/cms.php
MediaKit: config/media-kit.php
Tables
categories,category_translationscontents,content_translationscontent_categories- legacy:
content_files,category_files,content_video(migration only)
Disks
cms.php → disks.* are historical logical disks; real disk/URL is controlled by MediaKit (media-kit.php).
Profiles & sizes (files.*)
Defines logical kinds, default display and list of sizes. In v4 it’s a logical contract; variants & URLs are produced by MediaKit.
Kind ↔ config mapping (file_config_key_map)
Aliases one config key to another for kind resolution.
Logical name mapping (file_kind_map)
Maps logical names consumed by accessors (e.g. avatar, video_avatar, video_poster) to concrete kinds.
Models & relations
Models\Content,Models\Category(translations, meta).- MediaKit relation: morph to
MediaAsset(model_type,model_id,collection).
Media: write (backward-compatible & recommended)
Backward‑compatible (deprecated in CMS)
use Dominservice\LaravelCms\Helpers\Media; // images Media::uploadModelImage($content, $uploadedFile, 'avatar', null, null, true); Media::uploadModelResponsiveImages($content, $uploadedFile, 'avatar'); Media::uploadModelImageWithDefaults($content, $uploadedFile, 'avatar'); // video renditions Media::uploadModelVideos($content, [ 'hd' => $fileHD, 'sd' => $fileSD ], 'video_avatar');
Recommended (MediaKit)
use Dominservice\MediaKit\Traits\HasMedia; class Content extends Model { use HasMedia; } // in your service/controller $content->addMedia($uploadedFile, 'avatar'); // original + variants by MediaKit
Media: read (DynamicAvatarAccessor)
class Content extends Model { use \Dominservice\LaravelCms\Traits\DynamicAvatarAccessor; } $content->avatar; // 'display' variant of 'avatar' $content->avatar_sm; // 'sm' variant $content->video_hd; // video avatar 'hd' $content->poster_display; // poster 'display'
Missing file/variant ⇒ returns null (no exceptions).
Blade components / Variant URLs
MediaKit exposes route:
/media/{{asset-uuid}}/{{variant}}/{{slug?}}
Accessors already return such URLs — plug them directly into <img> / <video>. Blade components from MediaKit can be used alongside existing views.
End‑to‑end examples
1) Upload form + render image
// Controller \Dominservice\LaravelCms\Helpers\Media::uploadModelImage($content, $request->file('avatar'), 'avatar'); // Blade <img src="{{ $content->avatar ?? asset('img/placeholder.png') }}" alt="avatar">
2) Video with renditions + poster
// Controller \Dominservice\LaravelCms\Helpers\Media::uploadModelVideos($content, [ 'hd' => $request->file('video_hd'), 'sd' => $request->file('video_sd'), ], 'video_avatar'); // Blade <video controls poster="{{ $content->poster_display }}"> <source src="{{ $content->video_hd }}" type="video/mp4"> <source src="{{ $content->video_sd }}" type="video/mp4"> </video>
3) Gallery (custom kind)
@foreach(($content->gallery_md_list ?? []) as $url) <img src="{{ $url }}" alt="gallery item"> @endforeach
Tests
Edge‑case coverage recommendations:
- missing files/kinds ⇒ returns
null, no exceptions, - dynamic names (
avatar_sm,video_hd,poster_display, custom kinds), - migration v2/v3 → v4 on empty DB, with data and in
--dry-runmode, - deprecated helper methods delegate to MediaKit,
- integration tests with Laravel app boot (artisan, migrations, storage fake).
Support
Support this project (Ko‑fi)
If this package saves you time, consider buying me a coffee: https://ko-fi.com/dominservice — thank you!
License
MIT — see LICENSE.
Changelog (v4 summary)
- Full read/write integration with MediaKit.
DynamicAvatarAccessor: dynamic names,nullon missing.- v2/v3 → v4 migration (legacy tables dropped afterwards).
- Deprecated upload methods preserved for smooth transition; new code should use MediaKit APIs.
