Skip to content

Commit

Permalink
Create theme command added
Browse files Browse the repository at this point in the history
  • Loading branch information
HansSchouten committed Mar 21, 2020
1 parent 47ab262 commit 52cbc23
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Follow these steps to install Laravel Pagebuilder in your project:
- Update the configuration in `config/pagebuilder.php`
- `php artisan migrate`

Next, you can publish the demo theme:
Next, you need to create a theme:
- `php artisan pagebuilder:create-theme [name here]`

.. or publish the demo theme:
- `php artisan vendor:publish --provider="HansSchouten\LaravelPageBuilder\ServiceProvider" --tag=demo-theme`

Now you are able to login via `/admin` with `admin` and `changethispassword` (the admin URL and credentials can be changed in the pagebuilder config file).
Expand Down
37 changes: 37 additions & 0 deletions src/Commands/CreateTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace HansSchouten\LaravelPageBuilder\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Exception;

class CreateTheme extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pagebuilder:create-theme {name}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new theme.';

/**
* Execute the console command.
*
* @throws Exception
*/
public function handle()
{
$themeName = $this->argument('name');
$themePath = base_path(config('pagebuilder.theme.folder_url') . '/' . $themeName);
File::copyDirectory(__DIR__ . '/../../themes/stub', $themePath);
}

}
8 changes: 8 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace HansSchouten\LaravelPageBuilder;

use HansSchouten\LaravelPageBuilder\Commands\CreateTheme;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/**
Expand All @@ -23,6 +25,12 @@ public function boot()
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
$this->loadMigrationsFrom(__DIR__ . '/../migrations');

if ($this->app->runningInConsole()) {
$this->commands([
CreateTheme::class,
]);
}

$this->publishes([
__DIR__ . '/../config/pagebuilder.php' => config_path('pagebuilder.php'),
], 'config');
Expand Down
2 changes: 2 additions & 0 deletions themes/stub/blocks/header/view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<header>
</header>
12 changes: 12 additions & 0 deletions themes/stub/layouts/master/layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= $page->title ?></title>
</head>
<body>

<?= $body ?>

</body>
</html>

0 comments on commit 52cbc23

Please sign in to comment.