generator-folklore 3.0.3 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,37 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\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
|
+
$locale = $request->locale();
|
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 () use ($locale) {
|
31
|
+
return [
|
32
|
+
'body' => $this->body($locale),
|
33
|
+
];
|
34
|
+
}),
|
35
|
+
];
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\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 App\Contracts\Resources\Pages\Home as HomePage;
|
10
|
+
|
11
|
+
class PageResource extends JsonResource
|
12
|
+
{
|
13
|
+
/**
|
14
|
+
* Transform the resource into an array.
|
15
|
+
*
|
16
|
+
* @param \Illuminate\Http\Request $request
|
17
|
+
* @return array
|
18
|
+
*/
|
19
|
+
public function toArray($request)
|
20
|
+
{
|
21
|
+
$locale = $request->locale();
|
22
|
+
return [
|
23
|
+
'id' => $this->id(),
|
24
|
+
'type' => $this->type(),
|
25
|
+
'published' => $this->published(),
|
26
|
+
'title' => $this->title($locale),
|
27
|
+
'description' => $this->description($locale),
|
28
|
+
'slug' => $this->slug($locale),
|
29
|
+
'image' => !is_null($image) ? new ImageResource($image) : null,
|
30
|
+
'parent' =>
|
31
|
+
!is_null($parent) && $parent instanceof Page
|
32
|
+
? new ParentPageResource($parent)
|
33
|
+
: null,
|
34
|
+
|
35
|
+
$this->mergeWhen($this->resource instanceof HasBlocks, function () {
|
36
|
+
$blocks = $this->blocks();
|
37
|
+
return [
|
38
|
+
'blocks' => !is_null($blocks) ? new BlocksCollection($blocks) : [],
|
39
|
+
];
|
40
|
+
}),
|
41
|
+
|
42
|
+
$this->mergeWhen($this->resource instanceof HomePage, function () {
|
43
|
+
return [];
|
44
|
+
}),
|
45
|
+
];
|
46
|
+
}
|
47
|
+
}
|
@@ -2,21 +2,11 @@
|
|
2
2
|
|
3
3
|
namespace App\Models;
|
4
4
|
|
5
|
-
use Folklore\
|
5
|
+
use Folklore\Models\Block as BaseBlock;
|
6
6
|
|
7
7
|
class Block extends BaseBlock
|
8
8
|
{
|
9
|
-
protected $
|
10
|
-
'
|
11
|
-
'audios',
|
12
|
-
'videos',
|
13
|
-
'pivot',
|
14
|
-
'deleted_at'
|
15
|
-
];
|
16
|
-
|
17
|
-
protected $jsonSchemasReducers = [
|
18
|
-
\Folklore\Panneau\Reducers\BlocksReducer::class,
|
19
|
-
\Folklore\Panneau\Reducers\PagesReducer::class,
|
20
|
-
\Folklore\Panneau\Reducers\MediasReducer::class,
|
9
|
+
protected $typeResources = [
|
10
|
+
'text' => \App\Resources\Blocks\TextBlock::class,
|
21
11
|
];
|
22
12
|
}
|
@@ -2,68 +2,11 @@
|
|
2
2
|
|
3
3
|
namespace App\Models;
|
4
4
|
|
5
|
-
use Folklore\
|
6
|
-
use Folklore\Panneau\Contracts\Page as PageContract;
|
5
|
+
use Folklore\Models\Page as BasePage;
|
7
6
|
|
8
7
|
class Page extends BasePage
|
9
8
|
{
|
10
|
-
protected $
|
11
|
-
'
|
12
|
-
'slug_en',
|
13
|
-
'blocks',
|
14
|
-
'pages',
|
15
|
-
'pictures',
|
16
|
-
'audios',
|
17
|
-
'videos',
|
18
|
-
'order',
|
19
|
-
'deleted_at'
|
9
|
+
protected $typeResources = [
|
10
|
+
'text' => \App\Resources\Pages\HomePage::class,
|
20
11
|
];
|
21
|
-
|
22
|
-
protected $appends = [
|
23
|
-
'url',
|
24
|
-
'urls',
|
25
|
-
];
|
26
|
-
|
27
|
-
protected $jsonSchemasReducers = [
|
28
|
-
\Folklore\Panneau\Reducers\BlocksReducer::class,
|
29
|
-
\Folklore\Panneau\Reducers\PagesReducer::class,
|
30
|
-
\Folklore\Panneau\Reducers\MediasReducer::class,
|
31
|
-
\Folklore\Panneau\Reducers\SlugReducer::class,
|
32
|
-
\App\Reducers\SlugExtractReducer::class,
|
33
|
-
];
|
34
|
-
|
35
|
-
protected function getUrlAttribute()
|
36
|
-
{
|
37
|
-
return $this->getUrl();
|
38
|
-
}
|
39
|
-
|
40
|
-
protected function getUrlsAttribute()
|
41
|
-
{
|
42
|
-
$urls = [];
|
43
|
-
$locales = config('locale.locales', []);
|
44
|
-
foreach ($locales as $locale) {
|
45
|
-
$urls[$locale] = $this->getUrl($locale);
|
46
|
-
}
|
47
|
-
return $urls;
|
48
|
-
}
|
49
|
-
|
50
|
-
protected function getUrl($locale = null)
|
51
|
-
{
|
52
|
-
if (is_null($locale)) {
|
53
|
-
$locale = app()->getLocale();
|
54
|
-
}
|
55
|
-
return '';
|
56
|
-
// return route('pages.show.'.$locale, [array_get($this->attributes, 'slug_'.$locale)]);
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Get the route key for the model.
|
61
|
-
*
|
62
|
-
* @return string
|
63
|
-
*/
|
64
|
-
public function getRouteKeyName()
|
65
|
-
{
|
66
|
-
$locale = app()->getLocale();
|
67
|
-
return 'slug_'.$locale;
|
68
|
-
}
|
69
12
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Composers;
|
4
|
+
|
5
|
+
use Illuminate\Http\Request;
|
6
|
+
use Illuminate\View\View;
|
7
|
+
use App\Panneau\Http\Resources\UserResource;
|
8
|
+
|
9
|
+
class AppComposer
|
10
|
+
{
|
11
|
+
/**
|
12
|
+
* The request
|
13
|
+
*
|
14
|
+
* @var \Illuminate\Http\Request
|
15
|
+
*/
|
16
|
+
protected $request;
|
17
|
+
|
18
|
+
protected $panneau;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Create a new profile composer.
|
22
|
+
*
|
23
|
+
* @param \Illuminate\Http\Request $request
|
24
|
+
* @return void
|
25
|
+
*/
|
26
|
+
public function __construct(Request $request)
|
27
|
+
{
|
28
|
+
$this->request = $request;
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Bind data to the view.
|
33
|
+
*
|
34
|
+
* @param View $view
|
35
|
+
* @return void
|
36
|
+
*/
|
37
|
+
public function compose(View $view)
|
38
|
+
{
|
39
|
+
$user = $this->request->user();
|
40
|
+
|
41
|
+
$view->props = array_merge(isset($view->props) ? $view->props : [], [
|
42
|
+
'user' => !is_null($user) ? new UserResource($user) : null,
|
43
|
+
'isPanneau' => true,
|
44
|
+
'statusCode' => $view->statusCode,
|
45
|
+
'pubnubNamespace' => config('services.pubnub.namespace'),
|
46
|
+
'pubnubPublishKey' => config('services.pubnub.publish_key'),
|
47
|
+
'pubnubSubscribeKey' => config('services.pubnub.subscribe_key'),
|
48
|
+
]);
|
49
|
+
}
|
50
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Fields;
|
4
|
+
|
5
|
+
use Panneau\Fields\ResourceItem;
|
6
|
+
|
7
|
+
class Block extends ResourceItem
|
8
|
+
{
|
9
|
+
public function resource(): string
|
10
|
+
{
|
11
|
+
return 'blocks';
|
12
|
+
}
|
13
|
+
|
14
|
+
public function attributes(): ?array
|
15
|
+
{
|
16
|
+
return array_merge(parent::attributes(), [
|
17
|
+
'placeholder' => trans('panneau.fields.blocks_placeholder'),
|
18
|
+
'itemLabelPath' => 'title',
|
19
|
+
'itemDescriptionPath' => null,
|
20
|
+
]);
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Fields;
|
4
|
+
|
5
|
+
use Panneau\Fields\Items;
|
6
|
+
use Panneau\Fields\ResourceItem;
|
7
|
+
use App\Panneau\Resources\Blocks\BlockWithBlocks;
|
8
|
+
|
9
|
+
class Blocks extends Items
|
10
|
+
{
|
11
|
+
protected $currentDepth = 0;
|
12
|
+
|
13
|
+
protected $maxDepth = null;
|
14
|
+
|
15
|
+
protected $excludeTypes = [];
|
16
|
+
|
17
|
+
public function itemField(): ?string
|
18
|
+
{
|
19
|
+
return Block::class;
|
20
|
+
}
|
21
|
+
|
22
|
+
public function attributes(): ?array
|
23
|
+
{
|
24
|
+
// With types
|
25
|
+
$itemField = $this->itemField();
|
26
|
+
$itemField = !is_null($itemField) ? resolve($itemField) : null;
|
27
|
+
$itemResource =
|
28
|
+
!is_null($itemField) && $itemField instanceof ResourceItem
|
29
|
+
? $itemField->makeResource()
|
30
|
+
: null;
|
31
|
+
$resourceTypes =
|
32
|
+
!is_null($itemResource) && $itemResource->hasTypes() ? $itemResource->getTypes() : null;
|
33
|
+
|
34
|
+
$attributes = [
|
35
|
+
'withoutFormGroup' => true,
|
36
|
+
'addItemLabel' => trans('panneau.fields.add_block'),
|
37
|
+
'noItemLabel' => trans('panneau.fields.no_blocks'),
|
38
|
+
'itemLabel' => trans('panneau.fields.block'),
|
39
|
+
'withoutSort' => false,
|
40
|
+
];
|
41
|
+
|
42
|
+
if (!is_null($resourceTypes)) {
|
43
|
+
$attributes['types'] = $resourceTypes
|
44
|
+
->filter(function ($type) {
|
45
|
+
$key = get_class($type);
|
46
|
+
return !in_array($key, $this->excludeTypes);
|
47
|
+
})
|
48
|
+
->map(function ($type) {
|
49
|
+
$hasBlocks = collect($type->fields())->contains(function ($field) {
|
50
|
+
return $field instanceof self;
|
51
|
+
});
|
52
|
+
if (isset($this->maxDepth) && $hasBlocks) {
|
53
|
+
return new BlockWithBlocks($type, $this->currentDepth + 1);
|
54
|
+
}
|
55
|
+
return $type;
|
56
|
+
})
|
57
|
+
->filter(function ($type) {
|
58
|
+
if (isset($this->maxDepth) && $type instanceof BlockWithBlocks) {
|
59
|
+
return $type->currentDepth() < $this->maxDepth;
|
60
|
+
}
|
61
|
+
return true;
|
62
|
+
})
|
63
|
+
->values()
|
64
|
+
->toArray();
|
65
|
+
}
|
66
|
+
|
67
|
+
return $attributes;
|
68
|
+
}
|
69
|
+
|
70
|
+
public function maxDepth($depth)
|
71
|
+
{
|
72
|
+
$this->maxDepth = $depth;
|
73
|
+
return $this;
|
74
|
+
}
|
75
|
+
|
76
|
+
public function currentDepth($depth)
|
77
|
+
{
|
78
|
+
$this->currentDepth = $depth;
|
79
|
+
return $this;
|
80
|
+
}
|
81
|
+
|
82
|
+
public function withoutType($type)
|
83
|
+
{
|
84
|
+
$this->excludeTypes[] = is_object($type) ? get_class($type) : $type;
|
85
|
+
return $this;
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Fields;
|
4
|
+
|
5
|
+
use Panneau\Fields\ResourceItem;
|
6
|
+
|
7
|
+
class Page extends ResourceItem
|
8
|
+
{
|
9
|
+
protected $query = [
|
10
|
+
'paginated' => false,
|
11
|
+
];
|
12
|
+
|
13
|
+
protected $pageTypes = [];
|
14
|
+
|
15
|
+
public function resource(): string
|
16
|
+
{
|
17
|
+
return 'pages';
|
18
|
+
}
|
19
|
+
|
20
|
+
public function component(): string
|
21
|
+
{
|
22
|
+
return 'item';
|
23
|
+
}
|
24
|
+
|
25
|
+
public function attributes(): ?array
|
26
|
+
{
|
27
|
+
$query = $this->query;
|
28
|
+
if (isset($this->pageTypes) && sizeof($this->pageTypes) > 0) {
|
29
|
+
$query['type'] = $this->pageTypes;
|
30
|
+
}
|
31
|
+
|
32
|
+
return array_merge(parent::attributes(), [
|
33
|
+
'placeholder' => trans('panneau.forms.page_placeholder'),
|
34
|
+
'itemLabelPath' => 'title.'.app()->getLocale(),
|
35
|
+
'itemImagePath' => null,
|
36
|
+
'requestQuery' => $query,
|
37
|
+
]);
|
38
|
+
}
|
39
|
+
|
40
|
+
public function withQuery($query)
|
41
|
+
{
|
42
|
+
$this->query = $query;
|
43
|
+
return $this;
|
44
|
+
}
|
45
|
+
|
46
|
+
public function withTypes($types)
|
47
|
+
{
|
48
|
+
$this->pageTypes = is_array($types) ? $types : func_get_args();
|
49
|
+
return $this;
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Fields;
|
4
|
+
|
5
|
+
use Panneau\Fields\Text;
|
6
|
+
|
7
|
+
class PageSlug extends Text
|
8
|
+
{
|
9
|
+
public function component(): string
|
10
|
+
{
|
11
|
+
return 'page-slug';
|
12
|
+
}
|
13
|
+
|
14
|
+
public function attributes(): ?array
|
15
|
+
{
|
16
|
+
$locale = app()->getLocale();
|
17
|
+
$locales = config('locale.locales');
|
18
|
+
$finalLocale = in_array($this->name, $locales) ? $this->name : $locale;
|
19
|
+
|
20
|
+
return array_merge(parent::attributes(), [
|
21
|
+
'routes' => [
|
22
|
+
'page' => url()->routeForReactRouter($finalLocale . '.page', [
|
23
|
+
'withoutPatterns' => true,
|
24
|
+
]),
|
25
|
+
'page_with_parent' => url()->routeForReactRouter(
|
26
|
+
$finalLocale . '.page_with_parent',
|
27
|
+
[
|
28
|
+
'withoutPatterns' => true,
|
29
|
+
]
|
30
|
+
),
|
31
|
+
],
|
32
|
+
]);
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Fields;
|
4
|
+
|
5
|
+
use Panneau\Support\LocalizedField;
|
6
|
+
|
7
|
+
class PageSlugLocalized extends LocalizedField
|
8
|
+
{
|
9
|
+
public function component(): string
|
10
|
+
{
|
11
|
+
return 'page-slug-localized';
|
12
|
+
}
|
13
|
+
|
14
|
+
public function field($locale)
|
15
|
+
{
|
16
|
+
return new PageSlug($locale);
|
17
|
+
}
|
18
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/AccountController.php
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
use App\Http\Controllers\Controller;
|
6
|
+
use App\Http\Resources\UserResource;
|
7
|
+
use App\Panneau\Http\Requests\AccountUpdateRequest;
|
8
|
+
use Folklore\Contracts\Repositories\Users as UsersRepository;
|
9
|
+
|
10
|
+
class AccountController extends Controller
|
11
|
+
{
|
12
|
+
protected $users;
|
13
|
+
|
14
|
+
public function __construct(UsersRepository $users)
|
15
|
+
{
|
16
|
+
$this->users = $users;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Show the account
|
21
|
+
*
|
22
|
+
* @return \Illuminate\Contracts\Support\Renderable
|
23
|
+
*/
|
24
|
+
public function index()
|
25
|
+
{
|
26
|
+
return view('panneau::app');
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Update the account
|
31
|
+
*
|
32
|
+
* @return \Illuminate\Contracts\Support\Renderable
|
33
|
+
*/
|
34
|
+
public function update(AccountUpdateRequest $request)
|
35
|
+
{
|
36
|
+
$data = $request->all();
|
37
|
+
$user = $request->user();
|
38
|
+
$user = $this->users->update($user->id(), $data);
|
39
|
+
return new UserResource($user);
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
use Illuminate\Support\Str;
|
6
|
+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
7
|
+
use Illuminate\Foundation\Bus\DispatchesJobs;
|
8
|
+
use Illuminate\Foundation\Validation\ValidatesRequests;
|
9
|
+
use Illuminate\Routing\Controller as BaseController;
|
10
|
+
|
11
|
+
class Controller extends BaseController
|
12
|
+
{
|
13
|
+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
14
|
+
|
15
|
+
protected function requestIsJson($request)
|
16
|
+
{
|
17
|
+
return $request->wantsJson() || Str::endsWith($request->path(), '.json');
|
18
|
+
}
|
19
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/HomeController.php
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
class HomeController extends Controller
|
6
|
+
{
|
7
|
+
/**
|
8
|
+
* Show the home
|
9
|
+
*
|
10
|
+
* @return \Illuminate\Contracts\Support\Renderable
|
11
|
+
*/
|
12
|
+
public function index()
|
13
|
+
{
|
14
|
+
return view('panneau::app');
|
15
|
+
}
|
16
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/PagesController.php
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
use Illuminate\Http\Request;
|
6
|
+
use Panneau\Contracts\Resource;
|
7
|
+
use Panneau\Http\Controllers\ResourceController;
|
8
|
+
|
9
|
+
class PagesController extends ResourceController
|
10
|
+
{
|
11
|
+
protected $defaultPageCount = 25;
|
12
|
+
|
13
|
+
protected function getResourceFromRequest(Request $request)
|
14
|
+
{
|
15
|
+
return app('panneau')->resource('pages');
|
16
|
+
}
|
17
|
+
|
18
|
+
protected function getIndexQueryFromRequest(Request $request, Resource $resource)
|
19
|
+
{
|
20
|
+
$query = parent::getIndexQueryFromRequest($request, $resource);
|
21
|
+
|
22
|
+
return $query;
|
23
|
+
}
|
24
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
use App\Panneau\Http\Requests\UploadRequest;
|
6
|
+
use Folklore\Contracts\Repositories\Medias as MediasRepository;
|
7
|
+
use Folklore\Http\Resources\Medias\MediaResource;
|
8
|
+
|
9
|
+
class UploadController extends Controller
|
10
|
+
{
|
11
|
+
public function __construct(MediasRepository $medias)
|
12
|
+
{
|
13
|
+
$this->medias = $medias;
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Show the account
|
18
|
+
*
|
19
|
+
* @return \Illuminate\Contracts\Support\Renderable
|
20
|
+
*/
|
21
|
+
public function upload(UploadRequest $request)
|
22
|
+
{
|
23
|
+
$file = $request->file('file');
|
24
|
+
$media = $this->medias->createFromFile($file);
|
25
|
+
return new MediaResource($media);
|
26
|
+
}
|
27
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UsersController.php
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Controllers;
|
4
|
+
|
5
|
+
use Illuminate\Http\Request;
|
6
|
+
use Panneau\Http\Controllers\ResourceController;
|
7
|
+
use Panneau\Contracts\Resource;
|
8
|
+
|
9
|
+
class UsersController extends ResourceController
|
10
|
+
{
|
11
|
+
protected $defaultPageCount = 100;
|
12
|
+
|
13
|
+
protected function getResourceFromRequest(Request $request)
|
14
|
+
{
|
15
|
+
return app('panneau')->resource('users');
|
16
|
+
}
|
17
|
+
|
18
|
+
protected function getIndexQueryFromRequest(Request $request, Resource $resource)
|
19
|
+
{
|
20
|
+
$query = parent::getIndexQueryFromRequest($request, $resource);
|
21
|
+
|
22
|
+
if (!isset($query['order'])) {
|
23
|
+
$query['order'] = 'created_at';
|
24
|
+
}
|
25
|
+
|
26
|
+
if (!isset($query['role'])) {
|
27
|
+
$query['role'] = 'admin';
|
28
|
+
}
|
29
|
+
|
30
|
+
return $query;
|
31
|
+
}
|
32
|
+
}
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/AccountUpdateRequest.php
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Requests;
|
4
|
+
|
5
|
+
use Illuminate\Foundation\Http\FormRequest;
|
6
|
+
|
7
|
+
class AccountUpdateRequest 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
|
+
}
|