cogroup/cms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cogroup/cms

Composer 安装命令:

composer require cogroup/cms

包简介

CMS for all laravel projects

README 文档

README

Latest Stable Version License

Important:

To avoid incompatibilities, it is necessary to remove popper, jquery and bootstrap from webpack; our library already includes the most recent ones.

Comment all require files in:

resources/js/bootstrap.js

Cms

For Laravel < 5.7, please use the 1.6 branch!

For Laravel <= 6, please use the 1.8 branch!

For Laravel 7, please use the 2.0 branch!

For Laravel 8, please use the 3.0 branch!

COgroup - CMS package is a flexible way to add basic CMS system with Role-based Permissions to Laravel.

Contents

Installation

  1. Run the command to install laravel/ui and generate scaffolding
composer require laravel/ui
php artisan ui bootstrap --auth
  1. In order to install COgroup - CMS, just add the following to your composer.json. Then run composer update:
"cogroup/cms": "^3.0"

or run the next command:

composer require cogroup/cms "3.*"
  1. fixed Auth::routes, to avoid Clouser error

Remove Auth::routes from web.php file

  1. Run the command below to publish the package config file config/cogroupcms.php:
php artisan vendor:publish --provider="Cogroup\Cms\CmsServiceProvider"
  1. Run the command below to execute migrations
php artisan migrate
  1. Run the command below to seed
php artisan db:seed --class=CogroupCmsSeeder
  1. Run the command below to re-publish assets, config, custom error views, font, migrations and translations
php artisan cogroupcms:assets
php artisan cogroupcms:config
php artisan cogroupcms:errorviews
php artisan cogroupcms:fonts
php artisan cogroupcms:migrations
php artisan cogroupcms:seeders
php artisan cogroupcms:translations
  1. Change default User model in config/auth.php file
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => Cogroup\Cms\Models\User::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

InterventionImage

After you have installed Intervention Image, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

Intervention\Image\ImageServiceProvider::class

Add the facade of this package to the $aliases array.

'ImageManager' => Intervention\Image\Facades\Image::class

Now the Image Class will be auto-loaded by Laravel.

Publish configuration in Laravel 5

$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravelRecent"

Configuration

Set the property values in the config/cogroupcms.php. These values will be used by cogroup-cms to refer to the correct prefix, color theme and URI to CMS access.

User relation to roles

You may now run it with the artisan migrate command:

php artisan migrate

After the migration, seven new tables will be present:

  • files — manage files into CMS
  • modules — modules for CMS
  • noworkingdays — dates for special days, and to be able to discount in a range of dates
  • roles — roles for CMS
  • roles_access — relations between roles and modules access
  • settings — CMS basic settings (sitename, emailname, etc.)
  • user — Table for users and specific rol user

Models

Files

The Files model has eight main attributes:

  • originalname — Original name of the file.
  • diskname — name of the file into system after upload.
  • extension — extension of the file.
  • size — size of the file.
  • mimetype — Mime type of the file.
  • alt — Texto for label alt in HTML.
  • width — when is image, a width attribute.
  • height — when is image, a height attribute.
  • ispublic — determines whether a file is public or not.
  • created_at — determines the creation date.
  • updated_at — determine the update date.

Modules

The Modules model has ten main attributes:

  • moduleslug — Slug name for the module, to verify permissions.
  • modulename — Module name to show.
  • description — A more detailed explanation of what the Module does.
  • active — module is active or not.
  • url — url to acces the module. The url should not have the domain.
  • icon — font icon of the module.
  • parent — When is a submodule, id of the parent module. When is a father module is 0.
  • order — order to show module in the menu.
  • inmenu — determines if the module is show in the main menu.
  • permissions — Determine what permissions the module needs. They must be separated by commas. Example: "view, create".

NoWorkingDays

The NoWorkingDays model has two main attributes:

  • date — special day date.
  • active — determines whether a date is active or not.
  • created_at — determines the creation date.
  • updated_at — determine the update date.

Roles

The Role model has two main attributes:

  • rolname — Unique name for the Role, used for looking up role information in the application layer. For example: "admin", "owner", "employee".
  • description — A more detailed explanation of what the Role does.
  • created_at — determines the creation date.
  • updated_at — determine the update date.

