fbollon/lara-cms-lite

Laravel应用轻量级内容管理系统

0.3.3 2024-01-08 15:41 UTC

This package is auto-updated.

Last update: 2024-09-08 17:10:52 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

laracms-lite 的创建是为了让一些用户能够在内网的预定义业务应用页面上添加和管理内容,这避免了需要修改应用程序源代码来更改主页或其他页面的文本。我们还可以使用此包向现有应用程序添加新闻风格的页面或博客。

安装

支持从 6.x10.x 的 Laravel。

您可以通过 composer 安装此包

composer require fbollon/lara-cms-lite

发布资产、配置和视图

  • tinymce 发布到 public/vendor/tinymce
  • lara-cms-lite 配置文件,根据注释在 config/lara-cms-lite.php 中调整值
  • lara-cms-lite 视图发布到 views/vendor/lara-cms-lite
php artisan vendor:publish --provider="Fbollon\LaraCmsLite\LaraCmsLiteServiceProvider"

或者通过标签发布

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

要强制发布,请添加 --force 标志。

创建所需的表

php artisan migrate

将创建一个名为 'contents' 的表,如果您的应用程序中已存在同名表,请在 config/lara-cms-lite.php 中更改 'table' 的值

授权

向您的 \App\User 文件中添加 1 个方法 canManageLaraCmsLiteContent(),并添加您自己的逻辑

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

    }

用法

访问您的应用程序 URL: http://yourApplication/contents 以开始创建和管理内容。

在您的应用程序现有视图中显示内容

在您默认布局中,将此添加到您想要在布局中显示内容的位置

@if (!empty($contents) && count($contents))
@include('lara-cms-lite::layouts.partials.contents')
@endif

根据您在方法控制器中允许用户添加内容的范围,添加以下内容

// 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 了解最近更改的详细信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全

鸣谢

许可协议

MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件

Laravel 包模板

此包是使用 Laravel 包模板 生成的。