generator-folklore 3.0.6 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/generators/babel/index.js +8 -1
- package/lib/generators/build/index.js +3 -1
- package/lib/generators/cli/index.js +4 -1
- package/lib/generators/docs/index.js +9 -4
- package/lib/generators/eslint/index.js +12 -1
- package/lib/generators/intl/index.js +3 -1
- package/lib/generators/laravel-mediatheque/index.js +18 -0
- package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -0
- package/lib/generators/laravel-panneau/index.js +51 -5
- 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 +2 -2
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Block.php +10 -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 +2 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +1 -1
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +2 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +6 -4
- package/lib/generators/laravel-panneau/templates/app/Models/Block.php +11 -0
- package/lib/generators/laravel-panneau/templates/app/Models/Media.php +11 -0
- package/lib/generators/laravel-panneau/templates/app/Models/Page.php +12 -2
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/.gitkeep +0 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +2 -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 +30 -4
- 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 +3 -2
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +4 -1
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Resources/Block.php +10 -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 +7 -2
- package/lib/generators/laravel-panneau/templates/config.php +29 -0
- package/lib/generators/laravel-panneau/templates/index.js +1 -1
- package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +4 -0
- package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +4 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -0
- package/lib/generators/laravel-project/index.js +27 -12
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/CreateNewUser.php +41 -0
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/ResetUserPassword.php +31 -0
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserPassword.php +34 -0
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserProfileInformation.php +61 -0
- package/lib/generators/laravel-project/templates/laravel/app/Contracts/Repositories/Users.php +17 -0
- package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +0 -30
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +90 -15
- package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +4 -3
- package/lib/generators/laravel-project/templates/laravel/config/app.php +3 -2
- package/lib/generators/laravel-project/templates/laravel/config/image.php +204 -0
- package/lib/generators/lerna-repository/index.js +8 -3
- package/lib/generators/npm-package/index.js +6 -2
- package/lib/generators/prettier/index.js +5 -1
- package/lib/generators/react-app/index.js +22 -2
- package/lib/generators/react-package/index.js +14 -5
- package/lib/generators/rollup/index.js +8 -1
- package/lib/generators/server/index.js +9 -2
- package/lib/generators/storybook/index.js +9 -1
- package/lib/generators/stylelint/index.js +6 -1
- package/lib/generators/test/index.js +10 -1
- package/package.json +6 -5
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +0 -22
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +0 -87
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +0 -51
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +0 -34
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +0 -18
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +0 -110
@@ -1,12 +1,17 @@
|
|
1
1
|
<?php
|
2
2
|
|
3
|
-
namespace App\Resources\
|
3
|
+
namespace App\Resources\Blocks;
|
4
4
|
|
5
|
-
use
|
5
|
+
use App\Resources\Block;
|
6
6
|
use App\Contracts\Resources\Blocks\Text as TextBlockContract;
|
7
7
|
|
8
8
|
class TextBlock extends Block implements TextBlockContract
|
9
9
|
{
|
10
|
+
public function title(string $locale): ?string
|
11
|
+
{
|
12
|
+
return data_get($this->data, 'title.' . $locale);
|
13
|
+
}
|
14
|
+
|
10
15
|
public function body(string $locale): ?string
|
11
16
|
{
|
12
17
|
return data_get($this->data, 'body.' . $locale);
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
return [
|
4
|
+
'intl' => [
|
5
|
+
'locale' => 'fr',
|
6
|
+
'locales' => ['fr', 'en'],
|
7
|
+
'translations' => ['panneau::resources', 'panneau'],
|
8
|
+
],
|
9
|
+
|
10
|
+
'resources' => [
|
11
|
+
\App\Panneau\Resources\Blocks::class,
|
12
|
+
\App\Panneau\Resources\Pages::class,
|
13
|
+
\App\Panneau\Resources\Users::class,
|
14
|
+
],
|
15
|
+
|
16
|
+
'routes' => [
|
17
|
+
// Path to the routes file that will be automatically loaded. Set to null
|
18
|
+
// to prevent auto-loading of routes.
|
19
|
+
'map' => base_path('routes/panneau.php'),
|
20
|
+
|
21
|
+
'prefix' => 'panneau',
|
22
|
+
|
23
|
+
'middleware' => [\Panneau\Http\Middleware\DispatchHandlingRequestEvent::class],
|
24
|
+
|
25
|
+
'custom' => [],
|
26
|
+
|
27
|
+
'without_patterns' => true,
|
28
|
+
],
|
29
|
+
];
|
@@ -17,7 +17,7 @@ function renderApp(Container, props) {
|
|
17
17
|
|
18
18
|
function loadContainer({ isPanneau = false }) {
|
19
19
|
return isPanneau
|
20
|
-
? import('./components/Panneau')
|
20
|
+
? import('./components/Panneau').then(({ default: Container }) => Container)
|
21
21
|
: import('./components/Container').then(({ default: Container }) => Container);
|
22
22
|
}
|
23
23
|
|
@@ -6,6 +6,8 @@ return [
|
|
6
6
|
'url' => 'Address',
|
7
7
|
'published' => 'Published',
|
8
8
|
'description_short' => 'Short description',
|
9
|
+
'caption' => 'Caption',
|
10
|
+
'credits' => 'Credits',
|
9
11
|
'name' => 'Name',
|
10
12
|
'email' => 'Email',
|
11
13
|
'password' => 'Password',
|
@@ -13,6 +15,7 @@ return [
|
|
13
15
|
'body' => 'Text',
|
14
16
|
'parent' => 'Parent',
|
15
17
|
'blocks' => 'Blocks',
|
18
|
+
'role' => 'Role',
|
16
19
|
|
17
20
|
'page' => 'Page',
|
18
21
|
'pages' => 'Pages',
|
@@ -30,6 +33,7 @@ return [
|
|
30
33
|
'blocks' => 'Blocks',
|
31
34
|
'no_blocks' => 'No blocks',
|
32
35
|
'add_block' => 'Add a block',
|
36
|
+
'select_block' => 'Select a block...',
|
33
37
|
],
|
34
38
|
|
35
39
|
'filters' => [
|
@@ -6,6 +6,8 @@ return [
|
|
6
6
|
'url' => 'Adresse',
|
7
7
|
'published' => 'Publié',
|
8
8
|
'description_short' => 'Description courte',
|
9
|
+
'caption' => 'Libellé',
|
10
|
+
'credits' => 'Crédits',
|
9
11
|
'name' => 'Nom',
|
10
12
|
'email' => 'Courriel',
|
11
13
|
'password' => 'Mot de passe',
|
@@ -13,6 +15,7 @@ return [
|
|
13
15
|
'body' => 'Texte',
|
14
16
|
'parent' => 'Parent',
|
15
17
|
'blocks' => 'Blocs',
|
18
|
+
'role' => 'Rôle',
|
16
19
|
|
17
20
|
'page' => 'Page',
|
18
21
|
'pages' => 'Pages',
|
@@ -30,6 +33,7 @@ return [
|
|
30
33
|
'blocks' => 'Blocs',
|
31
34
|
'no_blocks' => 'Aucun bloc',
|
32
35
|
'add_block' => 'Ajouter un bloc',
|
36
|
+
'select_block' => 'Sélectionner un bloc...',
|
33
37
|
],
|
34
38
|
|
35
39
|
'filters' => [
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
2
|
+
import { useFormValue } from '@panneau/core/contexts';
|
3
|
+
import TextField from '@panneau/field-text';
|
4
|
+
import classNames from 'classnames';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import React from 'react';
|
7
|
+
import { generatePath } from 'react-router';
|
8
|
+
|
9
|
+
const propTypes = {
|
10
|
+
fieldLocale: PropTypes.string,
|
11
|
+
value: PropTypes.string,
|
12
|
+
className: PropTypes.string,
|
13
|
+
routes: PropTypes.objectOf(PropTypes.string).isRequired,
|
14
|
+
};
|
15
|
+
|
16
|
+
const defaultProps = {
|
17
|
+
fieldLocale: null,
|
18
|
+
value: null,
|
19
|
+
className: null,
|
20
|
+
};
|
21
|
+
|
22
|
+
const PageSlugField = ({ routes, fieldLocale, className, value, ...props }) => {
|
23
|
+
const page = useFormValue();
|
24
|
+
const { parent = null, handle = null } = page || {};
|
25
|
+
const { slug: parentSlug } = parent || {};
|
26
|
+
const { page: pageRoute = null, page_with_parent: pageWithParentRoute = null } = routes || {};
|
27
|
+
let url =
|
28
|
+
pageRoute !== null
|
29
|
+
? generatePath(pageRoute, {
|
30
|
+
page: 'REPLACE',
|
31
|
+
})
|
32
|
+
: null;
|
33
|
+
if (parent !== null && pageWithParentRoute !== null) {
|
34
|
+
url = generatePath(pageWithParentRoute, {
|
35
|
+
parent: parentSlug !== null ? parentSlug[fieldLocale] || null : null,
|
36
|
+
page: 'REPLACE',
|
37
|
+
});
|
38
|
+
}
|
39
|
+
if (handle === 'home') {
|
40
|
+
url = `/${fieldLocale}`;
|
41
|
+
}
|
42
|
+
|
43
|
+
return (
|
44
|
+
<TextField
|
45
|
+
prepend={
|
46
|
+
url !== null
|
47
|
+
? `${window.location.protocol}//${window.location.host}${url.replace(
|
48
|
+
'REPLACE',
|
49
|
+
'',
|
50
|
+
)}`
|
51
|
+
: null
|
52
|
+
}
|
53
|
+
className={classNames([
|
54
|
+
'flex-nowrap',
|
55
|
+
{
|
56
|
+
[className]: className !== null,
|
57
|
+
},
|
58
|
+
])}
|
59
|
+
value={handle === 'home' ? null : value}
|
60
|
+
{...props}
|
61
|
+
/>
|
62
|
+
);
|
63
|
+
};
|
64
|
+
|
65
|
+
PageSlugField.propTypes = propTypes;
|
66
|
+
PageSlugField.defaultProps = defaultProps;
|
67
|
+
|
68
|
+
export default PageSlugField;
|
@@ -289,19 +289,18 @@ module.exports = class LaravelProjectGenerator extends _generator.default {
|
|
289
289
|
if (this.options.mediatheque) {
|
290
290
|
this.composeWith('folklore:laravel-mediatheque', {
|
291
291
|
'project-name': this.options['project-name'],
|
292
|
-
'skip-install': true
|
292
|
+
'skip-install': true,
|
293
|
+
quiet: true
|
293
294
|
});
|
294
|
-
}
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
//
|
303
|
-
// }
|
304
|
-
// if (this.options.auth) {
|
295
|
+
}
|
296
|
+
|
297
|
+
if (this.options.panneau) {
|
298
|
+
this.composeWith('folklore:laravel-panneau', {
|
299
|
+
'project-name': this.options['project-name'],
|
300
|
+
'skip-install': skipInstall,
|
301
|
+
quiet: true
|
302
|
+
});
|
303
|
+
} // if (this.options.auth) {
|
305
304
|
// this.composeWith('folklore:laravel-auth', {
|
306
305
|
// 'project-name': this.options['project-name'],
|
307
306
|
// 'js-path': jsSrcPath,
|
@@ -368,6 +367,14 @@ module.exports = class LaravelProjectGenerator extends _generator.default {
|
|
368
367
|
'folklore/laravel-folklore': 'v1.x-dev',
|
369
368
|
'folklore/laravel-locale': 'v8.x-dev',
|
370
369
|
'folklore/laravel-image': 'v1.x-dev'
|
370
|
+
},
|
371
|
+
'require-dev': {
|
372
|
+
'laravel/telescope': '^4.0.0'
|
373
|
+
},
|
374
|
+
extra: {
|
375
|
+
laravel: {
|
376
|
+
'dont-discover': ['laravel/telescope', 'folklore/laravel-folklore']
|
377
|
+
}
|
371
378
|
}
|
372
379
|
});
|
373
380
|
},
|
@@ -490,6 +497,14 @@ module.exports = class LaravelProjectGenerator extends _generator.default {
|
|
490
497
|
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Image\\ServiceProvider']);
|
491
498
|
},
|
492
499
|
|
500
|
+
async telescope() {
|
501
|
+
if (this.options['skip-install']) {
|
502
|
+
return;
|
503
|
+
}
|
504
|
+
|
505
|
+
await this.spawnCommand('php', ['artisan', 'telescope:install']);
|
506
|
+
},
|
507
|
+
|
493
508
|
async valet() {
|
494
509
|
if (this.options['skip-install']) {
|
495
510
|
return;
|
package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/CreateNewUser.php
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Actions\Fortify;
|
4
|
+
|
5
|
+
use App\Contracts\Repositories\Users;
|
6
|
+
use Illuminate\Support\Facades\Hash;
|
7
|
+
use Illuminate\Support\Facades\Validator;
|
8
|
+
use Illuminate\Validation\Rule;
|
9
|
+
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
10
|
+
|
11
|
+
class CreateNewUser implements CreatesNewUsers
|
12
|
+
{
|
13
|
+
use PasswordValidationRules;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Validate and create a newly registered user.
|
17
|
+
*
|
18
|
+
* @param array $input
|
19
|
+
* @return \App\Models\User
|
20
|
+
*/
|
21
|
+
public function create(array $input)
|
22
|
+
{
|
23
|
+
Validator::make($input, [
|
24
|
+
'name' => ['required', 'string', 'max:255'],
|
25
|
+
'email' => [
|
26
|
+
'required',
|
27
|
+
'string',
|
28
|
+
'email',
|
29
|
+
'max:255',
|
30
|
+
Rule::unique(User::class),
|
31
|
+
],
|
32
|
+
'password' => $this->passwordRules(),
|
33
|
+
])->validate();
|
34
|
+
|
35
|
+
return resolve(Users::class)->create([
|
36
|
+
'name' => $input['name'],
|
37
|
+
'email' => $input['email'],
|
38
|
+
'password' => Hash::make($input['password']),
|
39
|
+
]);
|
40
|
+
}
|
41
|
+
}
|
package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/ResetUserPassword.php
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Actions\Fortify;
|
4
|
+
|
5
|
+
use Illuminate\Support\Facades\Hash;
|
6
|
+
use Illuminate\Support\Facades\Validator;
|
7
|
+
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
8
|
+
use App\Contracts\Repositories\Users;
|
9
|
+
|
10
|
+
class ResetUserPassword implements ResetsUserPasswords
|
11
|
+
{
|
12
|
+
use PasswordValidationRules;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Validate and reset the user's forgotten password.
|
16
|
+
*
|
17
|
+
* @param mixed $user
|
18
|
+
* @param array $input
|
19
|
+
* @return void
|
20
|
+
*/
|
21
|
+
public function reset($user, array $input)
|
22
|
+
{
|
23
|
+
Validator::make($input, [
|
24
|
+
'password' => $this->passwordRules(),
|
25
|
+
])->validate();
|
26
|
+
|
27
|
+
resolve(Users::class)->update($user->id(), [
|
28
|
+
'password' => Hash::make($input['password']),
|
29
|
+
]);
|
30
|
+
}
|
31
|
+
}
|
package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserPassword.php
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Actions\Fortify;
|
4
|
+
|
5
|
+
use Illuminate\Support\Facades\Hash;
|
6
|
+
use Illuminate\Support\Facades\Validator;
|
7
|
+
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
|
8
|
+
use App\Contracts\Repositories\Users;
|
9
|
+
|
10
|
+
class UpdateUserPassword implements UpdatesUserPasswords
|
11
|
+
{
|
12
|
+
use PasswordValidationRules;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Validate and update the user's password.
|
16
|
+
*
|
17
|
+
* @param mixed $user
|
18
|
+
* @param array $input
|
19
|
+
* @return void
|
20
|
+
*/
|
21
|
+
public function update($user, array $input)
|
22
|
+
{
|
23
|
+
Validator::make($input, [
|
24
|
+
'current_password' => ['required', 'string', 'current_password:web'],
|
25
|
+
'password' => $this->passwordRules(),
|
26
|
+
], [
|
27
|
+
'current_password.current_password' => __('The provided password does not match your current password.'),
|
28
|
+
])->validateWithBag('updatePassword');
|
29
|
+
|
30
|
+
resolve(Users::class)->update($user->id(), [
|
31
|
+
'password' => Hash::make($input['password']),
|
32
|
+
]);
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Actions\Fortify;
|
4
|
+
|
5
|
+
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
6
|
+
use Illuminate\Support\Facades\Validator;
|
7
|
+
use Illuminate\Validation\Rule;
|
8
|
+
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
9
|
+
use App\Contracts\Repositories\Users;
|
10
|
+
|
11
|
+
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
12
|
+
{
|
13
|
+
/**
|
14
|
+
* Validate and update the given user's profile information.
|
15
|
+
*
|
16
|
+
* @param mixed $user
|
17
|
+
* @param array $input
|
18
|
+
* @return void
|
19
|
+
*/
|
20
|
+
public function update($user, array $input)
|
21
|
+
{
|
22
|
+
Validator::make($input, [
|
23
|
+
'name' => ['required', 'string', 'max:255'],
|
24
|
+
|
25
|
+
'email' => [
|
26
|
+
'required',
|
27
|
+
'string',
|
28
|
+
'email',
|
29
|
+
'max:255',
|
30
|
+
Rule::unique('users')->ignore($user->id()),
|
31
|
+
],
|
32
|
+
])->validateWithBag('updateProfileInformation');
|
33
|
+
|
34
|
+
if ($input['email'] !== $user->email() && $user instanceof MustVerifyEmail) {
|
35
|
+
$this->updateVerifiedUser($user, $input);
|
36
|
+
} else {
|
37
|
+
resolve(Users::class)->update($user->id(), [
|
38
|
+
'name' => $input['name'],
|
39
|
+
'email' => $input['email'],
|
40
|
+
]);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Update the given verified user's profile information.
|
46
|
+
*
|
47
|
+
* @param mixed $user
|
48
|
+
* @param array $input
|
49
|
+
* @return void
|
50
|
+
*/
|
51
|
+
protected function updateVerifiedUser($user, array $input)
|
52
|
+
{
|
53
|
+
$user = resolve(Users::class)->update($user->id(), [
|
54
|
+
'name' => $input['name'],
|
55
|
+
'email' => $input['email'],
|
56
|
+
'email_verified_at' => null,
|
57
|
+
]);
|
58
|
+
|
59
|
+
$user->sendEmailVerificationNotification();
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Contracts\Repositories;
|
4
|
+
|
5
|
+
use Folklore\Contracts\Repositories\Users as BaseUsers;
|
6
|
+
use App\Contracts\Resources\User as UserResource;
|
7
|
+
|
8
|
+
interface Users extends BaseUsers
|
9
|
+
{
|
10
|
+
public function findById(string $id): ?UserResource;
|
11
|
+
|
12
|
+
public function findByEmail(string $email): ?UserResource;
|
13
|
+
|
14
|
+
public function create($data): UserResource;
|
15
|
+
|
16
|
+
public function update(string $id, $data): ?UserResource;
|
17
|
+
}
|
@@ -13,36 +13,6 @@ class User extends BaseUser
|
|
13
13
|
{
|
14
14
|
use HasApiTokens, HasFactory;
|
15
15
|
|
16
|
-
/**
|
17
|
-
* The attributes that are mass assignable.
|
18
|
-
*
|
19
|
-
* @var array<int, string>
|
20
|
-
*/
|
21
|
-
protected $fillable = [
|
22
|
-
'name',
|
23
|
-
'email',
|
24
|
-
'password',
|
25
|
-
];
|
26
|
-
|
27
|
-
/**
|
28
|
-
* The attributes that should be hidden for serialization.
|
29
|
-
*
|
30
|
-
* @var array<int, string>
|
31
|
-
*/
|
32
|
-
protected $hidden = [
|
33
|
-
'password',
|
34
|
-
'remember_token',
|
35
|
-
];
|
36
|
-
|
37
|
-
/**
|
38
|
-
* The attributes that should be cast.
|
39
|
-
*
|
40
|
-
* @var array<string, string>
|
41
|
-
*/
|
42
|
-
protected $casts = [
|
43
|
-
'email_verified_at' => 'datetime',
|
44
|
-
];
|
45
|
-
|
46
16
|
public function toResource(): UserContract
|
47
17
|
{
|
48
18
|
return new UserResource($this);
|
package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php
CHANGED
@@ -6,9 +6,66 @@ use Illuminate\Support\ServiceProvider;
|
|
6
6
|
use Illuminate\Support\Facades\Schema;
|
7
7
|
use Illuminate\Http\Resources\Json\JsonResource;
|
8
8
|
use Illuminate\Http\Request;
|
9
|
+
use Illuminate\Support\Arr;
|
9
10
|
|
10
11
|
class AppServiceProvider extends ServiceProvider
|
11
12
|
{
|
13
|
+
/**
|
14
|
+
* Register any application services.
|
15
|
+
*
|
16
|
+
* @return void
|
17
|
+
*/
|
18
|
+
public function register()
|
19
|
+
{
|
20
|
+
$this->registerRepositories();<% if (options.mediatheque) { %>
|
21
|
+
$this->registerMediatheque();<% } %>
|
22
|
+
$this->registerTelescope();
|
23
|
+
}
|
24
|
+
|
25
|
+
protected function registerRepositories()
|
26
|
+
{
|
27
|
+
$this->app->bind(
|
28
|
+
\Folklore\Contracts\Repositories\Users::class,
|
29
|
+
\App\Repositories\Users::class
|
30
|
+
);
|
31
|
+
|
32
|
+
$this->app->bind(
|
33
|
+
\App\Contracts\Repositories\Users::class,
|
34
|
+
\App\Repositories\Users::class
|
35
|
+
);<% if (options.panneau) { %>
|
36
|
+
|
37
|
+
$this->app->bind(
|
38
|
+
\Folklore\Contracts\Repositories\Pages::class,
|
39
|
+
\App\Repositories\Pages::class
|
40
|
+
);
|
41
|
+
|
42
|
+
$this->app->bind(
|
43
|
+
\App\Contracts\Repositories\Pages::class,
|
44
|
+
\App\Repositories\Pages::class
|
45
|
+
);<% } %>
|
46
|
+
}<% if (options.mediatheque) { %>
|
47
|
+
|
48
|
+
protected function registerMediatheque()
|
49
|
+
{
|
50
|
+
$this->app->bind(
|
51
|
+
\Folklore\Mediatheque\Contracts\Models\Media::class,
|
52
|
+
\App\Models\Media::class
|
53
|
+
);
|
54
|
+
|
55
|
+
$this->app->bind(
|
56
|
+
\Folklore\Mediatheque\Contracts\Models\File::class,
|
57
|
+
\App\Models\MediaFile::class
|
58
|
+
);
|
59
|
+
}<% } %>
|
60
|
+
|
61
|
+
protected function registerTelescope()
|
62
|
+
{
|
63
|
+
if ($this->app->environment('local')) {
|
64
|
+
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
|
65
|
+
$this->app->register(TelescopeServiceProvider::class);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
12
69
|
/**
|
13
70
|
* Bootstrap any application services.
|
14
71
|
*
|
@@ -16,30 +73,48 @@ class AppServiceProvider extends ServiceProvider
|
|
16
73
|
*/
|
17
74
|
public function boot()
|
18
75
|
{
|
76
|
+
// Some defaults
|
19
77
|
Schema::defaultStringLength(191);
|
20
78
|
JsonResource::withoutWrapping();
|
21
79
|
|
80
|
+
$this->bootRequest();
|
81
|
+
|
82
|
+
$this->bootImage();
|
83
|
+
}
|
84
|
+
|
85
|
+
protected function bootRequest()
|
86
|
+
{
|
22
87
|
// Determine site from request
|
23
88
|
Request::macro('site', function () {
|
24
89
|
return null;
|
25
90
|
});
|
26
91
|
}
|
27
92
|
|
28
|
-
|
29
|
-
* Register any application services.
|
30
|
-
*
|
31
|
-
* @return void
|
32
|
-
*/
|
33
|
-
public function register()
|
34
|
-
{
|
35
|
-
$this->registerRepositories();
|
36
|
-
}
|
37
|
-
|
38
|
-
protected function registerRepositories()
|
93
|
+
protected function bootImage()
|
39
94
|
{
|
40
|
-
$
|
41
|
-
|
42
|
-
|
43
|
-
|
95
|
+
foreach (config('image.sizes') as $filter) {
|
96
|
+
$id = $filter['id'];
|
97
|
+
$data = Arr::except($filter, ['id']);
|
98
|
+
if (sizeof($data) === 0) {
|
99
|
+
continue;
|
100
|
+
}
|
101
|
+
$newFilter = [];
|
102
|
+
if (isset($filter['maxWidth'])) {
|
103
|
+
$newFilter['width'] = $filter['maxWidth'];
|
104
|
+
}
|
105
|
+
if (isset($filter['maxHeight'])) {
|
106
|
+
$newFilter['height'] = $filter['maxHeight'];
|
107
|
+
}
|
108
|
+
if (isset($filter['width'])) {
|
109
|
+
$newFilter['width'] = $filter['width'];
|
110
|
+
}
|
111
|
+
if (isset($filter['height'])) {
|
112
|
+
$newFilter['height'] = $filter['height'];
|
113
|
+
}
|
114
|
+
if (isset($filter['width']) && isset($filter['height'])) {
|
115
|
+
$newFilter['crop'] = true;
|
116
|
+
}
|
117
|
+
$this->app['image']->filter($id, $newFilter);
|
118
|
+
}
|
44
119
|
}
|
45
120
|
}
|
@@ -3,11 +3,12 @@
|
|
3
3
|
namespace App\Repositories;
|
4
4
|
|
5
5
|
use Folklore\Repositories\Users as BaseUsers;
|
6
|
+
use App\Contracts\Repositories\Users as UsersContract;
|
6
7
|
use Illuminate\Database\Eloquent\Model;
|
7
8
|
use App\Models\User as UserModel;
|
8
9
|
use App\Contracts\Resources\User as UserContract;
|
9
10
|
|
10
|
-
class Users extends BaseUsers
|
11
|
+
class Users extends BaseUsers implements UsersContract
|
11
12
|
{
|
12
13
|
protected function newModel(): Model
|
13
14
|
{
|
@@ -24,12 +25,12 @@ class Users extends BaseUsers
|
|
24
25
|
return parent::findByEmail($email);
|
25
26
|
}
|
26
27
|
|
27
|
-
public function create(
|
28
|
+
public function create($data): UserContract
|
28
29
|
{
|
29
30
|
return parent::create($data);
|
30
31
|
}
|
31
32
|
|
32
|
-
public function update(string $id,
|
33
|
+
public function update(string $id, $data): ?UserContract
|
33
34
|
{
|
34
35
|
return parent::update($id, $data);
|
35
36
|
}
|
@@ -185,6 +185,7 @@ return [
|
|
185
185
|
/*
|
186
186
|
* Package Service Providers...
|
187
187
|
*/
|
188
|
+
Folklore\ServiceProvider::class,
|
188
189
|
|
189
190
|
/*
|
190
191
|
* Application Service Providers...
|
@@ -194,8 +195,8 @@ return [
|
|
194
195
|
// App\Providers\BroadcastServiceProvider::class,
|
195
196
|
App\Providers\EventServiceProvider::class,
|
196
197
|
App\Providers\RouteServiceProvider::class,
|
197
|
-
App\Providers\ViewServiceProvider::class
|
198
|
-
|
198
|
+
App\Providers\ViewServiceProvider::class,<% if (options.panneau) { %>
|
199
|
+
App\Panneau\PanneauServiceProvider::class,<% } %>
|
199
200
|
],
|
200
201
|
|
201
202
|
/*
|