fbollon/lara-cms-lite

Content management system lite for Laravel app

0.3.3 2024-01-08 15:41 UTC

This package is auto-updated.

Last update: 2024-04-08 16:06:41 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

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.

Installation

Laravel from 6.x to 10.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

Authorization

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();
        });

    }

Usage

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'));
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.