Laravel Admin panel with theme , modules ,artisan commands and helper classess.Laravel admin boilerplate with theme and modules
Laravel Version | Version |
---|---|
5.4 | 1.0 to 2.0 |
5.5 | >=2.1 |
5.6 | >=2.1 |
5.7 | >=2.1 |
5.8 | >=2.2 |
6 | >=2.3 |
7 | >=2.3 |
8 | >=2.4 |
php artisan make:cms-module {module-name} {--crud}
php artisan make:cms-module test --crud
php artisan make:cms-crudviews
it will create 2 file inside resources/views/admin
index.blade.php
edit.blade.php
composer require phpworkers/cms
// Add following Lines to `config/app.php` providers array
//html
Collective\Html\HtmlServiceProvider::class,
//datatable
Yajra\DataTables\DatatablesServiceProvider::class,
Ramesh\Cms\CmsServiceProvider::class,
// Add Following Lines to `config/app.php` aliases array
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Cms' => Ramesh\Cms\Facades\Cms::class,
# Publishing css,js,config files,core modules,theme,etc
php artisan vendor:publish
# Publishing filemanager resources
php artisan vendor:publish --provider="UniSharp\LaravelFilemanager\LaravelFilemanagerServiceProvider"
composer dump-autoload
# Migrate our tables
php artisan cms-migrate
# Seeding
php artisan db:cms-seed
#register modules to table
php artisan update:cms-module
#register plugins
php artisan update:cms-plugins
#regiser menus
php artisan update:cms-menu
Open your route/web.php
and remove rollowing lines(route)
Route::get('/', function () {
return view('welcome');
});
then run
php artisan serve
and open localhost:8000/administrator
cms (main)
|
|__core
| |
| |__core modules
|
|__local
|
|__themes
|
|__local modules
1.cms : cms path is the main path of our app,that contain
1.1 : core
1.2 : local
1.1 : core : core path is core module path ,that contain number of core modules,avoid to write core modules
1.1.1 : core modules -> core path contain number of core modules
1.2 : local : local path contain theme,we can create multiple theme
1.2.1 : local modules -> theme path contain number of local module(user create module)
public
public (main)
|
|_skin
|
|__theme name
|
|__css,js,vendor,fonts,etc
1 : public ->public folder is default folder in laravel
1.1 : skin -> skin folder is our assets folder
1.1.1 : theme name -> folder name is theme name , that contain css, fonts ,js,etc
Theme is main part of our package,we can create multiple theme,our package is theme and moduler based,all theme is placed on cms->local folder
Default theme is theme1
Just create new folder inside of cms->local
If you want to change theme?its very easy
Go to adminpanel->site configuration->change theme
Module is is a mechanism to group controller, views, modules, etc that are related, otherword module is pice of code or package of laravel
core is folder,that contain core modules (pre-defind) Module
Note: Don't change any code of core module's
local folder contain local module,which is created by user
php artisan make:cms-module {module-name}
eg :
php artisan make:cms-module helloworld
helloworld module is created under current theme folder
then register our module to database for feature use
php artisan update:cms-module
{
"name": "helloworld",
"version": "0.0.1",
"type": "local",
"providers": ["Providers\\HelloworldServiceProvider"]
}
Parameter | Data type | Use | is optional? |
---|---|---|---|
name | string | name of the module | NO |
version | string | version of the module | NO |
type | string (core/local) | type of the module | NO |
providers | Array | Provider of this module,provider is register point of our module | NO |
plugins | string (relative path of plugin) | plugin path,that used to defind plugin | YES |
helpers | object (relative path of helpers) |
helpers path,that used to defind helpers,helpers contain common functions,we can use any where
eg:
"helpers" : {
"HelperName1":"cms\\core\\blog\\helpers\\Blog",
"HelperName2":"some path",
....
}
|
YES |
search | object (relative path of search class) |
search path,that used to defind search helper,search class functions, this is used to make our module is searchable
eg:
"helpers" : {
"HelperName1":"cms\\core\\blog\\helpers\\Blog",
"HelperName2":"some path",
....
}
|
YES |
configuration | string (view file path of configuration) | configuration is used to view or edit module configuration
eg:
"configuration" : "user::admin.configuration.configuration",
Above example is taken from user module,that mean user configuration is place on cms/core/user/admin/configuration/configuraion.blade.php |
YES |
configuration_data | string (configuration data function path) | configuration data is get module configuration from function,its define function name,this function should return module configuration eg:
"configuration_data" : "\\cms\\core\\user\\Controllers\\UserController@getConfigurationData"
Above example is taken from user module, that mean user configuration function is place on cms/core/user/controller/UserController.php and function name is getConfigurationData
/*
Above function return available user groups |
YES |
{
"name": "cms/user",
"description": "",
"authors": [
{
"name": "Ramesh",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
}
}
}
Tag | Use | Parent | Attributes |
---|---|---|---|
|
menus tag is main tag of the menu.xml,that is bootstarp of menu.xml | NULL | NULL |
|
group tag is defind menu type,default type is general,you can create own group using name attribute |
|
|
|
menugroup tag is defind menu group for example user module menus is placed under user menugroup Menugroup is optional |
|
|
|
menu tag is used to give a link otherword its just clickable link |
|
|
routes.php file contain routes of the frontend app exclude admin routes
don't have routes.php?,just create it.. :)
if you don't like file name?
we have good solution for you
go to your module main provider and find registerRoot function then change it
adminroutes.php file contain routes of the admin
this file is include admin middlewares and admin route group with administrator prefix
if you dont want admin middleware of current module
go to your module provider and find registerAdminRoot method and remove middleware
Name | Use | Sub-folders |
---|---|---|
Controller | controller folder contain controllers | - |
Database | Database folder contain migrations and seeds | Migration -> that contain migrations Seeds -> that contain seeds |
Models | Models folder contain Models class | - |
helpers | helpers folder contain helpers class | - |
providers | providers folder contain providers class | - |
resources | resources folder contain assets and views | views,assets |
Mail folder contain Mail class | - | |
Events | Events folder contain Events class | - |
Listeners | Listeners folder contain Listeners class | - |
Middleware | Middleware folder contain Middleware class | - |
Console | Console folder contain artisan comands | Commands |
config | config folder contain config array like roles (deprecated) and mailer configurations | - |
we provide more artisan commands
imagin we have more than 30 artisan commands,its not remebarable,but you know default laravel commands so we have some idea,we added one common word for all laravel commands,thats it,now easily you can remember our commands
eg:/* * artisan command */ protected $commands = [ 'cms\core\{module-name}\Console\Commands\{Commandclass}' ];please replace module-name and commandclass like
/* * artisan command */ protected $commands = [ 'cms\core\menu\Console\Commands\AdminMenu' ];
/* * register commands */ protected function registerCommand() { $this->commands($this->commands); }then add following line to register method
$this->registerCommand();eg:
public function register() { $this->registerViews(); $this->registerRoot(); $this->registerAdminRoot(); $this->registerCommand(); }