Lara-cms-lite was created to allow some users to add and manage content on predefined business application pages in intranet, this avoids having to modify the application source code to change a text on a home page or other. We could also use this package to add a news-style page or blog to existing application.
Laravel from 6.x
to 11.x
are supported.
You can install the package via composer:
composer require fbollon/lara-cms-lite
Publish assets, config and views
- tinymce to public/vendor/tinymce
- lara-cms-lite config file and adjust values if needed in config/lara-cms-lite.php based on comments
- lara-cms-lite views to views/vendor/lara-cms-lite
php artisan vendor:publish --provider="Fbollon\LaraCmsLite\LaraCmsLiteServiceProvider"
Or publish by tags
php artisan vendor:publish --provider="Fbollon\LaraCmsLite\LaraCmsLiteServiceProvider" --tag=public
php artisan vendor:publish --provider="Fbollon\LaraCmsLite\LaraCmsLiteServiceProvider" --tag=config
php artisan vendor:publish --provider="Fbollon\LaraCmsLite\LaraCmsLiteServiceProvider" --tag=views
To force publishing add
--force
flag.
Create required tables
php artisan migrate
A table named 'contents' will be created, if a table with the same name already exists in your app change value of 'table' in config/lara-cms-lite.php
Add 1 method canManageLaraCmsLiteContent() to your \App\User file with your own logic
Define a gate in your App\Providers\AuthServiceProvider
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Gate::define('lara-cms-lite-manage', function ($user) {
return $user->canManageLaraCmsLiteContent();
});
}
Visit your application url : http://yourApplication/contents to start creating and managing content .
To display content in existing views of your application
In you default layout add this where you want to display content in your layout
@if (!empty($contents) && count($contents))
@include('lara-cms-lite::layouts.partials.contents')
@endif
Depending where you allow users to add content in yours methods controller add
// import model
use Fbollon\LaraCmsLite\Models\Content;
// for each method you allow to display content
public function xxx()
{
// get content
$contents = Content::getContextualContent();
// and send content to the view
return view('xxx.xxx', compact('contents'));
}
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.