generator-folklore 3.0.5 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/generators/build/index.js +1 -1
- package/lib/generators/eslint/index.js +1 -1
- package/lib/generators/intl/index.js +93 -0
- package/lib/generators/laravel-mediatheque/index.js +151 -0
- package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -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 +89 -28
- package/lib/generators/laravel-panneau/instructions/ServiceProvider.php +21 -0
- package/lib/generators/laravel-panneau/instructions/config.php +13 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Image.php +15 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +12 -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 +4 -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/{Schemas → Panneau}/Fields/.gitkeep +0 -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 +10 -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/Http/Resources/UsersCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +74 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/ImageBlock.php +30 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +28 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +45 -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/ImageBlock.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +19 -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/config.php +29 -0
- package/lib/generators/laravel-panneau/templates/index.js +32 -0
- package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +66 -0
- package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +66 -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/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -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 +519 -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/Repositories/Users.php +17 -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 +20 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +120 -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 +37 -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/image.php +204 -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/laravel-project/templates/laravel/resources/assets/fonts/.gitkeep +0 -0
- package/lib/generators/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/prettier/index.js +1 -1
- package/lib/generators/react-app/index.js +2 -2
- package/lib/generators/react-app/templates/src/components/App.jsx +3 -2
- package/lib/generators/react-app/templates/src/components/pages/Error.jsx +2 -2
- package/lib/generators/stylelint/index.js +1 -1
- package/lib/lib/generator.js +9 -0
- package/package.json +5 -4
- 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,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,12 @@
|
|
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
|
-
'
|
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,
|
11
|
+
'image' => \App\Resources\Blocks\ImageBlock::class,
|
21
12
|
];
|
22
13
|
}
|
@@ -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
|
+
}
|
File without changes
|
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
|
+
}
|
@@ -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,74 @@
|
|
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\Fields\Upload as UploadField;
|
9
|
+
use Panneau\Support\LocalizedField;
|
10
|
+
use Folklore\Panneau\Fields\PageSlug as PageSlugField;
|
11
|
+
use Panneau\Support\Facade as Panneau;
|
12
|
+
|
13
|
+
class PanneauServiceProvider extends BaseServiceProvider
|
14
|
+
{
|
15
|
+
/**
|
16
|
+
* Register any application services.
|
17
|
+
*
|
18
|
+
* @return void
|
19
|
+
*/
|
20
|
+
public function register()
|
21
|
+
{
|
22
|
+
Gate::policy(\Panneau\Panneau::class, \App\Panneau\Policies\PanneauPolicy::class);
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Bootstrap any application services.
|
27
|
+
*
|
28
|
+
* @return void
|
29
|
+
*/
|
30
|
+
public function boot()
|
31
|
+
{
|
32
|
+
$this->bootFields();
|
33
|
+
$this->bootViews();
|
34
|
+
}
|
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
|
+
|
61
|
+
protected function bootViews()
|
62
|
+
{
|
63
|
+
$view = $this->app[ViewFactory::class];
|
64
|
+
|
65
|
+
// Panneau
|
66
|
+
$view->composer('panneau::app', \App\Panneau\Composers\AppComposer::class);
|
67
|
+
|
68
|
+
Panneau::serving(function () use ($view) {
|
69
|
+
$view->composer('errors::*', \Panneau\Composers\PanneauComposer::class);
|
70
|
+
$view->composer('errors::*', \Panneau\Composers\AppComposer::class);
|
71
|
+
$view->composer('errors::*', \App\Panneau\Composers\AppComposer::class);
|
72
|
+
});
|
73
|
+
}
|
74
|
+
}
|