RolesAccess

The RolesAccess model has six main attributes:

  • roles_id — Unique key for the Role, used for relation to table roles.
  • modules_id — Unique key for the modules, used for relation to table modules.
  • view — Set the permission to see a module or submodule.
  • create — Set the permission to create content in a module or submodule.
  • update — Set the permission to update content in a module or submodule.
  • delete — Set the permission to delete content in a module or submodule.
  • created_at — determines the creation date.
  • updated_at — determine the update date.

Settings

The Settings model has two main attributes:

  • setting — Unique name for the setting.
  • defaultvalue — A value for the setting attribute.

User

This will enable the relation with Role.

And you are ready to go.

Usage

Middleware

You can use a middleware to filter routes and route groups by permission or role

Route::group(['prefix' => 'settings', 'middleware' => ['admin:settings|view']], function() {
    Route::get('/', 'AdminController@welcome');
    Route::post('/', ['middleware' => ['admin:settings|create,update'], 'uses' => 'AdminController@manageAdmins']);
});

It is possible to use comma symbol to verify until two actions:

'middleware' => ['role:admin|create,update']

Helper Permission

You can use a helper to verify a permission

cms_roles_check($check, $moduleslug, $type);
  • check is a Auth::user info or module id.
  • moduleslug is a slug of the module to check permission.
  • type is optional permission, by default it is view.

Helpers

Cogroup - CMS includes a two "helper" PHP functions. These functions are used by the package itself; however, you are free to use them in your own applications if you find them convenient.

cms_get_modules

This function return a modules of the system, register into table modules.

cms_get_modules($modulename, $inmenu, $idrol);
  • modulename is optional parameter. If is NULL return all modules.
  • inmenu By default it is Y. The other option is N.
  • idrol is optional parameter, by default it is NULL. When present, it returns the modules associated with the role that have permission view

cms_settings

This function return a object with settings values

cms_settings();

Example: cms_settings()->sitename

cms_format_date

This function return a Carbon format date with the dateformat setting format

cms_format_date($date);
  • date is required parameter. The date format must be Y-m-d.

cms_format_time

This function return a Carbon format date with the timeformat setting format

cms_format_time($time);
  • time is required parameter. The time format must be H:i:s.

cms_format_datetime

This function return a Carbon format date with the dateformat and timeformat setting format

cms_format_datetime($datetime);
  • datetime is required parameter. The date format must be Y-m-d H:i:s.

cms_get_file_attribute

This function return a attribute FileModel

cms_get_file_attribute($id, $attribute);
  • id is required parameter. Id into table Files
  • attribute is required parameter. Column of the table Files

cms_get_total_unread_notifications

This function return a number of total unread notifications system

cms_get_file_attribute();

Dashboard

For change dashboard, change option dashboard into config/cogroupcms.php file. Add all namespace example: \App\Http\Controllers\MyDashboardController

Notifications Messages

config channels into config/cogroupcms.php via option

'via' => ['mail', 'database'],

If use a mail channel add use Cogroup\Cms\Notifications\NewMessage; to your Controller.

For send message use Notification::send( $user, new NewMessage( $from, $message ) );

  • $user is the user to send email. Object User
  • $from is the user from send email. Object User
  • $message is a data message

Notifications Javascript

This configuration to set a float message from Controller

Set 0 to error, 1 to success, 2 to info, 3 to warning

$request->session()->flash('status', '1');

Set a position (top, bottom)

$request->session()->flash('msgfrom', {position});

Set a align (left, center, right)

$request->session()->flash('msgfrom', {align});

Set delay time (default: 4000)

$request->session()->flash('msgtime', {time});

Set a message

$request->session()->flash('msg', {message});

License

COgroup CMS is free software distributed under the terms of the MIT license.

Contribution guidelines

Support follows PSR-4 PHP coding standards, and semantic versioning.

Please report any issue you find in the issues page. Pull requests are welcome.

cogroup/cms 适用场景与选型建议

cogroup/cms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 182 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 05 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「cms」 「auth」 「laravel」 「permission」 「roles」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cogroup/cms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cogroup/cms 我们能提供哪些服务?
定制开发 / 二次开发

基于 cogroup/cms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 182
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-23