Laravel 5 Themes
Installation
Open your composer.json file, and add the new required package.
"pingpong/themes": "~2.1"
Next, open a terminal and run.
composer update
Next, Add new service provider in config/app.php
.
'Pingpong\Themes\ThemesServiceProvider',
Next, Add new aliases in config/app.php
.
'Theme' => 'Pingpong\Themes\ThemeFacade',
Next, publish the package's assets.
php artisan vendor:publish
Done.
Usage
Theme::all();
Theme::set('default');
Theme::setCurrent('default');
Theme::getCurrent();
Theme::has('simple')
Theme::exists('other-theme');
$path = public_path('themes');
Theme::setPath($path);
Theme::getThemePath('default');
Theme::getPath();
Get view from current active theme.
Theme::view('index');
Theme::view('folders.view');
Get translation value from active theme.
Theme::lang('group.name');
Get theme's config value from active theme.
Theme::config('filename.key');
Theme::config('filename.key.subkey');
Theme::config('filename.key.subkey', 'default value here');
If your theme's config file named config.php
, you can get the value of config little bit short.
Theme::config('key');
Theme::config('key.subkey');
You can also get config value from other theme.
// current theme
Theme::config('key');
// from other theme
Theme::config('bootstrap::key');
Artisan Commands
php artisan theme:make foo
php artisan theme:list
php artisan theme:cache
Publish all theme's assets from all themes.
php artisan theme:publish
Publish all theme's assets from the specified theme.
php artisan theme:publish theme-name