generator-folklore 3.0.3 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/generators/app/index.js +3 -51
- package/lib/generators/babel/index.js +28 -101
- package/lib/generators/babel/templates/config.js +16 -0
- package/lib/generators/browserslist/index.js +4 -9
- package/lib/generators/build/index.js +40 -29
- package/lib/generators/cli/index.js +92 -0
- package/lib/generators/cli/templates/cli.js +22 -0
- package/lib/generators/cli/templates/commands/default.js +16 -0
- package/lib/generators/docs/index.js +1 -2
- package/lib/generators/editorconfig/index.js +12 -22
- package/lib/generators/eslint/index.js +12 -13
- package/lib/generators/{html → html-project}/index.js +60 -73
- package/lib/generators/{html → html-project}/templates/folklore.png +0 -0
- package/lib/generators/{html → html-project}/templates/gitignore +0 -0
- package/lib/generators/{html → html-project}/templates/index.html.ejs +4 -1
- package/lib/generators/intl/index.js +93 -0
- package/lib/generators/laravel/index.js +5 -5
- package/lib/generators/laravel-mediatheque/index.js +133 -0
- package/lib/generators/laravel-mediatheque/templates/app/Models/Media.php +9 -0
- package/lib/generators/laravel-mediatheque/templates/app/Models/MediaFile.php +9 -0
- package/lib/generators/laravel-panneau/index.js +49 -28
- package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Page.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Pages/Home.php +9 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +37 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +8 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +47 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PagesCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Models/Block.php +3 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Page.php +3 -60
- package/lib/generators/laravel-panneau/templates/app/Panneau/Composers/AppComposer.php +50 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +22 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +87 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +51 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +34 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +18 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/AccountController.php +41 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/Controller.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/HomeController.php +16 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/PagesController.php +24 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UsersController.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/AccountUpdateRequest.php +29 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/UploadRequest.php +29 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlockResource.php +39 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +8 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +56 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PagesCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UserResource.php +24 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +48 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +110 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +42 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +28 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +92 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Users.php +57 -0
- package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +42 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +14 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Pages/HomePage.php +10 -0
- package/lib/generators/laravel-panneau/templates/app.blade.php +8 -0
- package/lib/generators/laravel-panneau/templates/index.js +32 -0
- package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +62 -0
- package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +62 -0
- package/lib/generators/laravel-panneau/templates/layout.blade.php +17 -48
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/Panneau.jsx +68 -0
- package/lib/generators/{js/templates/src/lib/.gitkeep → laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx} +0 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.jsx +43 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/index.js +2 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/styles/panneau.scss +2 -0
- package/lib/generators/laravel-panneau/templates/routes.php +30 -0
- package/lib/generators/laravel-project/index.js +504 -0
- package/lib/generators/laravel-project/templates/env +41 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/AppComposer.php +48 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/IntlComposer.php +10 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/MetaComposer.php +48 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/RoutesComposer.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/app/Contracts/Resources/User.php +10 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Controllers/HomeController.php +18 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Middleware/TrustProxies.php +28 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Resources/UserResource.php +21 -0
- package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +50 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +45 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php +64 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/ViewServiceProvider.php +33 -0
- package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +36 -0
- package/lib/generators/laravel-project/templates/laravel/app/Resources/User.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/config/app.php +216 -0
- package/lib/generators/laravel-project/templates/laravel/config/auth.php +116 -0
- package/lib/generators/laravel-project/templates/laravel/config/services.php +39 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/content.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/errors.php +17 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/meta.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/routes.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/auth.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/content.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/errors.php +17 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/meta.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/pagination.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/passwords.php +22 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/routes.php +12 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/validation.php +146 -0
- package/lib/generators/{js/templates/styles → laravel-project/templates/laravel/resources/assets/fonts}/.gitkeep +0 -0
- package/lib/generators/{laravel-panneau/templates/app/Schemas/Fields → laravel-project/templates/laravel/resources/assets/img}/.gitkeep +0 -0
- package/lib/generators/laravel-project/templates/laravel/resources/assets/img/folklore.png +0 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/body.blade.php +3 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/gpt.blade.php +16 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/head.blade.php +1 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/app.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/401.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/403.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/404.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/500.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/layout.blade.php +33 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/all.blade.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/base.blade.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/facebook.blade.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/opengraph.blade.php +9 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/twitter.blade.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/routes/web.php +12 -0
- package/lib/generators/lerna-package/index.js +1 -3
- package/lib/generators/lerna-repository/index.js +1 -3
- package/lib/generators/node-project/index.js +164 -0
- package/lib/generators/node-project/templates/index.js +0 -0
- package/lib/generators/npm-package/index.js +3 -5
- package/lib/generators/prettier/index.js +19 -6
- package/lib/generators/prettier/templates/prettierrc.json +3 -1
- package/lib/generators/{js → react-app}/index.js +22 -52
- package/lib/generators/{js → react-app}/templates/_package.json +0 -0
- package/lib/generators/react-app/templates/index.js +23 -0
- package/lib/generators/react-app/templates/src/components/App.jsx +46 -0
- package/lib/generators/react-app/templates/src/components/Container.jsx +40 -0
- package/lib/generators/{js → react-app}/templates/src/components/buttons/Button.jsx +4 -18
- package/lib/generators/react-app/templates/src/components/layouts/Main.jsx +27 -0
- package/lib/generators/react-app/templates/src/components/menus/Menu.jsx +62 -0
- package/lib/generators/{js → react-app}/templates/src/components/pages/Error.jsx +10 -14
- package/lib/generators/react-app/templates/src/components/pages/Home.jsx +32 -0
- package/lib/generators/{js → react-app}/templates/src/components/partials/PageMeta.jsx +11 -11
- package/lib/generators/{js → react-app}/templates/src/contexts/KeysContext.jsx +0 -0
- package/lib/generators/react-app/templates/src/lib/.gitkeep +0 -0
- package/lib/generators/{js → react-app}/templates/src/lib/PropTypes.js +0 -0
- package/lib/generators/{js → react-app}/templates/src/lib/utils.js +0 -0
- package/lib/generators/react-app/templates/src/polyfills/index.js +6 -0
- package/lib/generators/react-app/templates/src/polyfills/intl-en.js +2 -0
- package/lib/generators/react-app/templates/src/polyfills/intl-fr.js +2 -0
- package/lib/generators/react-app/templates/src/polyfills/should.js +14 -0
- package/lib/generators/react-app/templates/styles/.gitkeep +0 -0
- package/lib/generators/{js/templates/styles/buttons/button.scss → react-app/templates/styles/buttons/button.module.scss} +1 -0
- package/lib/generators/{js/templates/styles/layouts/main.scss → react-app/templates/styles/layouts/main.module.scss} +0 -0
- package/lib/generators/{js/templates/styles/menus/menu.scss → react-app/templates/styles/menus/menu.module.scss} +0 -0
- package/lib/generators/{js/templates/styles/pages/error.scss → react-app/templates/styles/pages/error.module.scss} +0 -0
- package/lib/generators/{js/templates/styles/pages/home.scss → react-app/templates/styles/pages/home.module.scss} +0 -0
- package/lib/generators/rollup/index.js +54 -0
- package/lib/generators/rollup/templates/config.js +50 -0
- package/lib/generators/scss/index.js +3 -16
- package/lib/generators/scss/templates/{main.scss → styles.scss} +0 -0
- package/lib/generators/server/index.js +81 -0
- package/lib/generators/server/templates/server.js +59 -0
- package/lib/generators/storybook/index.js +1 -7
- package/lib/generators/stylelint/index.js +13 -14
- package/lib/lib/generator.js +9 -0
- package/lib/lib/utils.js +17 -0
- package/package.json +2 -2
- package/lib/generators/babel/templates/babel-preset-react.js +0 -7
- package/lib/generators/babel/templates/babel-preset.js +0 -57
- package/lib/generators/babel/templates/babelrc +0 -5
- package/lib/generators/babel/templates/utils/processScss.js +0 -10
- package/lib/generators/babel/templates/utils/transformRequireIgnore.js +0 -80
- package/lib/generators/html/templates/index.js +0 -9
- package/lib/generators/html/templates/root.js +0 -23
- package/lib/generators/html/templates/utils.js +0 -7
- package/lib/generators/js/templates/browserslistrc +0 -9
- package/lib/generators/js/templates/config.js +0 -33
- package/lib/generators/js/templates/index.js +0 -41
- package/lib/generators/js/templates/src/actions/LayoutActions.js +0 -12
- package/lib/generators/js/templates/src/actions/SiteActions.js +0 -22
- package/lib/generators/js/templates/src/components/App.jsx +0 -52
- package/lib/generators/js/templates/src/components/Root.jsx +0 -70
- package/lib/generators/js/templates/src/components/layouts/Main.jsx +0 -52
- package/lib/generators/js/templates/src/components/menus/Menu.jsx +0 -60
- package/lib/generators/js/templates/src/components/messages/Success.jsx +0 -36
- package/lib/generators/js/templates/src/components/pages/Home.jsx +0 -32
- package/lib/generators/js/templates/src/components/partials/Label.jsx +0 -32
- package/lib/generators/js/templates/src/reducers/LayoutReducer.js +0 -32
- package/lib/generators/js/templates/src/reducers/SiteReducer.js +0 -36
- package/lib/generators/js/templates/src/reducers/index.js +0 -7
- package/lib/generators/js/templates/src/vendor/polyfills/intl-en.js +0 -2
- package/lib/generators/js/templates/src/vendor/polyfills/intl-fr.js +0 -2
- package/lib/generators/laravel-panneau/templates/_composer.json +0 -6
- package/lib/generators/laravel-panneau/templates/_package.json +0 -11
- package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/HomeController.php +0 -14
- package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/PagesController.php +0 -11
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/File.php +0 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Picture.php +0 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Video.php +0 -34
- package/lib/generators/laravel-panneau/templates/app/Providers/PanneauServiceProvider.php +0 -23
- package/lib/generators/laravel-panneau/templates/app/Reducers/SlugExtractReducer.php +0 -18
- package/lib/generators/laravel-panneau/templates/app/Resources/Pages.php +0 -54
- package/lib/generators/laravel-panneau/templates/app/Schemas/Blocks/Base.php +0 -22
- package/lib/generators/laravel-panneau/templates/app/Schemas/Bubbles/Base.php +0 -22
- package/lib/generators/laravel-panneau/templates/app/Schemas/Pages/Base.php +0 -36
- package/lib/generators/laravel-panneau/templates/resources/lang/en/panneau.php +0 -12
- package/lib/generators/laravel-panneau/templates/resources/lang/fr/panneau.php +0 -12
@@ -0,0 +1,29 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Requests;
|
4
|
+
|
5
|
+
use Illuminate\Foundation\Http\FormRequest;
|
6
|
+
|
7
|
+
class UploadRequest extends FormRequest
|
8
|
+
{
|
9
|
+
/**
|
10
|
+
* Determine if the user is authorized to make this request.
|
11
|
+
*
|
12
|
+
* @return bool
|
13
|
+
*/
|
14
|
+
public function authorize()
|
15
|
+
{
|
16
|
+
$user = $this->user();
|
17
|
+
return !is_null($user);
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Get the validation rules that apply to the request.
|
22
|
+
*
|
23
|
+
* @return array
|
24
|
+
*/
|
25
|
+
public function rules()
|
26
|
+
{
|
27
|
+
return [];
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
use App\Contracts\Resources\HasBlocks;
|
7
|
+
use Folklore\Http\Resources\LocalizedResource;
|
8
|
+
use App\Contracts\Resources\Blocks\Text as TextBlock;
|
9
|
+
|
10
|
+
class BlockResource extends JsonResource
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Transform the resource into an array.
|
14
|
+
*
|
15
|
+
* @param \Illuminate\Http\Request $request
|
16
|
+
* @return array
|
17
|
+
*/
|
18
|
+
public function toArray($request)
|
19
|
+
{
|
20
|
+
$type = $this->type();
|
21
|
+
|
22
|
+
return [
|
23
|
+
'id' => $this->id(),
|
24
|
+
'type' => $type,
|
25
|
+
'blocks' => $this->when($this->resource instanceof HasBlocks, function () {
|
26
|
+
$blocks = $this->blocks();
|
27
|
+
return !is_null($blocks) ? new BlocksCollection($blocks) : [];
|
28
|
+
}),
|
29
|
+
|
30
|
+
$this->mergeWhen($this->resource instanceof TextBlock, function () {
|
31
|
+
return [
|
32
|
+
'body' => new LocalizedResource(function ($locale) {
|
33
|
+
return $this->body($locale);
|
34
|
+
}),
|
35
|
+
];
|
36
|
+
}),
|
37
|
+
];
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
use App\Http\Resources\Medias\ImageResource;
|
7
|
+
use App\Contracts\Resources\Page;
|
8
|
+
use App\Contracts\Resources\HasBlocks;
|
9
|
+
use Folklore\Http\Resources\LocalizedResource;
|
10
|
+
use App\Contracts\Resources\Pages\Home as HomePage;
|
11
|
+
|
12
|
+
class PageResource extends JsonResource
|
13
|
+
{
|
14
|
+
/**
|
15
|
+
* Transform the resource into an array.
|
16
|
+
*
|
17
|
+
* @param \Illuminate\Http\Request $request
|
18
|
+
* @return array
|
19
|
+
*/
|
20
|
+
public function toArray($request)
|
21
|
+
{
|
22
|
+
$locale = $request->locale();
|
23
|
+
$isPanneauIndex = $request->isPanneauIndex();
|
24
|
+
|
25
|
+
return [
|
26
|
+
'id' => $this->id(),
|
27
|
+
'type' => $this->type(),
|
28
|
+
'published' => $this->published(),
|
29
|
+
'title' => new LocalizedResource(function ($locale) {
|
30
|
+
return $this->title($locale);
|
31
|
+
}),
|
32
|
+
'description' => new LocalizedResource(function ($locale) {
|
33
|
+
return $this->description($locale);
|
34
|
+
}),
|
35
|
+
'slug' => new LocalizedResource(function ($locale) {
|
36
|
+
return $this->slug($locale);
|
37
|
+
}),
|
38
|
+
'image' => !is_null($image) ? new ImageResource($image) : null,
|
39
|
+
'parent' =>
|
40
|
+
!is_null($parent) && $parent instanceof Page
|
41
|
+
? new ParentPageResource($parent)
|
42
|
+
: null,
|
43
|
+
|
44
|
+
$this->mergeWhen($this->resource instanceof HasBlocks, function () {
|
45
|
+
$blocks = $this->blocks();
|
46
|
+
return [
|
47
|
+
'blocks' => !is_null($blocks) ? new BlocksCollection($blocks) : [],
|
48
|
+
];
|
49
|
+
}),
|
50
|
+
|
51
|
+
$this->mergeWhen($this->resource instanceof HomePage, function () {
|
52
|
+
return [];
|
53
|
+
}),
|
54
|
+
];
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
|
7
|
+
class UserResource extends JsonResource
|
8
|
+
{
|
9
|
+
/**
|
10
|
+
* Transform the resource into an array.
|
11
|
+
*
|
12
|
+
* @param \Illuminate\Http\Request $request
|
13
|
+
* @return array
|
14
|
+
*/
|
15
|
+
public function toArray($request)
|
16
|
+
{
|
17
|
+
return [
|
18
|
+
'id' => $this->id(),
|
19
|
+
'name' => $this->name(),
|
20
|
+
'email' => $this->email(),
|
21
|
+
'role' => $this->role(),
|
22
|
+
];
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau;
|
4
|
+
|
5
|
+
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
6
|
+
use Illuminate\Contracts\View\Factory as ViewFactory;
|
7
|
+
use Illuminate\Support\Facades\Gate;
|
8
|
+
use Panneau\Support\LocalizedField;
|
9
|
+
use Panneau\Support\Facade as Panneau;
|
10
|
+
|
11
|
+
class PanneauServiceProvider extends BaseServiceProvider
|
12
|
+
{
|
13
|
+
/**
|
14
|
+
* Register any application services.
|
15
|
+
*
|
16
|
+
* @return void
|
17
|
+
*/
|
18
|
+
public function register()
|
19
|
+
{
|
20
|
+
Gate::policy(\Panneau\Panneau::class, \App\Panneau\Policies\PanneauPolicy::class);
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Bootstrap any application services.
|
25
|
+
*
|
26
|
+
* @return void
|
27
|
+
*/
|
28
|
+
public function boot()
|
29
|
+
{
|
30
|
+
LocalizedField::setLocalesResolver(function () {
|
31
|
+
return config('locale.locales');
|
32
|
+
});
|
33
|
+
|
34
|
+
$this->bootViews();
|
35
|
+
}
|
36
|
+
|
37
|
+
protected function bootViews()
|
38
|
+
{
|
39
|
+
$view = $this->app[ViewFactory::class];
|
40
|
+
|
41
|
+
// Panneau
|
42
|
+
$view->composer('panneau::app', \App\Panneau\Composers\AppComposer::class);
|
43
|
+
|
44
|
+
Panneau::serving(function () use ($view) {
|
45
|
+
$view->composer('errors::*', \App\Panneau\Composers\AppComposer::class);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Policies;
|
4
|
+
|
5
|
+
use Illuminate\Auth\Access\HandlesAuthorization;
|
6
|
+
use App\Contracts\Resources\User;
|
7
|
+
|
8
|
+
class PanneauPolicy
|
9
|
+
{
|
10
|
+
use HandlesAuthorization;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Create a new policy instance.
|
14
|
+
*
|
15
|
+
* @return void
|
16
|
+
*/
|
17
|
+
public function __construct()
|
18
|
+
{
|
19
|
+
//
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Determine if panneau can be viewed by the user.
|
24
|
+
*
|
25
|
+
* @param \App\User $user
|
26
|
+
* @return bool
|
27
|
+
*/
|
28
|
+
public function view(User $user)
|
29
|
+
{
|
30
|
+
return $user->role() === 'admin';
|
31
|
+
}
|
32
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Resources\Blocks;
|
4
|
+
|
5
|
+
use Panneau\Contracts\ResourceType;
|
6
|
+
use Panneau\Contracts\Repository;
|
7
|
+
use Panneau\Contracts\Resource;
|
8
|
+
use Panneau\Contracts\ResourceItem;
|
9
|
+
use App\Panneau\Fields\Blocks;
|
10
|
+
use JsonSerializable;
|
11
|
+
use Illuminate\Contracts\Support\Arrayable;
|
12
|
+
use Illuminate\Contracts\Support\Jsonable;
|
13
|
+
|
14
|
+
class BlockWithBlocks implements ResourceType, Arrayable, Jsonable
|
15
|
+
{
|
16
|
+
protected $type;
|
17
|
+
|
18
|
+
protected $depth;
|
19
|
+
|
20
|
+
public function __construct(ResourceType $type, $depth)
|
21
|
+
{
|
22
|
+
$this->type = $type;
|
23
|
+
$this->depth = $depth;
|
24
|
+
}
|
25
|
+
|
26
|
+
public function currentDepth(): int
|
27
|
+
{
|
28
|
+
return $this->depth;
|
29
|
+
}
|
30
|
+
|
31
|
+
public function id(): string
|
32
|
+
{
|
33
|
+
return $this->type->id();
|
34
|
+
}
|
35
|
+
|
36
|
+
public function name(): string
|
37
|
+
{
|
38
|
+
return $this->type->name();
|
39
|
+
}
|
40
|
+
|
41
|
+
public function fields(): array
|
42
|
+
{
|
43
|
+
return collect($this->type->fields())
|
44
|
+
->map(function ($field) {
|
45
|
+
return $field instanceof Blocks ? $field->currentDepth($this->depth) : $field;
|
46
|
+
})
|
47
|
+
->toArray();
|
48
|
+
}
|
49
|
+
|
50
|
+
public function resource(): Resource
|
51
|
+
{
|
52
|
+
return $this->type->resource();
|
53
|
+
}
|
54
|
+
|
55
|
+
public function settings(): ?array
|
56
|
+
{
|
57
|
+
return $this->type->settings();
|
58
|
+
}
|
59
|
+
|
60
|
+
public function makeRepository(): ?Repository
|
61
|
+
{
|
62
|
+
return $this->type->makeRepository();
|
63
|
+
}
|
64
|
+
|
65
|
+
public function makeJsonResource(ResourceItem $item): ?JsonSerializable
|
66
|
+
{
|
67
|
+
return $this->type->makeJsonResource($item);
|
68
|
+
}
|
69
|
+
|
70
|
+
public function makeJsonCollection($resources): ?JsonSerializable
|
71
|
+
{
|
72
|
+
return $this->type->makeJsonCollection($resources);
|
73
|
+
}
|
74
|
+
|
75
|
+
public function toArray()
|
76
|
+
{
|
77
|
+
$id = $this->id();
|
78
|
+
$data = [
|
79
|
+
'id' => $this->id(),
|
80
|
+
'name' => $this->name(),
|
81
|
+
'fields' => collect($this->resource()->fields())
|
82
|
+
->filter(function ($field) use ($id) {
|
83
|
+
$excepTypes = $field->exceptTypes();
|
84
|
+
$onlyTypes = $field->onlyTypes();
|
85
|
+
return (is_null($excepTypes) || !in_array($id, $excepTypes)) &&
|
86
|
+
(is_null($onlyTypes) || in_array($id, $onlyTypes));
|
87
|
+
})
|
88
|
+
->merge($this->fields())
|
89
|
+
->values()
|
90
|
+
->toArray(),
|
91
|
+
];
|
92
|
+
|
93
|
+
$settings = $this->settings();
|
94
|
+
if (isset($settings)) {
|
95
|
+
$data['settings'] = $settings;
|
96
|
+
}
|
97
|
+
|
98
|
+
return $data;
|
99
|
+
}
|
100
|
+
|
101
|
+
public function jsonSerialize()
|
102
|
+
{
|
103
|
+
return $this->type->jsonSerialize();
|
104
|
+
}
|
105
|
+
|
106
|
+
public function toJson($options = 0)
|
107
|
+
{
|
108
|
+
return $this->type->toJson($options);
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Resources\Blocks;
|
4
|
+
|
5
|
+
use Panneau\Support\ResourceType;
|
6
|
+
use Panneau\Fields\HtmlLocalized;
|
7
|
+
|
8
|
+
class TextBlock extends ResourceType
|
9
|
+
{
|
10
|
+
public function id(): string
|
11
|
+
{
|
12
|
+
return 'text';
|
13
|
+
}
|
14
|
+
|
15
|
+
public function name(): string
|
16
|
+
{
|
17
|
+
return trans('panneau.blocks_text');
|
18
|
+
}
|
19
|
+
|
20
|
+
public function fields(): array
|
21
|
+
{
|
22
|
+
return [
|
23
|
+
HtmlLocalized::make('body')
|
24
|
+
->withTransLabel('panneau.fields.body'),
|
25
|
+
];
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Resources;
|
4
|
+
|
5
|
+
use Panneau\Support\Resource;
|
6
|
+
|
7
|
+
class Blocks extends Resource
|
8
|
+
{
|
9
|
+
public static $repository = \App\Contracts\Repositories\Blocks::class;
|
10
|
+
|
11
|
+
public static $jsonResource = \App\Panneau\Http\Resources\BlockResource::class;
|
12
|
+
|
13
|
+
public static $jsonCollection = \App\Panneau\Http\Resources\BlocksCollection::class;
|
14
|
+
|
15
|
+
public static $settings = [
|
16
|
+
'hideInNavbar' => true,
|
17
|
+
];
|
18
|
+
|
19
|
+
public static $types = [\App\Panneau\Resources\Blocks\TextBlock::class];
|
20
|
+
|
21
|
+
public function name(): string
|
22
|
+
{
|
23
|
+
return trans('panneau.blocks.name');
|
24
|
+
}
|
25
|
+
|
26
|
+
public function index(): ?array
|
27
|
+
{
|
28
|
+
return [
|
29
|
+
'columns' => [
|
30
|
+
[
|
31
|
+
'id' => 'type',
|
32
|
+
'label' => 'Type',
|
33
|
+
],
|
34
|
+
],
|
35
|
+
];
|
36
|
+
}
|
37
|
+
|
38
|
+
public function fields(): array
|
39
|
+
{
|
40
|
+
return [];
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Resources\Pages;
|
4
|
+
|
5
|
+
use Panneau\Support\ResourceType;
|
6
|
+
use App\Panneau\Fields\Blocks;
|
7
|
+
use App\Panneau\Fields\Page as PageField;
|
8
|
+
|
9
|
+
class Page extends ResourceType
|
10
|
+
{
|
11
|
+
public function id(): string
|
12
|
+
{
|
13
|
+
return 'page';
|
14
|
+
}
|
15
|
+
|
16
|
+
public function name(): string
|
17
|
+
{
|
18
|
+
return trans('panneau.pages_page');
|
19
|
+
}
|
20
|
+
|
21
|
+
public function fields(): array
|
22
|
+
{
|
23
|
+
return [
|
24
|
+
PageField::make('parent')->withTransLabel('panneau.fields.parent'),
|
25
|
+
Blocks::make('blocks')->withTransLabel('panneau.fields.blocks'),
|
26
|
+
];
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<?php
|
2
|
+
namespace App\Panneau\Resources;
|
3
|
+
|
4
|
+
use App\Panneau\Fields\ImageLocalized;
|
5
|
+
use App\Panneau\Fields\PageSlugLocalized;
|
6
|
+
use Panneau\Fields\TextLocalized;
|
7
|
+
use Panneau\Fields\Toggle;
|
8
|
+
use Panneau\Support\Resource;
|
9
|
+
|
10
|
+
class Pages extends Resource
|
11
|
+
{
|
12
|
+
public static $repository = \App\Contracts\Repositories\Pages::class;
|
13
|
+
|
14
|
+
public static $controller = \App\Panneau\Http\Controllers\PagesController::class;
|
15
|
+
|
16
|
+
public static $jsonResource = \App\Panneau\Http\Resources\PageResource::class;
|
17
|
+
|
18
|
+
public static $jsonCollection = \App\Panneau\Http\Resources\PagesCollection::class;
|
19
|
+
|
20
|
+
public static $types = [\App\Panneau\Resources\Pages\Page::class];
|
21
|
+
|
22
|
+
public static $settings = [
|
23
|
+
'hideInNavbar' => false,
|
24
|
+
'indexIsPaginated' => true,
|
25
|
+
'canCreate' => true,
|
26
|
+
];
|
27
|
+
|
28
|
+
public function name(): string
|
29
|
+
{
|
30
|
+
return trans('panneau.pages.name');
|
31
|
+
}
|
32
|
+
|
33
|
+
public function index(): ?array
|
34
|
+
{
|
35
|
+
return [
|
36
|
+
'columns' => [
|
37
|
+
[
|
38
|
+
'label' => trans('panneau.columns.title'),
|
39
|
+
'component' => 'text-localized',
|
40
|
+
'path' => 'title',
|
41
|
+
],
|
42
|
+
[
|
43
|
+
'id' => 'type',
|
44
|
+
'label' => 'Type',
|
45
|
+
'component' => 'label',
|
46
|
+
'labels' => $this->getTypes()->mapWithKeys(function ($type) {
|
47
|
+
return [
|
48
|
+
$type->id() => $type->name(),
|
49
|
+
];
|
50
|
+
}),
|
51
|
+
],
|
52
|
+
[
|
53
|
+
'id' => 'parent',
|
54
|
+
'label' => trans('panneau.columns.parent_page'),
|
55
|
+
'path' => 'parent.title.fr',
|
56
|
+
],
|
57
|
+
'published',
|
58
|
+
[
|
59
|
+
'id' => 'actions',
|
60
|
+
'actions' => ['show', 'edit', 'delete'],
|
61
|
+
],
|
62
|
+
],
|
63
|
+
'filters' => [
|
64
|
+
[
|
65
|
+
'name' => 'search',
|
66
|
+
'component' => 'search',
|
67
|
+
'placeholder' => trans('panneau.filters.search'),
|
68
|
+
],
|
69
|
+
],
|
70
|
+
];
|
71
|
+
}
|
72
|
+
|
73
|
+
public function fields(): array
|
74
|
+
{
|
75
|
+
return [
|
76
|
+
Toggle::make('published')
|
77
|
+
->withTransLabel('panneau.fields.published')
|
78
|
+
->hideInForm(),
|
79
|
+
TextLocalized::make('title')->withTransLabel('panneau.fields.title'),
|
80
|
+
PageSlugLocalized::make('slug')
|
81
|
+
->isDisabled()
|
82
|
+
->withTransLabel('panneau.fields.url'),
|
83
|
+
TextLocalized::make('description')
|
84
|
+
->isRequired()
|
85
|
+
->isTextarea()
|
86
|
+
->withTransLabel('panneau.fields.description_short'),
|
87
|
+
ImageLocalized::make('image')
|
88
|
+
->withTransLabel('panneau.fields.image')
|
89
|
+
->withButton(),
|
90
|
+
];
|
91
|
+
}
|
92
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Resources;
|
4
|
+
|
5
|
+
use Panneau\Support\Resource;
|
6
|
+
use Panneau\Fields\Text;
|
7
|
+
use Panneau\Fields\Email;
|
8
|
+
use Panneau\Fields\Password;
|
9
|
+
use Panneau\Fields\Select;
|
10
|
+
|
11
|
+
class Users extends Resource
|
12
|
+
{
|
13
|
+
public static $repository = \App\Contracts\Repositories\Users::class;
|
14
|
+
|
15
|
+
public static $controller = \App\Panneau\Http\Controllers\UsersController::class;
|
16
|
+
|
17
|
+
public static $jsonResource = \App\Panneau\Http\Resources\UserResource::class;
|
18
|
+
|
19
|
+
public static $jsonCollection = \App\Panneau\Http\Resources\UsersCollection::class;
|
20
|
+
|
21
|
+
public static $settings = [
|
22
|
+
'hideInNavbar' => false,
|
23
|
+
'indexIsPaginated' => true,
|
24
|
+
'canCreate' => true,
|
25
|
+
];
|
26
|
+
|
27
|
+
public function name(): string
|
28
|
+
{
|
29
|
+
return trans('panneau.users.name');
|
30
|
+
}
|
31
|
+
|
32
|
+
public function index(): ?array
|
33
|
+
{
|
34
|
+
return [
|
35
|
+
'columns' => ['name', 'email', 'role'],
|
36
|
+
];
|
37
|
+
}
|
38
|
+
|
39
|
+
public function fields(): array
|
40
|
+
{
|
41
|
+
return [
|
42
|
+
Text::make('name')->withTransLabel('panneau.fields.name'),
|
43
|
+
Email::make('email')->withTransLabel('panneau.fields.email'),
|
44
|
+
Password::make('password')->withTransLabel('panneau.fields.password'),
|
45
|
+
Select::make('role')
|
46
|
+
->withTransLabel('panneau.fields.role')
|
47
|
+
->withOptions([
|
48
|
+
[
|
49
|
+
'value' => 'admin',
|
50
|
+
'label' => trans('panneau.roles.admin'),
|
51
|
+
],
|
52
|
+
])
|
53
|
+
->withoutReset()
|
54
|
+
->withDefaultValue('guest'),
|
55
|
+
];
|
56
|
+
}
|
57
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Repositories;
|
4
|
+
|
5
|
+
use Folklore\Repositories\Pages as BasePages;
|
6
|
+
use App\Contracts\Repositories\Pages as PagesContract;
|
7
|
+
use Folklore\Models\Page as PageBaseModel;
|
8
|
+
use App\Models\Page as PageModel;
|
9
|
+
use App\Contracts\Resources\Page as PageContract;
|
10
|
+
|
11
|
+
class Pages extends BasePages implements PagesContract
|
12
|
+
{
|
13
|
+
protected function newModel(): PageBaseModel
|
14
|
+
{
|
15
|
+
return new PageModel();
|
16
|
+
}
|
17
|
+
|
18
|
+
public function findById(string $id): ?PageContract
|
19
|
+
{
|
20
|
+
return parent::findById($id);
|
21
|
+
}
|
22
|
+
|
23
|
+
public function findByHandle(string $handle): ?PageContract
|
24
|
+
{
|
25
|
+
return parent::findByHandle($handle);
|
26
|
+
}
|
27
|
+
|
28
|
+
public function findBySlug(string $slug, string $locale = null): ?PageContract
|
29
|
+
{
|
30
|
+
return parent::findBySlug($slug, $locale);
|
31
|
+
}
|
32
|
+
|
33
|
+
public function create(array $data): PageContract
|
34
|
+
{
|
35
|
+
return parent::create($data);
|
36
|
+
}
|
37
|
+
|
38
|
+
public function update(string $id, array $data): ?PageContract
|
39
|
+
{
|
40
|
+
return parent::update($id, $data);
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Resources\Pages;
|
4
|
+
|
5
|
+
use Folklore\Resources\Block;
|
6
|
+
use App\Contracts\Resources\Blocks\Text as TextBlockContract;
|
7
|
+
|
8
|
+
class TextBlock extends Block implements TextBlockContract
|
9
|
+
{
|
10
|
+
public function body(string $locale): ?string
|
11
|
+
{
|
12
|
+
return data_get($this->data, 'body.' . $locale);
|
13
|
+
}
|
14
|
+
}
|