generator-folklore 3.0.6 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/lib/generators/babel/index.js +8 -1
  2. package/lib/generators/build/index.js +3 -1
  3. package/lib/generators/cli/index.js +4 -1
  4. package/lib/generators/docs/index.js +9 -4
  5. package/lib/generators/eslint/index.js +12 -1
  6. package/lib/generators/intl/index.js +3 -1
  7. package/lib/generators/laravel-mediatheque/index.js +18 -0
  8. package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -0
  9. package/lib/generators/laravel-panneau/index.js +51 -5
  10. package/lib/generators/laravel-panneau/instructions/ServiceProvider.php +21 -0
  11. package/lib/generators/laravel-panneau/instructions/config.php +13 -0
  12. package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +2 -2
  13. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Block.php +10 -0
  14. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Image.php +15 -0
  15. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +2 -0
  16. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +1 -1
  17. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +2 -0
  18. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +6 -4
  19. package/lib/generators/laravel-panneau/templates/app/Models/Block.php +11 -0
  20. package/lib/generators/laravel-panneau/templates/app/Models/Media.php +11 -0
  21. package/lib/generators/laravel-panneau/templates/app/Models/Page.php +12 -2
  22. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/.gitkeep +0 -0
  23. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +2 -0
  24. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UsersCollection.php +10 -0
  25. package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +30 -4
  26. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/ImageBlock.php +30 -0
  27. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +3 -2
  28. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +4 -1
  29. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +2 -2
  30. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +2 -2
  31. package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +2 -2
  32. package/lib/generators/laravel-panneau/templates/app/Resources/Block.php +10 -0
  33. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/ImageBlock.php +27 -0
  34. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +7 -2
  35. package/lib/generators/laravel-panneau/templates/config.php +29 -0
  36. package/lib/generators/laravel-panneau/templates/index.js +1 -1
  37. package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +4 -0
  38. package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +4 -0
  39. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -0
  40. package/lib/generators/laravel-project/index.js +27 -12
  41. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/CreateNewUser.php +41 -0
  42. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/ResetUserPassword.php +31 -0
  43. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserPassword.php +34 -0
  44. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserProfileInformation.php +61 -0
  45. package/lib/generators/laravel-project/templates/laravel/app/Contracts/Repositories/Users.php +17 -0
  46. package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +0 -30
  47. package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +90 -15
  48. package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +4 -3
  49. package/lib/generators/laravel-project/templates/laravel/config/app.php +3 -2
  50. package/lib/generators/laravel-project/templates/laravel/config/image.php +204 -0
  51. package/lib/generators/lerna-repository/index.js +8 -3
  52. package/lib/generators/npm-package/index.js +6 -2
  53. package/lib/generators/prettier/index.js +5 -1
  54. package/lib/generators/react-app/index.js +22 -2
  55. package/lib/generators/react-package/index.js +14 -5
  56. package/lib/generators/rollup/index.js +8 -1
  57. package/lib/generators/server/index.js +9 -2
  58. package/lib/generators/storybook/index.js +9 -1
  59. package/lib/generators/stylelint/index.js +6 -1
  60. package/lib/generators/test/index.js +10 -1
  61. package/package.json +6 -5
  62. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +0 -22
  63. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +0 -87
  64. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +0 -51
  65. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +0 -34
  66. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +0 -18
  67. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +0 -110
@@ -56,7 +56,14 @@ module.exports = class BabelGenerator extends _generator.default {
56
56
  },
57
57
 
58
58
  dependencies() {
59
- this.addDevDependencies(['@babel/cli', '@babel/core', '@babel/node', '@babel/plugin-transform-runtime', '@babel/preset-env', '@babel/preset-react']);
59
+ this.addDevDependencies({
60
+ '@babel/core': '^7.19.3',
61
+ '@babel/cli': 'latest',
62
+ '@babel/node': 'latest',
63
+ '@babel/plugin-transform-runtime': 'latest',
64
+ '@babel/preset-env': 'latest',
65
+ '@babel/preset-react': 'latest'
66
+ });
60
67
  }
61
68
 
62
69
  };
@@ -92,7 +92,9 @@ module.exports = class AppGenerator extends _generator.default {
92
92
  },
93
93
 
94
94
  dependencies() {
95
- this.addDevDependencies(['@folklore/cli']);
95
+ this.addDevDependencies({
96
+ '@folklore/cli': '^0.0.47'
97
+ });
96
98
  }
97
99
 
98
100
  };
