Skip to content

Commit 3dd7d30

Browse files
committed
#11 Add a default config file
1 parent a99bb14 commit 3dd7d30

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ composer require interaction-design-foundation/nova-unlayer-field
2323
⚠️ For PHP 7.1 - PHP 7.4 please use [version 0.2.2](https://github.com/InteractionDesignFoundation/nova-unlayer-field/tree/0.2.2) (it uses another namespace).
2424

2525

26+
### Optional: publish the configuration
27+
28+
Run this on the command line from the root of your project:
29+
```sh
30+
php artisan vendor:publish --provider="InteractionDesignFoundation\NovaUnlayerField\ServiceProvider" --tag=config
31+
```
32+
33+
2634
## Usage
2735

2836
This package assumes that your Model has an attribute to store design config
@@ -40,7 +48,7 @@ public function fields()
4048
'projectId' => config('unlayer.project_id'),
4149

4250
// optional
43-
'templateId' => config('unlayer.newsletter_template_id'), // Used only if bound attribute ('design' in this case) is empty.
51+
'templateId' => config('unlayer.template_id'), // Used only if bound attribute ('design' in this case) is empty.
4452
'displayMode' => 'web', // "email" or "web". Default value: "email"
4553
'locale' => 'es', // Locale for Unlayer UI. Default value: application’s locale.
4654
]),

config.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types=1);
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Unlayer Project ID
7+
|--------------------------------------------------------------------------
8+
| This is the project ID from Unlayer. You can get it from the project settings page:
9+
| 1. Log in to the Unlayer dabshboard and open https://dashboard.unlayer.com/projects
10+
| 2. Select or create a Project from, URL will be like https://dashboard.unlayer.com/projects/1234/design/templates, where 1234 is a project ID.
11+
*/
12+
'project_id' => env('UNLAYER_PROJECT_ID'),
13+
14+
/*
15+
|--------------------------------------------------------------------------
16+
| Unlayer Project ID
17+
|--------------------------------------------------------------------------
18+
| Templates are pre-built designs that can be loaded into the editor
19+
| so your users don't have to start creating everything from scratch in a blank editor.
20+
| @see https://docs.unlayer.com/docs/templates
21+
|
22+
| To find your project ID:
23+
| 1. Open Unlayer dabshboard and open https://dashboard.unlayer.com/projects
24+
| 2. Select a project and template, URL will be like https://dashboard.unlayer.com/projects/42/design/templates/43, where 42 is a project ID, 43 is a temple ID.
25+
*/
26+
'template_id' => env('UNLAYER_TEMPLATE_ID'),
27+
];

src/ServiceProvider.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public function boot(): void
1919
]);
2020

2121
$this->registerTranslations();
22+
23+
if ($this->app->runningInConsole()) {
24+
$this->registerResources();
25+
}
2226
}
2327

2428
protected function registerTranslations(): void
@@ -28,4 +32,11 @@ protected function registerTranslations(): void
2832
Nova::translations(__DIR__."/../resources/lang/$currentLocale.json");
2933
Nova::translations(resource_path("lang/vendor/nova-unlayer-field/$currentLocale.json"));
3034
}
35+
36+
private function registerResources(): void
37+
{
38+
$this->publishes([
39+
__DIR__ . '/../config/unlayer.php' => config_path('unlayer.php'),
40+
], 'config');
41+
}
3142
}

0 commit comments

Comments
 (0)