You can install the package via composer:
composer require isaeken/laravel-theme-systemYou can publish the config file with:
php artisan vendor:publish --provider="IsaEken\ThemeSystem\ThemeSystemServiceProvider" --tag="theme-system-config" --tag="theme-system-migrations"
php artisan migrateRun the following command in the terminal for initializing:
php artisan themes:inittheme_system()->setTheme('your-theme-name');theme_system()->getCurrentTheme();// \App\Models\User.php
class User extends Authenticatable
{
use \IsaEken\ThemeSystem\Traits\CanChooseTheme; // Add this
// ...
}// In your controller or middleware
auth()->user()->theme; // theme for user.
auth()->user()->theme = 'default'; // theme is saved to db.
auth()->user()->themeApply(); // changed current theme to user theme.Run the following command in the terminal.
php artisan make:theme your-theme-nameChange theme in PHP or application config.
Do not change the main
webpack.mix.jsfile.
A special "webpack.mix.js" file is created for each theme.
The "webpack.mix.js" file of the default theme is in the "resources" folder.
You can continue to use the "webpack.mix.js" as normal in the default theme.
However, in themes you should use it as in the example.
const mix = require('laravel-mix');
mix
.js(themeResourceRoot + '/js/app.js', 'js')
.postCss(themeResourceRoot + '/css/app.css', 'css', [
//
]);
exports.mix = mix;Register ThemeMiddleware in app\Http\Kernel.php:
protected $routeMiddleware = [
// ...
'theme' => \IsaEken\ThemeSystem\Http\Middlewares\ThemeMiddleware::class,
];Example usages:
Route::group(['middleware' => 'theme:your-theme-name'], function () {
// ...
});
Route::get('/hello-world', fn () => 'Hello World!')->middleware('theme:your-theme-name');Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