@@ -75,7 +75,10 @@ module.exports = class CliGenerator extends _generator.default {
75
75
  },
76
76
 
77
77
  dependencies() {
78
- this.addDependencies(['commander', 'debug']);
78
+ this.addDependencies({
79
+ 'commander': 'latest',
80
+ 'debug': 'latest'
81
+ });
79
82
  }
80
83
 
81
84
  };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -141,10 +141,15 @@ module.exports = class DocsGenerator extends _generator.default {
141
141
  return;
142
142
  }
143
143
 
144
- this.addDevDependencies(['gitbook-cli@latest']);
144
+ this.addDevDependencies({
145
+ 'gitbook-cli': 'latest'
146
+ });
145
147
 
146
148
  if (this.options.language === 'js') {
147
- this.addDevDependencies(['jsdoc@latest', 'jsdoc-babel@latest']);
149
+ this.addDevDependencies({
150
+ jsdoc: 'latest',
151
+ 'jsdoc-babel': 'latest'
152
+ });
148
153
  }
149
154
  }
150
155
 
@@ -32,7 +32,18 @@ module.exports = class EslintGenerator extends _generator.default {
32
32
  },
33
33
 
34
34
  dependencies() {
35
- this.addDevDependencies(['babel-preset-airbnb', '@babel/eslint-parser', 'eslint', 'eslint-config-airbnb', 'eslint-config-prettier', 'eslint-plugin-prettier', 'eslint-plugin-import', 'eslint-plugin-jsx-a11y', 'eslint-plugin-react', 'eslint-plugin-formatjs']);
35
+ this.addDevDependencies({
36
+ 'babel-preset-airbnb': 'latest',
37
+ '@babel/eslint-parser': 'latest',
38
+ eslint: '^8.0.0',
39
+ 'eslint-config-airbnb': 'latest',
40
+ 'eslint-config-prettier': 'latest',
41
+ 'eslint-plugin-prettier': 'latest',
42
+ 'eslint-plugin-import': 'latest',
43
+ 'eslint-plugin-jsx-a11y': 'latest',
44
+ 'eslint-plugin-react': 'latest',
45
+ 'eslint-plugin-formatjs': 'latest'
46
+ });
36
47
  }
37
48
 
38
49
  };
@@ -76,7 +76,9 @@ module.exports = class IntlGenerator extends _generator.default {
76
76
  },
77
77
 
78
78
  dependencies() {
79
- this.addDevDependencies(['@folklore/cli']);
79
+ this.addDevDependencies({
80
+ '@folklore/cli': '^0.0.47'
81
+ });
80
82
  }
81
83
 
82
84
  };
@@ -130,4 +130,22 @@ module.exports = class LaravelMediathequeGenerator extends _generator.default {
130
130
  };
131
131
  }
132
132
 
133
+ end() {
134
+ if (this.options.quiet) {
135
+ return;
136
+ }
137
+
138
+ console.log('\n\n');
139
+ console.log(_chalk.default.yellow('\n----------------------'));
140
+ console.log(_chalk.default.bold('Instructions'));
141
+ console.log(_chalk.default.yellow('----------------------\n\n'));
142
+ console.log(`1. Add to ${_chalk.default.bold.yellow('app/Providers/AppServiceProvider.php')}:`);
143
+ const serviceProvider = fs.readFileSync(_path.default.join(__dirname, './instructions/ServiceProvider.php'));
144
+ console.log('---');
145
+ console.log(highlight(serviceProvider.toString('utf-8'), {
146
+ language: 'php',
147
+ ignoreIllegals: true
148
+ }));
149
+ }
150
+
133
151
  };
@@ -0,0 +1,26 @@
1
+ <?php
2
+
3
+ class AppServiceProvider extends ServiceProvider
4
+ {
5
+ //...
6
+ public function register()
7
+ {
8
+ // ...
9
+
10
+ $this->registerMediatheque();
11
+ }
12
+
13
+ protected function registerMediatheque()
14
+ {
15
+ $this->app->bind(
16
+ \Folklore\Mediatheque\Contracts\Models\Media::class,
17
+ \App\Models\Media::class
18
+ );
19
+
20
+ $this->app->bind(
21
+ \Folklore\Mediatheque\Contracts\Models\File::class,
22
+ \App\Models\MediaFile::class
23
+ );
24
+ }
25
+ //...
26
+ }
@@ -2,6 +2,10 @@
2
2
 
