dev-master
9999999-devCMS for all laravel projects
MIT
The Requires
- php >=7.1.0
- laravel/socialite ^3.0
- intervention/image ^2.4.1
by COgroup
laravel auth roles cms admin illuminate permission
Wallogit.com
2017 © Pedro Pelรกez
CMS for all laravel projects
, (*1)
COgroup - CMS package is a flexible way to add basic CMS system with Role-based Permissions to Laravel., (*3)
1) Run the command to install laravel/ui and generate scaffolding, (*4)
composer require laravel/ui php artisan ui bootstrap --auth
2) In order to install COgroup - CMS, just add the following to your composer.json. Then run composer update:, (*5)
"cogroup/cms": "^2.0"
or run the next command:, (*6)
composer require cogroup/cms "2.*"
3) fixed Auth::routes, to avoid Clouser error, (*7)
Remove Auth::routes from web.php file, (*8)
4) Run the command below to publish the package config file config/cogroupcms.php:, (*9)
php artisan vendor:publish --provider="Cogroup\Cms\CmsServiceProvider"
5) Run the command below to execute migrations, (*10)
php artisan migrate
6) Run the command below to seed, (*11)
php artisan db:seed --class=CogroupCmsSeeder
7) Run the command below to re-publish assets, config, custom error views, font, migrations and translations, (*12)
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
6) Change default User model in config/auth.php file, (*13)
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => Cogroup\Cms\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
After you have installed Intervention Image, open your Laravel config file config/app.php and add the following lines., (*14)
In the $providers array add the service providers for this package., (*15)
Intervention\Image\ImageServiceProvider::class, (*16)
Add the facade of this package to the $aliases array., (*17)
'ImageManager' => Intervention\Image\Facades\Image::class, (*18)
Now the Image Class will be auto-loaded by Laravel., (*19)
$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravelRecent"
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., (*20)
You may now run it with the artisan migrate command:, (*21)
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, (*22)
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., (*23)
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"., (*24)
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., (*25)
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., (*26)
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., (*27)
The Settings model has two main attributes:
- setting โ Unique name for the setting.
- defaultvalue โ A value for the setting attribute., (*28)
This will enable the relation with Role., (*29)
And you are ready to go., (*30)
You can use a middleware to filter routes and route groups by permission or role, (*31)
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:, (*32)
'middleware' => ['role:admin|create,update']
You can use a helper to verify a permission, (*33)
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.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., (*34)
This function return a modules of the system, register into table modules., (*35)
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
This function return a object with settings values, (*36)
cms_settings();
Example: cms_settings()->sitename, (*37)
This function return a Carbon format date with the dateformat setting format, (*38)
cms_format_date($date);
date is required parameter. The date format must be Y-m-d.This function return a Carbon format date with the timeformat setting format, (*39)
cms_format_time($time);
time is required parameter. The time format must be H:i:s.This function return a Carbon format date with the dateformat and timeformat setting format, (*40)
cms_format_datetime($datetime);
datetime is required parameter. The date format must be Y-m-d H:i:s.This function return a attribute FileModel, (*41)
cms_get_file_attribute($id, $attribute);
id is required parameter. Id into table Files
attribute is required parameter. Column of the table Files
This function return a number of total unread notifications system, (*42)
cms_get_file_attribute();
For change dashboard, change option dashboard into config/cogroupcms.php file.
Add all namespace example: \App\Http\Controllers\MyDashboardController, (*43)
config channels into config/cogroupcms.php via option, (*44)
'via' => ['mail', 'database'],
If use a mail channel add use Cogroup\Cms\Notifications\NewMessage; to your Controller., (*45)
For send message use Notification::send( $user, new NewMessage( $from, $message ) );, (*46)
$user is the user to send email. Object User$from is the user from send email. Object User$message is a data messageThis configuration to set a float message from Controller, (*47)
Set 0 to error, 1 to success, 2 to info, 3 to warning, (*48)
$request->session()->flash('status', '1');
Set a position (top, bottom), (*49)
$request->session()->flash('msgfrom', {position});
Set a align (left, center, right), (*50)
$request->session()->flash('msgfrom', {align});
Set delay time (default: 4000), (*51)
$request->session()->flash('msgtime', {time});
Set a message, (*52)
$request->session()->flash('msg', {message});
COgroup CMS is free software distributed under the terms of the MIT license., (*53)
Support follows PSR-4 PHP coding standards, and semantic versioning., (*54)
Please report any issue you find in the issues page. Pull requests are welcome., (*55)
CMS for all laravel projects
MIT
laravel auth roles cms admin illuminate permission