3
3
  var _chalk = _interopRequireDefault(require("chalk"));
4
4
 
5
+ var _cliHighlight = require("cli-highlight");
6
+
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+
5
9
  var _glob = _interopRequireDefault(require("glob"));
6
10
 
7
11
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -65,7 +69,24 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
65
69
  },
66
70
 
67
71
  packageJSON() {
68
- this.addDependencies(['@panneau/app@^1.0.0-alpha.193', '@panneau/core@^1.0.0-alpha.193']);
72
+ this.addDependencies({
73
+ '@panneau/app': '^1.0.3-alpha.1',
74
+ '@panneau/core': '^1.0.3-alpha.1',
75
+ '@panneau/data': '^1.0.3-alpha.1',
76
+ '@panneau/field-text': '^1.0.3-alpha.1',
77
+ '@panneau/field-localized': '^1.0.3-alpha.1'
78
+ });
79
+ },
80
+
81
+ config() {
82
+ const source = this.templatePath('config.php');
83
+ const destination = this.destinationPath('config/panneau.php');
84
+
85
+ if (this.fs.exists(destination)) {
86
+ this.fs.delete(destination);
87
+ }
88
+
89
+ this.fs.copyTpl(source, destination, {});
69
90
  },
70
91
 
71
92
  routes() {
@@ -107,10 +128,6 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
107
128
  this.fs.copyTpl(source, destination, {});
108
129
  },
109
130
 
110
- npmDependencies() {
111
- this.addDependencies(['@panneau/app@^1.0.0-alpha.193', '@panneau/core@^1.0.0-alpha.193', '@panneau/data@^1.0.0-alpha.193', '@panneau/field-text@^1.0.0-alpha.193', '@panneau/field-localized@^1.0.0-alpha.193']);
112
- },
113
-
114
131
  files() {
115
132
  const folders = ['app', 'resources', 'lang'];
116
133
  folders.forEach(folder => {
@@ -169,4 +186,33 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
169
186
  };
170
187
  }
171
188
 
189
+ end() {
190
+ if (this.options.quiet) {
191
+ return;
192
+ }
193
+
194
+ console.log('\n\n');
195
+ console.log(_chalk.default.yellow('\n----------------------'));
196
+ console.log(_chalk.default.bold('Instructions'));
197
+ console.log(_chalk.default.yellow('----------------------\n\n'));
198
+ console.log(`1. Add to ${_chalk.default.bold.yellow('app/Providers/AppServiceProvider.php')}:`);
199
+
200
+ const serviceProvider = _fs.default.readFileSync(_path.default.join(__dirname, './instructions/ServiceProvider.php'));
201
+
202
+ console.log('---');
203
+ console.log((0, _cliHighlight.highlight)(serviceProvider.toString('utf-8'), {
204
+ language: 'php',
205
+ ignoreIllegals: true
206
+ }));
207
+ console.log(`\n2. Add to ${_chalk.default.bold.yellow('config/app.php')}:`);
208
+
209
+ const config = _fs.default.readFileSync(_path.default.join(__dirname, './instructions/config.php'));
210
+
211
+ console.log('---');
212
+ console.log((0, _cliHighlight.highlight)(config.toString('utf-8'), {
213
+ language: 'php',
214
+ ignoreIllegals: true
215
+ }));
216
+ }
217
+
172
218
  };
@@ -0,0 +1,21 @@
1
+ <?php
2
+
3
+ class AppServiceProvider extends ServiceProvider
4
+ {
5
+ //...
6
+ protected function registerRepositories()
7
+ {
8
+ //...
9
+
10
+ $this->app->bind(
11
+ \Folklore\Contracts\Repositories\Pages::class,
12
+ \App\Repositories\Pages::class
13
+ );
14
+
15
+ $this->app->bind(
16
+ \App\Contracts\Repositories\Pages::class,
17
+ \App\Repositories\Pages::class
18
+ );
19
+ }
20
+ //...
21
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ return [
4
+ // ...
5
+
6
+ 'providers' => [
7
+ // ...
8
+
9
+ App\Panneau\PanneauServiceProvider::class,
10
+ ],
11
+
12
+ // ...
13
+ ];
@@ -13,7 +13,7 @@ interface Pages extends BasePages
13
13
 
14
14
  public function findBySlug(string $slug, string $locale = null): ?PageResource;
15
15
 
16
- public function create(array $data): PageResource;
16
+ public function create($data): PageResource;
17
17
 
18
- public function update(string $id, array $data): ?PageResource;
18
+ public function update(string $id, $data): ?PageResource;
19
19
  }
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ namespace App\Contracts\Resources;
4
+
5
+ use Folklore\Contracts\Resources\Block as BaseBlock;
6
+
7
+ interface Block extends BaseBlock
8
+ {
9
+
10
+ }
@@ -0,0 +1,15 @@
1
+ <?php
2
+
3
+ namespace App\Contracts\Resources\Blocks;
4
+
5
+ use App\Contracts\Resources\Block as BaseBlock;
6
+ use Folklore\Contracts\Resources\Image as ImageContract;
7
+
8
+ interface Image extends BaseBlock
9
+ {
10
+ public function image(): ?ImageContract;
11
+
12
+ public function caption(string $locale): ?string;
13
+
14
+ public function credits(string $locale): ?string;
15
+ }
@@ -6,5 +6,7 @@ use App\Contracts\Resources\Block as BaseBlock;
6
6
 
7
7
  interface Text extends BaseBlock
8
8
  {
9
+ public function title(string $locale): ?string;
10
+
9
11
  public function body(string $locale): ?string;
10
12
  }
@@ -3,7 +3,7 @@
3
3
  namespace App\Http\Resources;
4
4
 
5
5
  use Illuminate\Http\Resources\Json\JsonResource;
6
- use App\Contracts\Resources\HasBlocks;
6
+ use Folklore\Contracts\Resources\HasBlocks;
7
7
  use Folklore\Http\Resources\LocalizedResource;
8
8
  use App\Contracts\Resources\Blocks\Text as TextBlock;
9
9
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  namespace App\Http\Resources;
4
4
 
5
+ use Folklore\Http\Resources\Collection;
6
+
5
7
  class BlocksCollection extends Collection
6
8
  {
7
9
  public $collects = BlockResource::class;
@@ -3,10 +3,10 @@
3
3
  namespace App\Http\Resources;
4
4
 
5
5
  use Illuminate\Http\Resources\Json\JsonResource;
6
- use App\Http\Resources\Medias\ImageResource;
7
6
  use App\Contracts\Resources\Page;
8
- use App\Contracts\Resources\HasBlocks;
9
7
  use App\Contracts\Resources\Pages\Home as HomePage;
8
+ use Folklore\Http\Resources\MediaResource;
9
+ use Folklore\Contracts\Resources\HasBlocks;
10
10
 
11
11
  class PageResource extends JsonResource
12
12
  {
@@ -19,6 +19,8 @@ class PageResource extends JsonResource
19
19
  public function toArray($request)
20
20
  {
21
21
  $locale = $request->locale();
22
+ $image = $this->image();
23
+ $parent = $this->parent();
22
24
  return [
23
25
  'id' => $this->id(),
24
26
  'type' => $this->type(),
@@ -26,10 +28,10 @@ class PageResource extends JsonResource
26
28
  'title' => $this->title($locale),
27
29
  'description' => $this->description($locale),
28
30
  'slug' => $this->slug($locale),
29
- 'image' => !is_null($image) ? new ImageResource($image) : null,
31
+ 'image' => !is_null($image) ? new MediaResource($image) : null,
30
32
  'parent' =>
31
33
  !is_null($parent) && $parent instanceof Page
32
- ? new ParentPageResource($parent)
34
+ ? new PageResource($parent)
33
35
  : null,
34
36
 
35
37
  $this->mergeWhen($this->resource instanceof HasBlocks, function () {
@@ -2,11 +2,22 @@
2
2
 
3
3
  namespace App\Models;
4
4
 
5
+ use App\Contracts\Resources\Block as BlockContract;
6
+ use App\Resources\Block as BlockResource;
5
7
  use Folklore\Models\Block as BaseBlock;
8
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
6
9
 
7
10
  class Block extends BaseBlock
8
11
  {
12
+ use HasFactory;
13
+
9
14
  protected $typeResources = [
10
15
  'text' => \App\Resources\Blocks\TextBlock::class,
16
+ 'image' => \App\Resources\Blocks\ImageBlock::class,
11
17
  ];
18
+
19
+ public function toResource(): BlockContract
20
+ {
21
+ return $this->toTypedResource() ?? new BlockResource($this);
22
+ }
12
23
  }
@@ -0,0 +1,11 @@
1
+ <?php
2
+
3
+ namespace App\Models;
4
+
5
+ use Folklore\Models\Media as BaseMedia;
6
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
7
+
8
+ class Media extends BaseMedia
9
+ {
10
+ use HasFactory;
11
+ }
@@ -2,11 +2,21 @@
2
2
 
3
3
  namespace App\Models;
4
4
 
5
+ use App\Contracts\Resources\Page as PageContract;
6
+ use App\Resources\Page as PageResource;
5
7
  use Folklore\Models\Page as BasePage;
8
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
6
9
 
7
10
  class Page extends BasePage
8
11
  {
9
- protected $typeResources = [
10
- 'text' => \App\Resources\Pages\HomePage::class,
12
+ use HasFactory;
13
+
14
+ protected $typedResources = [
15
+ 'home' => \App\Resources\Pages\HomePage::class,
11
16
  ];
17
+
18
+ public function toResource(): PageContract
19
+ {
20
+ return $this->toTypedResource() ?? new PageResource($this);
21
+ }
12
22
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  namespace App\Panneau\Http\Resources;
4
4
 
5
+ use Folklore\Http\Resources\Collection;
6
+
5
7
  class BlocksCollection extends Collection
6
8
  {
7
9
  public $collects = BlockResource::class;
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ namespace App\Panneau\Http\Resources;
4
+
5
+ use Folklore\Http\Resources\Collection;
6
+
7
+ class UsersCollection extends Collection
8
+ {
9
+ public $collects = UserResource::class;
10
+ }
@@ -5,7 +5,9 @@ namespace App\Panneau;
5
5
  use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
6
  use Illuminate\Contracts\View\Factory as ViewFactory;
7
7
  use Illuminate\Support\Facades\Gate;
8
+ use Panneau\Fields\Upload as UploadField;
8
9
  use Panneau\Support\LocalizedField;
10
+ use Folklore\Panneau\Fields\PageSlug as PageSlugField;
9
11
  use Panneau\Support\Facade as Panneau;
10
12
 
11
13
  class PanneauServiceProvider extends BaseServiceProvider
@@ -27,13 +29,35 @@ class PanneauServiceProvider extends BaseServiceProvider
27
29
  */
28
30
  public function boot()
29
31
  {
30
- LocalizedField::setLocalesResolver(function () {
31
- return config('locale.locales');
32
- });
33
-
32
+ $this->bootFields();
34
33
  $this->bootViews();
35
34
  }
36
35
 
36
+ protected function bootFields()
37
+ {
38
+ $this->app->booted(function () {
39
+ LocalizedField::setLocalesResolver(function () {
40
+ return config('locale.locales');
41
+ });
42
+
43
+ UploadField::setEndpoint(route('panneau.upload'));
44
+
45
+ PageSlugField::setRoutesResolver(function ($locale) {
46
+ return [
47
+ 'page' => url()->routeForReactRouter($locale . '.page', [
48
+ 'withoutPatterns' => config('panneau.routes.without_patterns', true),
49
+ ]),
50
+ 'page_with_parent' => url()->routeForReactRouter(
51
+ $locale . '.page_with_parent',
52
+ [
53
+ 'withoutPatterns' => config('panneau.routes.without_patterns', true),
54
+ ]
55
+ ),
56
+ ];
57
+ });
58
+ });
59
+ }
60
+
37
61
  protected function bootViews()
38
62
  {
39
63
  $view = $this->app[ViewFactory::class];
@@ -42,6 +66,8 @@ class PanneauServiceProvider extends BaseServiceProvider
42
66
  $view->composer('panneau::app', \App\Panneau\Composers\AppComposer::class);
43
67
 
44
68
  Panneau::serving(function () use ($view) {
69
+ $view->composer('errors::*', \Panneau\Composers\PanneauComposer::class);
70
+ $view->composer('errors::*', \Panneau\Composers\AppComposer::class);
45
71
  $view->composer('errors::*', \App\Panneau\Composers\AppComposer::class);
46
72
  });
47
73
  }
@@ -0,0 +1,30 @@
1
+ <?php
2
+
3
+ namespace App\Panneau\Resources\Blocks;
4
+
5
+ use Panneau\Support\ResourceType;
6
+ use Panneau\Fields\Image;
7
+ use Panneau\Fields\HtmlLocalized;
8
+ use Panneau\Fields\TextLocalized;
9
+
10
+ class ImageBlock extends ResourceType
11
+ {
12
+ public function id(): string
13
+ {
14
+ return 'image';
15
+ }
16
+
17
+ public function name(): string
18
+ {
19
+ return trans('panneau.blocks_image');
20
+ }
21
+
22
+ public function fields(): array
23
+ {
24
+ return [
25
+ Image::make('image')->withTransLabel('panneau.fields.image'),
26
+ HtmlLocalized::make('caption')->withTransLabel('panneau.fields.caption'),
27
+ TextLocalized::make('credits')->withTransLabel('panneau.fields.credits'),
28
+ ];
29
+ }
30
+ }
@@ -3,6 +3,7 @@
3
3
  namespace App\Panneau\Resources\Blocks;
4
4
 
5
5
  use Panneau\Support\ResourceType;
6
+ use Panneau\Fields\TextLocalized;
6
7
  use Panneau\Fields\HtmlLocalized;
7
8
 
8
9
  class TextBlock extends ResourceType
@@ -20,8 +21,8 @@ class TextBlock extends ResourceType
20
21
  public function fields(): array
21
22
  {
22
23
  return [
23
- HtmlLocalized::make('body')
24
- ->withTransLabel('panneau.fields.body'),
24
+ TextLocalized::make('title')->withTransLabel('panneau.fields.title'),
25
+ HtmlLocalized::make('body')->withTransLabel('panneau.fields.body'),
25
26
  ];
26
27
  }
27
28
  }
@@ -16,7 +16,10 @@ class Blocks extends Resource
16
16
  'hideInNavbar' => true,
17
17
  ];
18
18
 
19
- public static $types = [\App\Panneau\Resources\Blocks\TextBlock::class];
19
+ public static $types = [
20
+ \App\Panneau\Resources\Blocks\TextBlock::class,
21
+ \App\Panneau\Resources\Blocks\ImageBlock::class,
22
+ ];
20
23
 
21
24
  public function name(): string
22
25
  {
@@ -3,8 +3,8 @@
3
3
  namespace App\Panneau\Resources\Pages;
4
4
 
5
5
  use Panneau\Support\ResourceType;
6
- use App\Panneau\Fields\Blocks;
7
- use App\Panneau\Fields\Page as PageField;
6
+ use Folklore\Panneau\Fields\Blocks;
7
+ use Folklore\Panneau\Fields\Page as PageField;
8
8
 
9
9
  class Page extends ResourceType
10
10
  {
@@ -1,9 +1,9 @@
1
1
  <?php
2
2
  namespace App\Panneau\Resources;
3
3
 
4
- use App\Panneau\Fields\ImageLocalized;
5
- use App\Panneau\Fields\PageSlugLocalized;
4
+ use Folklore\Panneau\Fields\PageSlugLocalized;
6
5
  use Panneau\Fields\TextLocalized;
6
+ use Panneau\Fields\ImageLocalized;
7
7
  use Panneau\Fields\Toggle;
8
8
  use Panneau\Support\Resource;
9
9
 
@@ -30,12 +30,12 @@ class Pages extends BasePages implements PagesContract
30
30
  return parent::findBySlug($slug, $locale);
31
31
  }
32
32
 
33
- public function create(array $data): PageContract
33
+ public function create($data): PageContract
34
34
  {
35
35
  return parent::create($data);
36
36
  }
37
37
 
38
- public function update(string $id, array $data): ?PageContract
38
+ public function update(string $id, $data): ?PageContract
39
39
  {
40
40
  return parent::update($id, $data);
41
41
  }
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ namespace App\Resources;
4
+
5
+ use Folklore\Resources\Block as BaseBlock;
6
+
7
+ class Block extends BaseBlock
8
+ {
9
+
10
+ }
@@ -0,0 +1,27 @@
1
+ <?php
2
+
3
+ namespace App\Resources\Blocks;
4
+
5
+ use App\Resources\Block;
6
+ use App\Contracts\Resources\Blocks\Text as TextBlockContract;
7
+ use Folklore\Contracts\Resources\Image as ImageContract;
8
+ use Folklore\Resources\Image;
9
+
10
+ class ImageBlock extends Block implements TextBlockContract
11
+ {
12
+ public function image(): ?ImageContract
13
+ {
14
+ $image = data_get($this->data, 'image');
15
+ return isset($image) ? new Image($image) : null;
16
+ }
17
+
18
+ public function caption(string $locale): ?string
19
+ {
20
+ return data_get($this->data, 'caption.' . $locale);
21
+ }
22
+
23
+ public function credits(string $locale): ?string
24
+ {
25
+ return data_get($this->data, 'credits.' . $locale);
26
+ }
27
+ }