Compare commits
447 commits
crud-secti
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad4218da01 | ||
|
|
376c5d3ab1 | ||
|
|
2e07125c62 | ||
|
|
ef17ae64e3 | ||
|
|
ea4848ede8 | ||
|
|
d5edac7cba | ||
|
|
74015163b7 | ||
|
|
c3e34984d6 | ||
|
|
10eede1282 | ||
|
|
d695c04d81 | ||
|
|
d7a81c939d | ||
|
|
f5b0f9fd66 | ||
|
|
9007631dc9 | ||
|
|
a646ecd84b | ||
|
|
455277669a | ||
|
|
3d86d1fa5f | ||
|
|
5f4a4b4ecb | ||
|
|
d38010dbdc | ||
|
|
10e8655192 | ||
|
|
2d20d563fe | ||
|
|
f42a2d7deb | ||
|
|
3948787e3d | ||
|
|
737d17652a | ||
|
|
898ce4d962 | ||
|
|
9f564c61ed | ||
|
|
31b7df079b | ||
|
|
d926451557 | ||
|
|
0f7da74206 | ||
|
|
ecc0a42044 | ||
|
|
88c38f7a6c | ||
|
|
25c7a9bef3 | ||
|
|
b62e258070 | ||
|
|
f415475878 | ||
|
|
02c4f35683 | ||
|
|
79a709e3f4 | ||
|
|
8b582376b0 | ||
|
|
3f1e5c765c | ||
|
|
11e82b9a1c | ||
|
|
d3af7c03be | ||
|
|
5fe32c9f73 | ||
|
|
6add647e12 | ||
|
|
e7330d27f8 | ||
|
|
70d9f09a0e | ||
|
|
0c9d7da807 | ||
|
|
93e4ed4cae | ||
|
|
e6c0fe65e2 | ||
|
|
a50ca7f133 | ||
|
|
249172d18e | ||
|
|
dd50c67623 | ||
|
|
9e7cfc2a76 | ||
|
|
6a5a679b62 | ||
|
|
7dbd427cb6 | ||
|
|
2f6948bf5e | ||
|
|
f1cd325a4d | ||
|
|
cc3a09f39e | ||
|
|
fde2cc3e02 | ||
|
|
3a4ec13798 | ||
|
|
ef44546aea | ||
|
|
82abf4518e | ||
|
|
77be8ce26d | ||
|
|
cfffe97e06 | ||
|
|
9358cf32b9 | ||
|
|
75dd8de967 | ||
|
|
5b74ca5e78 | ||
|
|
4b281f8abf | ||
|
|
906e81cda7 | ||
|
|
5e9e542d87 | ||
|
|
a3a01e5296 | ||
|
|
edd9028336 | ||
|
|
f52db3b50b | ||
|
|
5d77c5d158 | ||
|
|
17b35bb20c | ||
|
|
45b5fb538f | ||
|
|
ae7dd18bda | ||
|
|
20a6ed4ac0 | ||
|
|
45f0ac7434 | ||
|
|
139b61290c | ||
|
|
3990442d39 | ||
|
|
ed5807645d | ||
|
|
860cbe272b | ||
|
|
0a07237aa7 | ||
|
|
9bb18429bb | ||
|
|
a9201415c9 | ||
|
|
c8ac89ca3a | ||
|
|
f3a4e2fc80 | ||
|
|
67e4885fd5 | ||
|
|
7b45466952 | ||
|
|
27d5d7b2b9 | ||
|
|
e8820543b8 | ||
|
|
34ddb7f4fa | ||
|
|
4035ce0002 | ||
|
|
a6863b507d | ||
|
|
749628540b | ||
|
|
074320d79c | ||
|
|
91dd2c81e3 | ||
|
|
93a5181b4d | ||
|
|
8e1ca12c9f | ||
|
|
bbbd9ce526 | ||
|
|
fbd5829aef | ||
|
|
2f3310220c | ||
|
|
a169b2c2e1 | ||
|
|
5f9a4496eb | ||
|
|
33810d36fc | ||
|
|
6e6757cd77 | ||
|
|
0fabceb1f3 | ||
|
|
af3d961dea | ||
|
|
03fdf04437 | ||
|
|
2e23543a0d | ||
|
|
6f3e459a65 | ||
|
|
c00caa1dc3 | ||
|
|
7f5e6173c9 | ||
|
|
7ff95fdb5f | ||
|
|
3a3415c61e | ||
|
|
3a064fd47f | ||
|
|
a344a89466 | ||
|
|
a0d3c95305 | ||
|
|
4d5bf6a135 | ||
|
|
ddf876ea0b | ||
|
|
fad0d13c8f | ||
|
|
aceee89f39 | ||
|
|
abb326134f | ||
|
|
7ca3e0333b | ||
|
|
b834747955 | ||
|
|
7da3f98667 | ||
|
|
cacee5c21d | ||
|
|
773c59aafc | ||
|
|
efc250ba16 | ||
|
|
ee912e4163 | ||
|
|
9da5674696 | ||
|
|
cab82c9ecd | ||
|
|
4f02895ac8 | ||
|
|
8cfc757995 | ||
|
|
bd6f7e5358 | ||
|
|
6f0348a6ff | ||
|
|
a424fc724d | ||
|
|
1bedaaee6e | ||
|
|
f5ca726c66 | ||
|
|
19e2fc4f6a | ||
|
|
d70dbce0f6 | ||
|
|
08bb5c9180 | ||
|
|
63208d568a | ||
|
|
754ed2c734 | ||
|
|
ad0e6802d3 | ||
|
|
e025969e93 | ||
|
|
f09df54d90 | ||
|
|
33a0206ade | ||
|
|
d59d7a9781 | ||
|
|
53a285ec9f | ||
|
|
2ec44a2584 | ||
|
|
43d6b4d652 | ||
|
|
58ca2372aa | ||
|
|
0929272440 | ||
|
|
3904db884a | ||
|
|
abd47e2aed | ||
|
|
33f0594bc6 | ||
|
|
d4ef6e4b44 | ||
|
|
156a9b8fa7 | ||
|
|
7cb3c668d9 | ||
|
|
dd80e4c8d5 | ||
|
|
24cbab746b | ||
|
|
ad0e0fc436 | ||
|
|
0843331f01 | ||
|
|
c05d1c3e0a | ||
|
|
9959bb4a24 | ||
|
|
993dc6ed88 | ||
|
|
92800c4282 | ||
|
|
fcc49f0189 | ||
|
|
ac98b01925 | ||
|
|
cadc478ea9 | ||
|
|
6a5fdba063 | ||
|
|
57c22e5ea5 | ||
|
|
bdf748c1b7 | ||
|
|
36c877d6be | ||
|
|
b13b34e860 | ||
|
|
16d3c0e552 | ||
|
|
4ec3428928 | ||
|
|
f0e3f5df91 | ||
|
|
6466cb7f5f | ||
|
|
fccfc1734e | ||
|
|
b85ac4fe9d | ||
|
|
242ca9bc35 | ||
|
|
da66e2322c | ||
|
|
cda965c645 | ||
|
|
65d170cd90 | ||
|
|
6e7203306d | ||
|
|
8d4b48c03e | ||
|
|
1e6cc6166c | ||
|
|
60607f8931 | ||
|
|
546f955171 | ||
|
|
0a05fe76b5 | ||
|
|
241b8d6a42 | ||
|
|
b2f2dc77d5 | ||
|
|
f090b12405 | ||
|
|
e0a9133f96 | ||
|
|
852861b838 | ||
|
|
cdf0a866dc | ||
|
|
4491ddaff5 | ||
|
|
21ef4b1e1f | ||
|
|
a525a36c4b | ||
|
|
1c3aecf556 | ||
|
|
2229e96a57 | ||
|
|
45277f1c0b | ||
|
|
33773f90cc | ||
|
|
a90393391f | ||
|
|
08f99d0fa5 | ||
|
|
6b089ce172 | ||
|
|
b203269c5e | ||
|
|
7111f9adee | ||
|
|
f5b8deee6a | ||
|
|
e89c6224ff | ||
|
|
51051adc56 | ||
|
|
a43edd883d | ||
|
|
546e2d102e | ||
|
|
5defc78270 | ||
|
|
68193ec8c8 | ||
|
|
2d9fd8eb06 | ||
|
|
3352142d54 | ||
|
|
bffbfdabc6 | ||
|
|
fc797ccc4f | ||
|
|
551253516d | ||
|
|
0c99ea0af0 | ||
|
|
09914575e7 | ||
|
|
6615233ac7 | ||
|
|
758648fcc8 | ||
|
|
57cc782078 | ||
|
|
cdc915c9f9 | ||
|
|
6904bf16a6 | ||
|
|
4e285d85e3 | ||
|
|
348cb1638d | ||
|
|
8ddf9c66a3 | ||
|
|
2f498b01b4 | ||
|
|
e03737544a | ||
|
|
8750cc935b | ||
|
|
a7d9d2d63a | ||
|
|
64e481b63b | ||
|
|
e064d2436f | ||
|
|
d992ac4484 | ||
|
|
fcae5436fa | ||
|
|
477de0bc1d | ||
|
|
d1855d8771 | ||
|
|
15c973798f | ||
|
|
1be7e6df68 | ||
|
|
9065e3295a | ||
|
|
d2a61fb619 | ||
|
|
6358ddd78d | ||
|
|
e242ab8ac4 | ||
|
|
237c48f91e | ||
|
|
2f1ba3617f | ||
|
|
374f84c0d3 | ||
|
|
5ddbae8889 | ||
|
|
8fad33010d | ||
|
|
ef0501ba6e | ||
|
|
aa8aa882a7 | ||
|
|
c4abbf28e6 | ||
|
|
ddea9f65c2 | ||
|
|
e7035b8b40 | ||
|
|
57378b1a17 | ||
|
|
6b6f5f40fc | ||
|
|
f48e658f6b | ||
|
|
ff27b87203 | ||
|
|
b2204f5d13 | ||
|
|
c1c355e80c | ||
|
|
df3a175de2 | ||
|
|
43ab9b75e9 | ||
|
|
d890f92741 | ||
|
|
dfbd8d86ee | ||
|
|
7c0a2fca0c | ||
|
|
355733d5b8 | ||
|
|
a072b82904 | ||
|
|
88e62ddc17 | ||
|
|
5b7c943e6c | ||
|
|
25f4e0a344 | ||
|
|
3e3161cfa6 | ||
|
|
c1d04e49e8 | ||
|
|
158f933fae | ||
|
|
a2c6fc9771 | ||
|
|
83062ecec1 | ||
|
|
17690e0bf8 | ||
|
|
7e76ad9b02 | ||
|
|
30aad4c124 | ||
|
|
918d5a3dc8 | ||
|
|
f46da1e93f | ||
|
|
a4166969e0 | ||
|
|
2348aa5af7 | ||
|
|
114b98526f | ||
|
|
1952056b6d | ||
|
|
3e4ea23684 | ||
|
|
c53a940dc0 | ||
|
|
a1ef12c19f | ||
|
|
48c0ddb3f0 | ||
|
|
2cde39df0c | ||
|
|
a8e5ffe776 | ||
|
|
1a3315361c | ||
|
|
5da558a90e | ||
|
|
2e54c8a721 | ||
|
|
31ae3ff676 | ||
|
|
b00c974413 | ||
|
|
a41a2bd141 | ||
|
|
c6a85ba9ca | ||
|
|
8948aa796e | ||
|
|
02b7ea8f2e | ||
|
|
09ee2a5b91 | ||
|
|
4201168131 | ||
|
|
9299b53b1b | ||
|
|
1b3b07f4ef | ||
|
|
d611575adb | ||
|
|
7cfcbc200a | ||
|
|
5465854892 | ||
|
|
07f8af2e90 | ||
|
|
aa44664e37 | ||
|
|
e04c789a80 | ||
|
|
7c33190d62 | ||
|
|
c1472394bb | ||
|
|
aee1df06b5 | ||
|
|
3a1a7e5fce | ||
|
|
5f83813f34 | ||
|
|
dd9330841e | ||
|
|
25e885ec08 | ||
|
|
a21a45d98f | ||
|
|
977260c240 | ||
|
|
61fc2b4c96 | ||
|
|
173e2009c5 | ||
|
|
251d235930 | ||
|
|
4fcb5e7f4d | ||
|
|
324abfc92b | ||
|
|
73a27598e1 | ||
|
|
bc18f01f3e | ||
|
|
1538e17a6b | ||
|
|
77a1ba39e4 | ||
|
|
f8fe9c861c | ||
|
|
40fb5e692d | ||
|
|
2a9996eb22 | ||
|
|
fdbba824b6 | ||
|
|
1cf26fed67 | ||
|
|
66842b4220 | ||
|
|
2fc3a7c432 | ||
|
|
5ca427c691 | ||
|
|
ded761155c | ||
|
|
ae2325a2b1 | ||
|
|
5e4b413067 | ||
|
|
a03d694071 | ||
|
|
30ad03d92b | ||
|
|
e9618e79bb | ||
|
|
e095b8f186 | ||
|
|
6cbb4671dd | ||
|
|
d71d72af86 | ||
|
|
fc3f0d1fae | ||
|
|
06c5b83b28 | ||
|
|
afad70924b | ||
|
|
6cd2a87655 | ||
|
|
f55b01b02c | ||
|
|
c9364bcd08 | ||
|
|
1819fdb285 | ||
|
|
5f30d81ff2 | ||
|
|
8c664f426e | ||
|
|
27e2336023 | ||
|
|
39612326fe | ||
|
|
a7d3df2dde | ||
|
|
0035e56ea0 | ||
|
|
d30cc71978 | ||
|
|
54317c0e58 | ||
|
|
14097c0acf | ||
|
|
844e9d73e9 | ||
|
|
b49654e567 | ||
|
|
5b21cce220 | ||
|
|
921d3e750e | ||
|
|
0229a6dac5 | ||
|
|
8f46a19771 | ||
|
|
eae23a7a55 | ||
|
|
16f59a4a44 | ||
|
|
a511395990 | ||
|
|
1ec8692915 | ||
|
|
ad399ba4fc | ||
|
|
5cb166e3bd | ||
|
|
bdf0766d86 | ||
|
|
7805a088d4 | ||
|
|
04777c331e | ||
|
|
10d066ad91 | ||
|
|
8611f696d1 | ||
|
|
4ab0de37b5 | ||
|
|
7e5631fade | ||
|
|
1eaf6c1da7 | ||
|
|
5bfc256b30 | ||
|
|
437c23b77d | ||
|
|
6707463e2d | ||
|
|
1d55d19fb9 | ||
|
|
dd7639c803 | ||
|
|
4979a23745 | ||
|
|
84582bb756 | ||
|
|
6eb04d2b6e | ||
|
|
754744e46b | ||
|
|
a462757fd8 | ||
|
|
3c80de9e4a | ||
|
|
886a90f4cc | ||
|
|
5876f7b885 | ||
|
|
c1bb78fc1c | ||
|
|
bb4c6d5f70 | ||
|
|
0b93f0b0b3 | ||
|
|
c2bf61fa58 | ||
|
|
5fe0eecbce | ||
|
|
c358bd37f7 | ||
|
|
5aff3c64ed | ||
|
|
b23524f292 | ||
|
|
b16eb6ceb7 | ||
|
|
a00facf25d | ||
|
|
5e6525448b | ||
|
|
4957d71936 | ||
|
|
730aa399e3 | ||
|
|
8fd9720fc8 | ||
|
|
ffdff8525d | ||
|
|
0615ff51c2 | ||
|
|
73cb532806 | ||
|
|
ff2bcc700f | ||
|
|
d476500fdb | ||
|
|
0f29978308 | ||
|
|
8c63ea2c4d | ||
|
|
962ff582c6 | ||
|
|
8b36c58d88 | ||
|
|
1d5a1e9a15 | ||
|
|
64dbccde06 | ||
|
|
e8dcdf40a7 | ||
|
|
3465ab791f | ||
|
|
d17de9fd41 | ||
|
|
9ca475c613 | ||
|
|
9f920b714c | ||
|
|
110fe8c2e3 | ||
|
|
227eb90737 | ||
|
|
55c68965d3 | ||
|
|
f3d79cf7a9 | ||
|
|
74cebd7eb3 | ||
|
|
93dc9903c5 | ||
|
|
afd5b4b47e | ||
|
|
1e427028e8 | ||
|
|
1ea003521c | ||
|
|
4be4dddda0 | ||
|
|
bcb1fd1566 | ||
|
|
984358cc55 | ||
|
|
fa84ac6db8 | ||
|
|
d3f83d2ccc | ||
|
|
727fdfa2e3 | ||
|
|
2214a4294a | ||
|
|
b315da9d63 | ||
|
|
67fde446dc | ||
|
|
d9c3a02fe4 | ||
|
|
cab0866422 | ||
|
|
50b4ecfb43 | ||
|
|
de6beb5cfe |
566 changed files with 39681 additions and 10475 deletions
|
|
@ -1,5 +1,13 @@
|
|||
# Browsers that we support
|
||||
|
||||
last 3 version
|
||||
> 0.3%
|
||||
not dead # no browsers without security updates
|
||||
# https://github.com/browserslist/browserslist#readme
|
||||
|
||||
>= 0.5%
|
||||
last 2 major versions
|
||||
not dead
|
||||
Chrome >= 60
|
||||
Firefox >= 60
|
||||
Firefox ESR
|
||||
iOS >= 12
|
||||
Safari >= 12
|
||||
not Explorer <= 11
|
||||
|
|
|
|||
27
.env.example
27
.env.example
|
|
@ -60,3 +60,30 @@ VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|||
|
||||
# Sentry
|
||||
SENTRY_LARAVEL_DSN=
|
||||
|
||||
# Matomo
|
||||
MATOMO_SITE_ID=id
|
||||
|
||||
# MAILS
|
||||
MAIL_CONTACT_REMARK="equipe.web@ldc.fr"
|
||||
MAIL_CONTACT_SPONSORING="equipe.web@ldc.fr"
|
||||
MAIL_CONTACT_SERVICE="equipe.web@ldc.fr"
|
||||
MAIL_CONTACT_OTHER="equipe.web@ldc.fr"
|
||||
|
||||
# GOOGLE
|
||||
# - RECAPTCHA
|
||||
GOOGLE_RECAPTCHA_PUBLIC=
|
||||
GOOGLE_RECAPTCHA_PRIVATE=
|
||||
GOOGLE_RECAPTCHA_VERSION=
|
||||
|
||||
|
||||
SAML2_DEFAULT_TENANT_UUID=
|
||||
SAML2_SP_CERT_x509=
|
||||
SAML2_SP_CERT_PRIVATEKEY=
|
||||
SAML2_CONTACT_TECHNICAL_EMAIL=
|
||||
|
||||
# UWIL ADMIN SECURE
|
||||
# - LIST SEPARATED WITH ',' (Required)
|
||||
UWIL_ADMIN_SECURE_CIDR_LIST=""
|
||||
# - LIST SEPARATED WITH ',' (Optional)
|
||||
UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST=""
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@
|
|||
"vue/script-indent": ["error", 2, { "baseIndent": 0, "switchCase": 1 }],
|
||||
"vue/one-component-per-file": "off"
|
||||
},
|
||||
"globals": {
|
||||
"require": true
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"node": {
|
||||
|
|
|
|||
17
.gitignore
vendored
17
.gitignore
vendored
|
|
@ -8,6 +8,7 @@
|
|||
/.phpunit.cache
|
||||
/.vscode
|
||||
/node_modules
|
||||
/bootstrap
|
||||
/public/build
|
||||
/public/cache
|
||||
/public/hot
|
||||
|
|
@ -22,3 +23,19 @@ Homestead.yaml
|
|||
npm-debug.log
|
||||
yarn-error.log
|
||||
.npmrc
|
||||
.zshrc
|
||||
.npm/
|
||||
.composer/
|
||||
|
||||
# Ignore public favicon
|
||||
/public/android-chrome-192x192.png
|
||||
/public/android-chrome-512x512.png
|
||||
/public/apple-touch-icon.png
|
||||
/public/browserconfig.xml
|
||||
/public/browserconfig.xml
|
||||
/public/favicon-16x16.png
|
||||
/public/favicon-32x32.png
|
||||
/public/favicon.ico
|
||||
/public/mstile-150x150.png
|
||||
/public/safari-pinned-tab.svg
|
||||
/public/site.webmanifest
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
include:
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'lint/lint.yml'
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'security/security.yml'
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'build/build.yml'
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'test/test.yml'
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'deploy/deploy.yml'
|
||||
|
||||
- project: "ldc-web/shared-ci"
|
||||
ref: "main"
|
||||
file: "lint/lint.yml"
|
||||
- project: "ldc-web/shared-ci"
|
||||
ref: "main"
|
||||
file: "security/security.yml"
|
||||
- project: "ldc-web/shared-ci"
|
||||
ref: "main"
|
||||
file: "build/docker-multistage.yml"
|
||||
- project: "ldc-web/shared-ci"
|
||||
ref: "main"
|
||||
file: "test/test.yml"
|
||||
- project: "ldc-web/shared-ci"
|
||||
ref: "main"
|
||||
file: "deploy/deploy.yml"
|
||||
|
||||
stages:
|
||||
- lint
|
||||
- security
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
- lint
|
||||
- security
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
|
|
|||
2
.husky/commit-msg
Normal file
2
.husky/commit-msg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
npx commitlint --config node_modules/@uwil/husky-config/commitlint.config.js --edit $1
|
||||
21
.vscode/extensions.json
vendored
21
.vscode/extensions.json
vendored
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"esbenp.prettier-vscode",
|
||||
"rvest.vs-code-prettier-eslint",
|
||||
"onecentlin.laravel-extension-pack",
|
||||
"johnpapa.vscode-peacock",
|
||||
"xdebug.php-debug",
|
||||
"neilbrayfield.php-docblocker",
|
||||
"bmewburn.vscode-intelephense-client",
|
||||
"valeryanm.vscode-phpsab",
|
||||
"shevaua.phpcs",
|
||||
"syler.sass-indented",
|
||||
"sibiraj-s.vscode-scss-formatter",
|
||||
"mrmlnc.vscode-scss",
|
||||
"stylelint.vscode-stylelint",
|
||||
"vue.vscode-typescript-vue-plugin",
|
||||
"wscats.vue",
|
||||
"vue.volar",
|
||||
"misterj.vue-volar-extention-pack"
|
||||
]
|
||||
}
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
|
@ -20,7 +20,7 @@
|
|||
"commandCenter.border": "#e7e7e799"
|
||||
},
|
||||
"peacock.remoteColor": "#103251",
|
||||
"intelephense.environment.phpVersion": "8.2.0",
|
||||
"intelephense.environment.phpVersion": "8.3.0",
|
||||
"intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true,
|
||||
"intelephense.phpdoc.useFullyQualifiedNames": true
|
||||
}
|
||||
|
|
|
|||
46
Dockerfile
Normal file
46
Dockerfile
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
FROM composer:2.8 AS vendor
|
||||
|
||||
ARG GITLAB_USER
|
||||
ARG GITLAB_PASSWORD
|
||||
|
||||
COPY database/ database/
|
||||
|
||||
COPY composer.json composer.json
|
||||
COPY composer.lock composer.lock
|
||||
|
||||
RUN composer config gitlab-token.lab.s-web.fr ${GITLAB_USER} ${GITLAB_PASSWORD}
|
||||
RUN composer install \
|
||||
--ignore-platform-reqs \
|
||||
--no-interaction \
|
||||
--no-plugins \
|
||||
--no-scripts \
|
||||
--no-dev \
|
||||
--prefer-dist
|
||||
|
||||
FROM node:20.18 AS frontend
|
||||
|
||||
ARG GITLAB_PASSWORD
|
||||
|
||||
RUN mkdir -p /app/public/build
|
||||
|
||||
COPY package*.json tsconfig.json vite.config.ts .eslintrc.json .stylelintrc.json /app/
|
||||
COPY resources/ /app/resources/
|
||||
WORKDIR /app
|
||||
RUN npm config set @ldc-web:registry https://lab.s-web.fr/api/v4/packages/npm/
|
||||
RUN npm config set -- '//lab.s-web.fr/api/v4/packages/npm/:_authToken' "${GITLAB_PASSWORD}"
|
||||
RUN npm config set @uwil:registry https://lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/
|
||||
RUN npm config set -- '//lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/:_authToken' "${GITLAB_PASSWORD}"
|
||||
RUN npm ci --no-audit --no-fund --loglevel=error && npm run prod
|
||||
|
||||
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
|
||||
|
||||
ARG USER=www-data
|
||||
|
||||
COPY --chown=${USER}:${USER} . /app/srcs
|
||||
COPY --from=vendor --chown=${USER}:${USER} /app/vendor/ /app/srcs/vendor/
|
||||
COPY --from=frontend --chown=${USER}:${USER} /app/public/build/ /app/srcs/public/build/
|
||||
COPY --chown=${USER}:${USER} ./resources/favicon /app/srcs/public
|
||||
|
||||
USER root
|
||||
RUN chmod -R 755 /app/srcs/storage
|
||||
USER ${USER}
|
||||
46
app/Console/Commands/CleanOldActivities.php
Normal file
46
app/Console/Commands/CleanOldActivities.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\CleanOldActivities as CleanOldActivitiesJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CleanOldActivities extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:activity-logs:clean {--force : Delete all activity logs regardless of date.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clean all logs older than one year. Use --force to delete all logs.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$messageTitle = "<comment>activity logs</comment>";
|
||||
$this->components->info("Cleaning {$messageTitle}...");
|
||||
|
||||
$force = $this->option('force');
|
||||
|
||||
if ($force && !$this->confirm('Are you sure you want to delete all activity logs ? This cannot be undone.')) {
|
||||
$this->components->error("Clean of {$messageTitle} aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
(new CleanOldActivitiesJob(force: $force))->handle();
|
||||
|
||||
$messageContent = $force ? "All {$messageTitle} deleted" : "Old {$messageTitle} cleaned";
|
||||
$this->components->success($messageContent);
|
||||
}
|
||||
}
|
||||
117
app/Console/Commands/MakeUser.php
Normal file
117
app/Console/Commands/MakeUser.php
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Artisan command to create a backend admin user.
|
||||
*/
|
||||
class MakeUser extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:make:user';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new backend admin user.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->components->info("Creating a new <comment>backend user</comment>...");
|
||||
|
||||
$firstName = $this->askValid(
|
||||
'first_name',
|
||||
'First name',
|
||||
'Admin',
|
||||
['required', 'min:3', 'max:255']
|
||||
);
|
||||
$lastName = $this->askValid(
|
||||
'last_name',
|
||||
'Last name',
|
||||
'Saïtama',
|
||||
['required', 'min:3', 'max:255']
|
||||
);
|
||||
$email = $this->askValid(
|
||||
'email',
|
||||
'Email',
|
||||
'equipe.web@ldc.fr',
|
||||
['required', 'unique:users,email', 'email:rfc,strict,dns,spoof,filter']
|
||||
);
|
||||
$role = $this->askRole();
|
||||
|
||||
$user = new User([
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'email' => $email,
|
||||
'role' => $role,
|
||||
'published' => true,
|
||||
'published_at' => Carbon::now(),
|
||||
]);
|
||||
$user->saveOrFail();
|
||||
|
||||
$this->components->success("User <comment>{$firstName} {$lastName}</comment> created successfully.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for a value and validate it, re-prompting on failure.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $label
|
||||
* @param string $default
|
||||
* @param array<int, string> $rules
|
||||
* @return string
|
||||
*/
|
||||
private function askValid(string $field, string $label, string $default, array $rules): string
|
||||
{
|
||||
try {
|
||||
$value = $this->ask(sprintf("Type the wanted user %s", $label), $default);
|
||||
$validator = Validator::make([$field => $value], [$field => $rules]);
|
||||
$validator->validate();
|
||||
return $value;
|
||||
} catch (ValidationException $e) {
|
||||
$this->components->error(
|
||||
collect($e->errors())->flatten()->first()
|
||||
);
|
||||
return $this->askValid($field, $label, $default, $rules);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for a role and return the corresponding RoleEnum.
|
||||
*
|
||||
* @return \App\Enums\Users\RoleEnum
|
||||
*/
|
||||
private function askRole(): \App\Enums\Users\RoleEnum
|
||||
{
|
||||
$options = collect([
|
||||
RoleEnum::conceptor,
|
||||
RoleEnum::admin,
|
||||
RoleEnum::visitor,
|
||||
])->mapWithKeys(fn(RoleEnum $role) => [
|
||||
Str::ucFirst($role->label()) => $role
|
||||
]);
|
||||
|
||||
/** @var string $choice */
|
||||
$choice = $this->choice('Role', $options->keys()->all(), Str::ucFirst(RoleEnum::visitor->label()));
|
||||
return $options->get($choice);
|
||||
}
|
||||
}
|
||||
34
app/Console/Commands/UpdatePlanificatedStatus.php
Normal file
34
app/Console/Commands/UpdatePlanificatedStatus.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\UpdatePlanificatedStatus as UpdatePlanificatedStatusJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdatePlanificatedStatus extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:update-planificated-status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update models planificated status.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
(new UpdatePlanificatedStatusJob())->handle();
|
||||
$this->info('Models\' planificated status updated 👌');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,231 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UserCreate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'uwil:user:create';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a backend admin user';
|
||||
|
||||
/**
|
||||
* The first name of the new user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $first_name;
|
||||
|
||||
/**
|
||||
* The last name of the new user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $last_name;
|
||||
|
||||
/**
|
||||
* The email of the new user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* The password of the new user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* The role of the new user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $role;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->first_name = null;
|
||||
$this->addFirstName();
|
||||
|
||||
$this->last_name = null;
|
||||
$this->addLastName();
|
||||
|
||||
$this->email = null;
|
||||
$this->addEmail();
|
||||
|
||||
$this->password = null;
|
||||
$this->addPassword();
|
||||
|
||||
$this->role = null;
|
||||
$this->addRole();
|
||||
|
||||
$user = new User([
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
'role' => $this->role,
|
||||
'published' => true,
|
||||
'published_at' => Carbon::now(),
|
||||
]);
|
||||
$user->saveOrFail();
|
||||
|
||||
$this->info('User created 👌');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a first name to the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addFirstName(): void
|
||||
{
|
||||
while (is_null($this->first_name)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user first name', 'Admin');
|
||||
$validator = Validator::make(['first_name' => $tmp], [
|
||||
'first_name' => 'required|min:3|max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$this->first_name = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid first name %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
} //end try
|
||||
}; //end while
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a last name to the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addLastName(): void
|
||||
{
|
||||
while (is_null($this->last_name)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user last name', 'Saïtama');
|
||||
$validator = Validator::make(['last_name' => $tmp], [
|
||||
'last_name' => 'required|min:3|max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$this->last_name = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid last_name %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
} //end try
|
||||
}; //end while
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an email to the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addEmail(): void
|
||||
{
|
||||
while (is_null($this->email)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
|
||||
$validator = Validator::make(['email' => $tmp], [
|
||||
'email' => 'required|unique:users,email|email:rfc,dns'
|
||||
]);
|
||||
$validator->validate();
|
||||
$this->email = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid email %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
} //end try
|
||||
}; //end while
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a password to the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addPassword(): void
|
||||
{
|
||||
while (
|
||||
($this->password = $this->secret(
|
||||
(!\is_null($this->password) ? 'Failed to confirm, ' : '') . 'Type the wanted user password'
|
||||
)) !== $this->secret('Confirm the password')
|
||||
) {
|
||||
continue;
|
||||
}; //end while
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a role to the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addRole(): void
|
||||
{
|
||||
while (is_null($this->role)) {
|
||||
try {
|
||||
$tmp = $this->choice(
|
||||
'Select his role',
|
||||
[RoleEnum::conceptor->name, RoleEnum::admin->name, RoleEnum::visitor->name],
|
||||
RoleEnum::visitor->name,
|
||||
$maxAttempts = null,
|
||||
$allowMultipleSelections = false
|
||||
);
|
||||
if ($tmp === RoleEnum::conceptor->name) {
|
||||
$tmp = RoleEnum::conceptor;
|
||||
}
|
||||
if ($tmp === RoleEnum::admin->name) {
|
||||
$tmp = RoleEnum::admin;
|
||||
}
|
||||
if ($tmp === RoleEnum::visitor->name) {
|
||||
$tmp = RoleEnum::visitor;
|
||||
}
|
||||
$validator = Validator::make(['role' => $tmp], [
|
||||
'role' => 'required'
|
||||
]);
|
||||
$validator->validate();
|
||||
$this->role = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please choose from the selection',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
} //end try
|
||||
}; //end while
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Jobs\CleanOldActivities;
|
||||
use App\Jobs\UpdatePlanificatedStatus;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
|
|
@ -13,8 +15,10 @@ class Kernel extends ConsoleKernel
|
|||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->job(CleanOldActivities::class)->daily();
|
||||
$schedule->job(UpdatePlanificatedStatus::class)->everyFiveMinutes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -22,7 +26,7 @@ class Kernel extends ConsoleKernel
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ enum ActivityLogsEventEnum: int
|
|||
case deleted = 4;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::created->name => 'Création',
|
||||
|
|
@ -25,7 +27,7 @@ enum ActivityLogsEventEnum: int
|
|||
|
||||
|
||||
/**
|
||||
* Custom added classes definition
|
||||
* Custom added classes definition.
|
||||
*/
|
||||
private const BOOTSTRAPCLASS = [
|
||||
self::created->name => 'success',
|
||||
|
|
@ -35,7 +37,7 @@ enum ActivityLogsEventEnum: int
|
|||
];
|
||||
|
||||
/**
|
||||
* Get Class
|
||||
* Get Class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,15 +9,19 @@ enum CkEditorConfigName: int
|
|||
use BaseEnum;
|
||||
|
||||
case minimal = 1;
|
||||
case base = 2;
|
||||
case basic = 2;
|
||||
case advanced = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::minimal->name => 'minimal',
|
||||
self::base->name => 'base',
|
||||
self::basic->name => 'basic',
|
||||
self::advanced->name => 'advanced',
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,8 @@ enum Country: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::afghanistan->name => 'Afghanistan',
|
||||
|
|
@ -355,9 +357,9 @@ enum Country: int
|
|||
self::guatemala->name => 'Guatemala',
|
||||
self::guernsey->name => 'Guernsey',
|
||||
self::guinea->name => 'Guinea',
|
||||
self::guineaBissau->name => 'GuineaBissau',
|
||||
self::guineaBissau->name => 'Guinea Bissau',
|
||||
self::guyana->name => 'Guyana',
|
||||
self::haiti->name => 'Haiti',
|
||||
self::haiti->name => 'Haïti',
|
||||
self::heardIslandAndMcdonaldIslands->name => 'Heard Island and McDonald Islands',
|
||||
self::holySeeVaticanCityState->name => 'Holy See (Vatican City State)',
|
||||
self::honduras->name => 'Honduras',
|
||||
|
|
@ -516,7 +518,7 @@ enum Country: int
|
|||
/**
|
||||
* Get Valid Shipping Countries
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, self>
|
||||
*/
|
||||
public static function validShippingCountries(): array
|
||||
{
|
||||
|
|
@ -542,7 +544,7 @@ enum Country: int
|
|||
/**
|
||||
* Get Valid Shipping Countries
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, self>
|
||||
*/
|
||||
public static function validBillingCountries(): array
|
||||
{
|
||||
|
|
@ -566,7 +568,7 @@ enum Country: int
|
|||
/**
|
||||
* Get Alpha 2 ISO code of valid shipping countries
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function getValidShippingCountriesIsoAplha2Codes(): array
|
||||
{
|
||||
|
|
@ -576,7 +578,7 @@ enum Country: int
|
|||
/**
|
||||
* Get Alpha 2 ISO code of valid billing countries
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function getValidBillingCountriesIsoAplha2Codes(): array
|
||||
{
|
||||
|
|
@ -584,21 +586,258 @@ enum Country: int
|
|||
}
|
||||
|
||||
/**
|
||||
* Custom added ISOCODES definition
|
||||
* Custom added ISOCODES definition.
|
||||
*/
|
||||
private const ISOCODES = [
|
||||
self::france->name => 'FR',
|
||||
self::guadeloupe->name => 'GP',
|
||||
self::martinique->name => 'MQ',
|
||||
self::frenchGuiana->name => 'GF',
|
||||
self::reunion->name => 'RE',
|
||||
self::saintPierreAndMiquelon->name => 'PM',
|
||||
self::mayotte->name => 'YT',
|
||||
self::saintBarthelemy->name => 'BL',
|
||||
self::saintMartinFrenchPart->name => 'MF',
|
||||
self::wallisAndFutuna->name => 'WF',
|
||||
self::frenchPolynesia->name => 'PF',
|
||||
self::newCaledonia->name => 'NC',
|
||||
self::afghanistan->name => 'AFG',
|
||||
self::alandIslands->name => 'ALA',
|
||||
self::albania->name => 'ALB',
|
||||
self::algeria->name => 'DZA',
|
||||
self::americanSamoa->name => 'ASM',
|
||||
self::andorra->name => 'AND',
|
||||
self::angola->name => 'AGO',
|
||||
self::anguilla->name => 'AIA',
|
||||
self::antarctica->name => 'AQ',
|
||||
self::antiguaAndBarbuda->name => 'ATG',
|
||||
self::argentina->name => 'ARG',
|
||||
self::armenia->name => 'ARM',
|
||||
self::aruba->name => 'ABW',
|
||||
self::australia->name => 'AUS',
|
||||
self::austria->name => 'AUT',
|
||||
self::azerbaijan->name => 'AZE',
|
||||
self::bahrain->name => 'BHR',
|
||||
self::bahamas->name => 'BHS',
|
||||
self::bangladesh->name => 'BGD',
|
||||
self::barbados->name => 'BRB',
|
||||
self::belarus->name => 'BLR',
|
||||
self::belgium->name => 'BEL',
|
||||
self::belize->name => 'BLZ',
|
||||
self::benin->name => 'BEN',
|
||||
self::bermuda->name => 'BMU',
|
||||
self::bhutan->name => 'BTN',
|
||||
self::boliviaPlurinationalStateOf->name => 'BOL',
|
||||
self::bonaireSintEustatiusAndSaba->name => 'BES',
|
||||
self::bosniaAndHerzegovina->name => 'BIH',
|
||||
self::botswana->name => 'BWA',
|
||||
self::bouvetIsland->name => 'BVT',
|
||||
self::brazil->name => 'BRA',
|
||||
self::britishIndianOceanTerritory->name => 'IOT',
|
||||
self::bruneiDarussalam->name => 'BRN',
|
||||
self::bulgaria->name => 'BGR',
|
||||
self::burkinaFaso->name => 'BFA',
|
||||
self::burundi->name => 'BDI',
|
||||
self::cambodia->name => 'KHM',
|
||||
self::cameroon->name => 'CMR',
|
||||
self::canada->name => 'CAN',
|
||||
self::capeVerde->name => 'CPV',
|
||||
self::caymanIslands->name => 'CYM',
|
||||
self::centralAfricanRepublic->name => 'CAF',
|
||||
self::chad->name => 'TCD',
|
||||
self::chile->name => 'CHL',
|
||||
self::china->name => 'CHN',
|
||||
self::christmasIsland->name => 'CXR',
|
||||
self::cocosKeelingIslands->name => 'CCK',
|
||||
self::colombia->name => 'COL',
|
||||
self::comoros->name => 'COM',
|
||||
self::congo->name => 'COG',
|
||||
self::congoTheDemocraticRepublicOfThe->name => 'COD',
|
||||
self::cookIslands->name => 'COK',
|
||||
self::costaRica->name => 'CRI',
|
||||
self::coteDivoire->name => 'CIV',
|
||||
self::croatia->name => 'HRV',
|
||||
self::cuba->name => 'CUB',
|
||||
self::curacao->name => 'CUW',
|
||||
self::cyprus->name => 'CYP',
|
||||
self::czechRepublic->name => 'CZE',
|
||||
self::denmark->name => 'DNK',
|
||||
self::djibouti->name => 'DJI',
|
||||
self::dominica->name => 'DMA',
|
||||
self::dominicanRepublic->name => 'DOM',
|
||||
self::ecuador->name => 'ECU',
|
||||
self::egypt->name => 'EGY',
|
||||
self::elSalvador->name => 'SLV',
|
||||
self::equatorialGuinea->name => 'GNQ',
|
||||
self::eritrea->name => 'ERI',
|
||||
self::estonia->name => 'EST',
|
||||
self::ethiopia->name => 'ETH',
|
||||
self::falklandIslandsMalvinas->name => 'FLK',
|
||||
self::faroeIslands->name => 'FRO',
|
||||
self::fiji->name => 'FJI',
|
||||
self::finland->name => 'FIN',
|
||||
self::france->name => 'FRA',
|
||||
self::frenchGuiana->name => 'GUF',
|
||||
self::frenchPolynesia->name => 'PYF',
|
||||
self::frenchSouthernTerritories->name => 'ATF',
|
||||
self::gabon->name => 'GAB',
|
||||
self::gambia->name => 'GMB',
|
||||
self::georgia->name => 'GEO',
|
||||
self::germany->name => 'DEU',
|
||||
self::ghana->name => 'GHA',
|
||||
self::gibraltar->name => 'GIB',
|
||||
self::greece->name => 'GRC',
|
||||
self::greenland->name => 'GRL',
|
||||
self::grenada->name => 'GRD',
|
||||
self::guadeloupe->name => 'GLP',
|
||||
self::guam->name => 'GUM',
|
||||
self::guatemala->name => 'GTM',
|
||||
self::guernsey->name => 'GGY',
|
||||
self::guinea->name => 'GIN',
|
||||
self::guineaBissau->name => 'GNB',
|
||||
self::guyana->name => 'GUY',
|
||||
self::haiti->name => 'HTI',
|
||||
self::heardIslandAndMcdonaldIslands->name => 'HMD',
|
||||
self::holySeeVaticanCityState->name => 'VAT',
|
||||
self::honduras->name => 'HND',
|
||||
self::hongKong->name => 'HKG',
|
||||
self::hungary->name => 'HUN',
|
||||
self::iceland->name => 'ISL',
|
||||
self::india->name => 'IND',
|
||||
self::indonesia->name => 'IDN',
|
||||
self::iranIslamicRepublicOf->name => 'IRN',
|
||||
self::iraq->name => 'IRQ',
|
||||
self::ireland->name => 'IRL',
|
||||
self::isleOfMan->name => 'IMN',
|
||||
self::israel->name => 'ISR',
|
||||
self::italy->name => 'ITA',
|
||||
self::jamaica->name => 'JAM',
|
||||
self::japan->name => 'JPN',
|
||||
self::jersey->name => 'JEY',
|
||||
self::jordan->name => 'JOR',
|
||||
self::kazakhstan->name => 'KAZ',
|
||||
self::kenya->name => 'KEN',
|
||||
self::kiribati->name => 'KIR',
|
||||
self::koreaDemocraticPeoplesRepublicOf->name => 'PRK',
|
||||
self::koreaRepublicOf->name => 'KOR',
|
||||
self::kuwait->name => 'KWT',
|
||||
self::kyrgyzstan->name => 'KGZ',
|
||||
self::laoPeoplesDemocraticRepublic->name => 'LAO',
|
||||
self::latvia->name => 'LVA',
|
||||
self::lebanon->name => 'LBN',
|
||||
self::lesotho->name => 'LSO',
|
||||
self::liberia->name => 'LBR',
|
||||
self::libya->name => 'LBY',
|
||||
self::liechtenstein->name => 'LIE',
|
||||
self::lithuania->name => 'LTU',
|
||||
self::luxembourg->name => 'LUX',
|
||||
self::macao->name => 'MAC',
|
||||
self::macedoniaTheFormerYugoslavRepublicOf->name => 'MKD',
|
||||
self::madagascar->name => 'MDG',
|
||||
self::malawi->name => 'MWI',
|
||||
self::malaysia->name => 'MYS',
|
||||
self::maldives->name => 'MDV',
|
||||
self::mali->name => 'MLI',
|
||||
self::malta->name => 'MLT',
|
||||
self::marshallIslands->name => 'MHL',
|
||||
self::martinique->name => 'MTQ',
|
||||
self::mauritania->name => 'MRT',
|
||||
self::mauritius->name => 'MUS',
|
||||
self::mayotte->name => 'MYT',
|
||||
self::mexico->name => 'MEX',
|
||||
self::micronesiaFederatedStatesOf->name => 'FSM',
|
||||
self::moldovaRepublicOf->name => 'MDA',
|
||||
self::monaco->name => 'MCO',
|
||||
self::mongolia->name => 'MNG',
|
||||
self::montenegro->name => 'MNE',
|
||||
self::montserrat->name => 'MSR',
|
||||
self::morocco->name => 'MAR',
|
||||
self::mozambique->name => 'MOZ',
|
||||
self::myanmar->name => 'MMR',
|
||||
self::namibia->name => 'NAM',
|
||||
self::nauru->name => 'NRU',
|
||||
self::nepal->name => 'NPL',
|
||||
self::netherlands->name => 'NLD',
|
||||
self::newCaledonia->name => 'NCL',
|
||||
self::newZealand->name => 'NZL',
|
||||
self::nicaragua->name => 'NIC',
|
||||
self::niger->name => 'NER',
|
||||
self::nigeria->name => 'NGA',
|
||||
self::niue->name => 'NIU',
|
||||
self::norfolkIsland->name => 'NFK',
|
||||
self::northernMarianaIslands->name => 'MNP',
|
||||
self::norway->name => 'NOR',
|
||||
self::oman->name => 'OMN',
|
||||
self::pakistan->name => 'PAK',
|
||||
self::palau->name => 'PLW',
|
||||
self::palestineStateOf->name => 'PSE',
|
||||
self::panama->name => 'PAN',
|
||||
self::papuaNewGuinea->name => 'PNG',
|
||||
self::paraguay->name => 'PRY',
|
||||
self::peru->name => 'PER',
|
||||
self::philippines->name => 'PHL',
|
||||
self::pitcairn->name => 'PCN',
|
||||
self::poland->name => 'POL',
|
||||
self::portugal->name => 'PRT',
|
||||
self::puertoRico->name => 'PRI',
|
||||
self::qatar->name => 'QAT',
|
||||
self::reunion->name => 'REU',
|
||||
self::romania->name => 'ROU',
|
||||
self::russianFederation->name => 'RUS',
|
||||
self::rwanda->name => 'RWA',
|
||||
self::saintBarthelemy->name => 'BLM',
|
||||
self::saintHelenaAscensionAndTristanDaCunha->name => 'SHN',
|
||||
self::saintKittsAndNevis->name => 'KNA',
|
||||
self::saintLucia->name => 'LCA',
|
||||
self::saintMartinFrenchPart->name => 'MAF',
|
||||
self::saintPierreAndMiquelon->name => 'SPM',
|
||||
self::saintVincentAndTheGrenadines->name => 'VCT',
|
||||
self::samoa->name => 'WSM',
|
||||
self::sanMarino->name => 'SMR',
|
||||
self::saoTomeAndPrincipe->name => 'STP',
|
||||
self::saudiArabia->name => 'SAU',
|
||||
self::senegal->name => 'SEN',
|
||||
self::serbia->name => 'SRB',
|
||||
self::seychelles->name => 'SYC',
|
||||
self::sierraLeone->name => 'SLE',
|
||||
self::singapore->name => 'SGP',
|
||||
self::sintMaartenDutchPart->name => 'SXM',
|
||||
self::slovakia->name => 'SVK',
|
||||
self::slovenia->name => 'SVN',
|
||||
self::solomonIslands->name => 'SLB',
|
||||
self::somalia->name => 'SOM',
|
||||
self::southAfrica->name => 'ZAF',
|
||||
self::southGeorgiaAndTheSouthSandwichIslands->name => 'SGS',
|
||||
self::southSudan->name => 'SSD',
|
||||
self::spain->name => 'ESP',
|
||||
self::sriLanka->name => 'LKA',
|
||||
self::sudan->name => 'SDN',
|
||||
self::suriname->name => 'SUR',
|
||||
self::svalbardAndJanMayen->name => 'SJM',
|
||||
self::swaziland->name => 'SWZ',
|
||||
self::sweden->name => 'SWE',
|
||||
self::switzerland->name => 'CHE',
|
||||
self::syrianArabRepublic->name => 'SYR',
|
||||
self::taiwanProvinceOfChina->name => 'TWN',
|
||||
self::tajikistan->name => 'TJK',
|
||||
self::tanzaniaUnitedRepublicOf->name => 'TZA',
|
||||
self::thailand->name => 'THA',
|
||||
self::timorLeste->name => 'TLS',
|
||||
self::togo->name => 'TGO',
|
||||
self::tokelau->name => 'TKL',
|
||||
self::tonga->name => 'TON',
|
||||
self::trinidadAndTobago->name => 'TTO',
|
||||
self::tunisia->name => 'TUN',
|
||||
self::turkey->name => 'TUR',
|
||||
self::turkmenistan->name => 'TKM',
|
||||
self::turksAndCaicosIslands->name => 'TCA',
|
||||
self::tuvalu->name => 'TUV',
|
||||
self::uganda->name => 'UGA',
|
||||
self::ukraine->name => 'UKR',
|
||||
self::unitedArabEmirates->name => 'ARE',
|
||||
self::unitedKingdom->name => 'GBR',
|
||||
self::unitedStates->name => 'USA',
|
||||
self::unitedStatesMinorOutlyingIslands->name => 'UMI',
|
||||
self::uruguay->name => 'URY',
|
||||
self::uzbekistan->name => 'UZB',
|
||||
self::vanuatu->name => 'VUT',
|
||||
self::venezuelaBolivarianRepublicOf->name => 'VEN',
|
||||
self::vietNam->name => 'VNM',
|
||||
self::virginIslandsBritish->name => 'VGB',
|
||||
self::virginIslandsUs->name => 'VIR',
|
||||
self::wallisAndFutuna->name => 'WLF',
|
||||
self::westernSahara->name => 'ESH',
|
||||
self::yemen->name => 'YEM',
|
||||
self::zambia->name => 'ZMB',
|
||||
self::zimbabwe->name => 'ZWE',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
27
app/Enums/Listen/ObjectEnum.php
Normal file
27
app/Enums/Listen/ObjectEnum.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Listen;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum ObjectEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case remark = 1;
|
||||
case sponsoring = 2;
|
||||
case service = 3;
|
||||
case other = 4;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::remark->name => 'Contact Commercial ou remarque sur nos produits',
|
||||
self::sponsoring->name => 'Demande de partenariat ou sponsoring',
|
||||
self::service->name => 'Proposition de service au fournisseur',
|
||||
self::other->name => 'Autre demande',
|
||||
];
|
||||
}
|
||||
|
|
@ -13,64 +13,70 @@ enum PageSectionEnum: int
|
|||
case home_team = 3;
|
||||
case home_life = 4;
|
||||
case unveil_pole = 5;
|
||||
case unveil_local = 6;
|
||||
case unveil_sites = 7;
|
||||
case unveil_history = 8;
|
||||
case unveil_commitments = 9;
|
||||
case hire_life = 10;
|
||||
case hire_formation = 11;
|
||||
case hire_grow = 12;
|
||||
case hire_parity = 13;
|
||||
case hire_find = 14;
|
||||
case commit_ambition = 15;
|
||||
case commit_breeding = 16;
|
||||
case commit_living = 17;
|
||||
case commit_respect_earth = 18;
|
||||
case commit_feed = 19;
|
||||
case commit_commitments = 20;
|
||||
case move_life = 21;
|
||||
case move_commitments = 22;
|
||||
case produce_local = 23;
|
||||
case produce_gms = 24;
|
||||
case produce_rhd = 25;
|
||||
case produce_export = 26;
|
||||
case produce_quality = 27;
|
||||
case produce_linking = 28;
|
||||
case listening_study = 29;
|
||||
case unveil_missions = 6;
|
||||
case unveil_local = 7;
|
||||
case unveil_sites = 8;
|
||||
case unveil_history = 9;
|
||||
case unveil_commitments = 10;
|
||||
case hire_life = 11;
|
||||
case hire_formation = 12;
|
||||
case hire_grow = 13;
|
||||
case hire_parity = 14;
|
||||
case hire_find = 15;
|
||||
case commit_ambition = 16;
|
||||
case commit_breeding = 17;
|
||||
case commit_living = 18;
|
||||
case commit_respect_earth = 19;
|
||||
case commit_feed = 20;
|
||||
case commit_commitments = 21;
|
||||
case move_life = 22;
|
||||
case move_commitments = 23;
|
||||
case produce_local = 24;
|
||||
case produce_gms = 25;
|
||||
case produce_rhd = 26;
|
||||
case produce_export = 27;
|
||||
case produce_quality = 28;
|
||||
case produce_linking = 29;
|
||||
case listening_study = 30;
|
||||
case produce_networks = 31;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::home_missions->name => 'Nos Missions',
|
||||
self::home_ambition->name => 'Notre Ambition',
|
||||
self::home_team->name => 'L\'équipe VOLENA',
|
||||
self::home_life->name => 'La vie chez VOLENA',
|
||||
self::unveil_pole->name => 'Le Pôle Volena',
|
||||
self::unveil_local->name => 'Notre Filière Locale',
|
||||
self::unveil_sites->name => 'Nos Sites',
|
||||
self::unveil_history->name => 'Histoire',
|
||||
self::unveil_commitments->name => 'Engagements',
|
||||
self::hire_life->name => 'Vie de l\'Entreprise',
|
||||
self::hire_formation->name => 'Alternance et Formation',
|
||||
self::hire_grow->name => 'Fiers d\'évoluer ensemble',
|
||||
self::hire_parity->name => 'Parité',
|
||||
self::hire_find->name => 'On se retrouve',
|
||||
self::commit_ambition->name => 'Ambition',
|
||||
self::commit_breeding->name => 'Elever Durablement',
|
||||
self::commit_living->name => 'Mieux vivre',
|
||||
self::home_missions->name => 'Nos Missions',
|
||||
self::home_ambition->name => 'Notre Ambition',
|
||||
self::home_team->name => 'L\'équipe VOLENA',
|
||||
self::home_life->name => 'La vie chez VOLENA',
|
||||
self::unveil_pole->name => 'Le Pôle Volena',
|
||||
self::unveil_missions->name => 'Nos Missions',
|
||||
self::unveil_local->name => 'Notre Filière Locale',
|
||||
self::unveil_sites->name => 'Nos Sites',
|
||||
self::unveil_history->name => 'Histoire',
|
||||
self::unveil_commitments->name => 'Engagements',
|
||||
self::hire_life->name => 'Vie de l\'Entreprise',
|
||||
self::hire_formation->name => 'Alternance et Formation',
|
||||
self::hire_grow->name => 'Fiers d\'évoluer ensemble',
|
||||
self::hire_parity->name => 'Parité',
|
||||
self::hire_find->name => 'On se retrouve',
|
||||
self::commit_ambition->name => 'Ambition',
|
||||
self::commit_breeding->name => 'Elever Durablement',
|
||||
self::commit_living->name => 'Mieux vivre',
|
||||
self::commit_respect_earth->name => 'Respecter la terre',
|
||||
self::commit_feed->name => 'Bien nourrir',
|
||||
self::commit_commitments->name => 'Engagements',
|
||||
self::move_life->name => 'Vie de l\'Entreprise',
|
||||
self::move_commitments->name => 'Engagements',
|
||||
self::produce_local->name => 'Large Gamme Locale',
|
||||
self::produce_gms->name => 'Retrouvez en GMS',
|
||||
self::produce_rhd->name => 'RHD',
|
||||
self::produce_export->name => 'Export',
|
||||
self::produce_quality->name => 'Qualité',
|
||||
self::produce_linking->name => 'Liens',
|
||||
self::listening_study->name => 'On étudie',
|
||||
self::commit_feed->name => 'Bien nourrir',
|
||||
self::commit_commitments->name => 'Engagements',
|
||||
self::move_life->name => 'Vie de l\'Entreprise',
|
||||
self::move_commitments->name => 'Engagements',
|
||||
self::produce_local->name => 'Large Gamme Locale',
|
||||
self::produce_gms->name => 'Retrouvez en GMS',
|
||||
self::produce_rhd->name => 'RHD',
|
||||
self::produce_export->name => 'Export',
|
||||
self::produce_quality->name => 'Qualité',
|
||||
self::produce_linking->name => 'Liens',
|
||||
self::listening_study->name => 'On étudie',
|
||||
self::produce_networks->name => 'Nos réseaux',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -94,6 +100,7 @@ enum PageSectionEnum: int
|
|||
self::commit_feed,
|
||||
self::move_commitments,
|
||||
self::produce_linking => true,
|
||||
self::unveil_missions,
|
||||
self::unveil_local,
|
||||
self::unveil_sites,
|
||||
self::unveil_history,
|
||||
|
|
@ -109,7 +116,8 @@ enum PageSectionEnum: int
|
|||
self::produce_rhd,
|
||||
self::produce_export,
|
||||
self::produce_quality,
|
||||
self::listening_study => false,
|
||||
self::listening_study,
|
||||
self::produce_networks => false,
|
||||
}; //end match
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +135,9 @@ enum PageSectionEnum: int
|
|||
self::home_life,
|
||||
self::unveil_sites,
|
||||
self::unveil_history,
|
||||
self::unveil_commitments => \App\Enums\CkEditorConfigName::base->label(),
|
||||
self::unveil_commitments => \App\Enums\CkEditorConfigName::basic->label(),
|
||||
self::unveil_pole,
|
||||
self::unveil_missions,
|
||||
self::unveil_local,
|
||||
self::hire_life,
|
||||
self::hire_formation,
|
||||
|
|
@ -149,7 +158,8 @@ enum PageSectionEnum: int
|
|||
self::produce_quality,
|
||||
self::listening_study => \App\Enums\CkEditorConfigName::advanced->label(),
|
||||
self::produce_linking,
|
||||
self::hire_grow, => null,
|
||||
self::hire_grow,
|
||||
self::produce_networks => null,
|
||||
}; //end match
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ enum SpeciesEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::chicken->name => 'Poulet',
|
||||
|
|
@ -28,4 +30,73 @@ enum SpeciesEnum: int
|
|||
self::guinea_fowl->name => 'Pintade',
|
||||
self::rooster->name => 'Coq',
|
||||
];
|
||||
|
||||
/**
|
||||
* Pictures paths.
|
||||
*/
|
||||
private const PICTURES = [
|
||||
self::chicken->name => 'resources/assets/images/pictos/chicken.jpg',
|
||||
self::turkey->name => 'resources/assets/images/pictos/turkey.jpg',
|
||||
self::hen->name => 'resources/assets/images/pictos/hen_and_rooster.jpg',
|
||||
self::duck->name => 'resources/assets/images/pictos/duck.jpg',
|
||||
self::rabbit->name => 'resources/assets/images/pictos/rabbit.jpg',
|
||||
self::guinea_fowl->name => 'resources/assets/images/pictos/guinea_fowl.jpg',
|
||||
self::rooster->name => 'resources/assets/images/pictos/hen_and_rooster.jpg',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function picture(): string
|
||||
{
|
||||
return self::PICTURES[$this->name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alt attributes for pictures.
|
||||
*/
|
||||
private const ALTS = [
|
||||
self::chicken->name => 'Pictogramme pour la catégorie \'poulet\'',
|
||||
self::turkey->name => 'Pictogramme pour la catégorie \'dinde\'',
|
||||
self::hen->name => 'Pictogramme pour la catégorie \'poule\'',
|
||||
self::duck->name => 'Pictogramme pour la catégorie \'canard\'',
|
||||
self::rabbit->name => 'Pictogramme pour la catégorie \'lapin\'',
|
||||
self::guinea_fowl->name => 'Pictogramme pour la catégorie \'pintade\'',
|
||||
self::rooster->name => 'Pictogramme pour la catégorie \'coq\'',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture alt attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function alt(): string
|
||||
{
|
||||
return self::ALTS[$this->name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alt attributes for pictures.
|
||||
*/
|
||||
private const TITLES = [
|
||||
self::chicken->name => 'Pictogramme pour la catégorie \'poulet\'',
|
||||
self::turkey->name => 'Pictogramme pour la catégorie \'dinde\'',
|
||||
self::hen->name => 'Pictogramme pour la catégorie \'poule\'',
|
||||
self::duck->name => 'Pictogramme pour la catégorie \'canard\'',
|
||||
self::rabbit->name => 'Pictogramme pour la catégorie \'lapin\'',
|
||||
self::guinea_fowl->name => 'Pictogramme pour la catégorie \'pintade\'',
|
||||
self::rooster->name => 'Pictogramme pour la catégorie \'coq\'',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture alt attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return self::TITLES[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,17 @@ enum SliderTypeEnum: int
|
|||
case home = 1;
|
||||
case better_life = 2;
|
||||
case respect_earth = 3;
|
||||
case team = 4;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::home->name => 'Accueil',
|
||||
self::better_life->name => 'Mieux vivre',
|
||||
self::respect_earth->name => 'Respecter la terre',
|
||||
self::team->name => 'Nous rejoindre',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ enum StaticPageType: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::contact->name => 'Contact',
|
||||
|
|
@ -38,7 +40,7 @@ enum StaticPageType: int
|
|||
/**
|
||||
* Get the enums for the page which contains sections.
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, self>
|
||||
*/
|
||||
public static function containsSection(): array
|
||||
{
|
||||
|
|
@ -52,4 +54,45 @@ enum StaticPageType: int
|
|||
self::we_listen,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the static page need to fill its 'content' column ?
|
||||
*
|
||||
* @return boolean
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
public function containsContent(): bool
|
||||
{
|
||||
// @phpcs:enable
|
||||
return match ($this) {
|
||||
self::contact => false,
|
||||
self::legals => true,
|
||||
self::confidentiality => true,
|
||||
self::home => false,
|
||||
self::unveil => false,
|
||||
self::we_hire => false,
|
||||
self::we_commit => false,
|
||||
self::we_move => false,
|
||||
self::we_produce => false,
|
||||
self::we_listen => false,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the static page need to fill its 'picture' column ?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function containsBanner(): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::unveil,
|
||||
self::we_hire,
|
||||
self::we_commit,
|
||||
self::we_move,
|
||||
self::we_produce,
|
||||
self::we_listen => true,
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
app/Enums/StickiesColorEnum.php
Normal file
31
app/Enums/StickiesColorEnum.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum StickiesColorEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case primary = 1;
|
||||
case secondary = 2;
|
||||
case tertiary = 3;
|
||||
case quad = 4;
|
||||
case quint = 5;
|
||||
case sixt = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::primary->name => 'Primary',
|
||||
self::secondary->name => 'Secondary',
|
||||
self::tertiary->name => 'Tertiary',
|
||||
self::quad->name => 'Quad',
|
||||
self::quint->name => 'Quint',
|
||||
self::sixt->name => 'Sixt',
|
||||
];
|
||||
}
|
||||
|
|
@ -8,22 +8,91 @@ enum PictoEnum: int
|
|||
{
|
||||
use BaseEnum;
|
||||
|
||||
case danger = 1;
|
||||
case respect_earth = 2;
|
||||
case breeding = 3;
|
||||
case feed = 4;
|
||||
case better_life = 5;
|
||||
case none = 6;
|
||||
case none = 1;
|
||||
case danger = 2;
|
||||
case respect_earth = 3;
|
||||
case breeding = 4;
|
||||
case feed = 5;
|
||||
case better_life = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::none->name => 'Aucun',
|
||||
self::danger->name => 'Danger',
|
||||
self::respect_earth->name => 'Respecter la terre',
|
||||
self::breeding->name => 'Elever Durablement',
|
||||
self::feed->name => 'Bien Nourrir',
|
||||
self::better_life->name => 'Mieux vivre en équipe',
|
||||
self::none->name => 'Aucun',
|
||||
];
|
||||
|
||||
/**
|
||||
* Pictures paths.
|
||||
*/
|
||||
private const PICTURES = [
|
||||
self::none->name => 'resources/assets/images/pictos/none.jpg',
|
||||
self::danger->name => 'resources/assets/images/pictos/danger.png',
|
||||
self::respect_earth->name => 'resources/assets/images/pictos/respect_earth.png',
|
||||
self::breeding->name => 'resources/assets/images/pictos/breeding.png',
|
||||
self::feed->name => 'resources/assets/images/pictos/feed.png',
|
||||
self::better_life->name => 'resources/assets/images/pictos/better_life.png',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function picture(): string
|
||||
{
|
||||
return self::PICTURES[$this->name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alt attributes for pictures.
|
||||
*/
|
||||
private const ALTS = [
|
||||
self::none->name => 'Logo Volena',
|
||||
self::danger->name => 'Pictogramme pour la catégorie \'Danger\'',
|
||||
self::respect_earth->name => 'Pictogramme pour la catégorie \'Respecter la terre\'',
|
||||
self::breeding->name => 'Pictogramme pour la catégorie \'Elever durablement\'',
|
||||
self::feed->name => 'Pictogramme pour la catégorie \'Bien nourrir\'',
|
||||
self::better_life->name => 'Pictogramme pour la catégorie \'Mieux vivre en équipe\'',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture alt attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function alt(): string
|
||||
{
|
||||
return self::ALTS[$this->name];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alt attributes for pictures.
|
||||
*/
|
||||
private const TITLES = [
|
||||
self::none->name => 'Logo Volena',
|
||||
self::danger->name => 'Pictogramme pour la catégorie \'Danger\'',
|
||||
self::respect_earth->name => 'Pictogramme pour la catégorie \'Respecter la terre\'',
|
||||
self::breeding->name => 'Pictogramme pour la catégorie \'Elever durablement\'',
|
||||
self::feed->name => 'Pictogramme pour la catégorie \'Bien nourrir\'',
|
||||
self::better_life->name => 'Pictogramme pour la catégorie \'Mieux vivre en équipe\'',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get picture alt attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return self::TITLES[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum TypeEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::breeding->name => 'Elever Durablement',
|
||||
|
|
@ -26,4 +28,26 @@ enum TypeEnum: int
|
|||
self::volena->name => 'Voléna',
|
||||
self::hire->name => 'On Embauche',
|
||||
];
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const COLORS = [
|
||||
self::breeding->name => 'tertiary',
|
||||
self::better_life->name => 'quad',
|
||||
self::respect_earth->name => 'quint',
|
||||
self::feed->name => 'sixt',
|
||||
self::volena->name => 'primary',
|
||||
self::hire->name => 'primary',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get color name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return self::COLORS[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@ enum BootstrapThemeEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::light->name => 'Light',
|
||||
self::dark->name => 'Dark',
|
||||
self::light->name => 'enums.bootstrap-theme.light',
|
||||
self::dark->name => 'enums.bootstrap-theme.dark',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ enum RoleEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::conceptor->name => 'Concepteur',
|
||||
self::admin->name => 'Administrateur',
|
||||
self::visitor->name => 'Visiteur',
|
||||
self::conceptor->name => 'enums.user-role.conceptor',
|
||||
self::admin->name => 'enums.user-role.admin',
|
||||
self::visitor->name => 'enums.user-role.visitor',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ class ActivityLogController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$this->authorize('isConceptor');
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\ActivityLog> $query */
|
||||
$query = ActivityLog::query()->with('user');
|
||||
|
||||
/** @var string $search Search field */
|
||||
|
|
@ -51,12 +50,12 @@ class ActivityLogController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\ActivityLog $activity_log
|
||||
* @param \App\Models\ActivityLog $activity_log
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$this->authorize('isConceptor');
|
||||
/** @var \Illuminate\Database\Eloquent\Model $targetModelClass */
|
||||
$targetModelClass = $activity_log->model_class;
|
||||
$targetModel = $activity_log->model_class::where(
|
||||
(new $targetModelClass())->getRouteKeyName(),
|
||||
|
|
|
|||
194
app/Http/Controllers/Bo/AisleController.php
Normal file
194
app/Http/Controllers/Bo/AisleController.php
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Aisles\StoreAisleRequest;
|
||||
use App\Http\Requests\Bo\Aisles\UpdateAisleRequest;
|
||||
use App\Models\Aisle;
|
||||
use App\Models\Network;
|
||||
use App\Traits\Controllers\UpdateModelOrder;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AisleController extends Controller
|
||||
{
|
||||
use UpdateModelOrder;
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Aisle::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Aisle> $aisleModels */
|
||||
$aisleModels = Aisle::query()->with('network');
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Network> $networkModels */
|
||||
$networkModels = Network::query()->where('published', true)->get();
|
||||
|
||||
$selectedNetwork = intval($request->network);
|
||||
|
||||
$aisleModels = $aisleModels->when($selectedNetwork, function ($query) use ($selectedNetwork) {
|
||||
$query->where('network_id', $selectedNetwork);
|
||||
});
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$aisleModels,
|
||||
$search,
|
||||
null,
|
||||
'name',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.name')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($aisleModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$aisleModels = $this->paginate($aisleModels);
|
||||
|
||||
return view(
|
||||
'bo.pages.aisles.index',
|
||||
compact(
|
||||
'aisleModels',
|
||||
'networkModels',
|
||||
'selectedNetwork',
|
||||
'search',
|
||||
'searchFields'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Aisle $aisle
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Aisle $aisle): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$networkModels = Network::all();
|
||||
|
||||
return view('bo.pages.aisles.create', [
|
||||
'aisleModel' => $aisle,
|
||||
'networkModels' => $networkModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Aisles\StoreAisleRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreAisleRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$aisle = new Aisle();
|
||||
$aisle->fill($request->validated());
|
||||
|
||||
if ($aisle->saveOrFail()) {
|
||||
return redirect()->route('bo.aisles.edit', $aisle)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Aisle $aisle
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Aisle $aisle): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$networkModels = Network::all();
|
||||
|
||||
return view('bo.pages.aisles.edit', [
|
||||
'aisleModel' => $aisle,
|
||||
'networkModels' => $networkModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Aisles\UpdateAisleRequest $request
|
||||
* @param \App\Models\Aisle $aisle
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateAisleRequest $request, Aisle $aisle): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $aisle) {
|
||||
$aisle->fill($request->validated());
|
||||
|
||||
if ($aisle->saveOrFail()) {
|
||||
return redirect()->route('bo.aisles.edit', $aisle)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.aisles.edit', $aisle)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Aisle $aisle
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Aisle $aisle): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($aisle) {
|
||||
if ($aisle->deleteOrFail()) {
|
||||
return redirect()->route('bo.aisles.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.aisle'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Aisle $aisle
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Aisle $aisle): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($aisle->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,6 @@
|
|||
namespace App\Http\Controllers\Bo\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
|
@ -28,7 +26,7 @@ class LoginController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
protected function guard(): StatefulGuard
|
||||
protected function guard(): \Illuminate\Contracts\Auth\StatefulGuard
|
||||
{
|
||||
return Auth::guard('backend');
|
||||
}
|
||||
|
|
@ -38,7 +36,7 @@ class LoginController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function showLoginForm(): View
|
||||
public function showLoginForm(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.auth.login');
|
||||
}
|
||||
|
|
@ -59,7 +57,7 @@ class LoginController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return boolean
|
||||
*/
|
||||
protected function attemptLogin(Request $request)
|
||||
protected function attemptLogin(Request $request): bool
|
||||
{
|
||||
$credentials = $this->credentials($request);
|
||||
// * Attempt login only using published users.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Controllers\Bo\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ class ResetPasswordController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
protected function guard(): StatefulGuard
|
||||
protected function guard(): \Illuminate\Contracts\Auth\StatefulGuard
|
||||
{
|
||||
return Auth::guard('backend');
|
||||
}
|
||||
|
|
|
|||
176
app/Http/Controllers/Bo/BrandController.php
Normal file
176
app/Http/Controllers/Bo/BrandController.php
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Brands\StoreBrandRequest;
|
||||
use App\Http\Requests\Bo\Brands\UpdateBrandRequest;
|
||||
use App\Models\Aisle;
|
||||
use App\Models\Brand;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BrandController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Brand::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Brand> $brandModels */
|
||||
$brandModels = Brand::query()->with('aisle');
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$brandModels,
|
||||
$search,
|
||||
null,
|
||||
'name',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.name')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($brandModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$brandModels = $this->paginate($brandModels);
|
||||
|
||||
return view('bo.pages.brands.index', compact('brandModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Brand $brand
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Brand $brand): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$aisleModels = Aisle::all();
|
||||
|
||||
return view('bo.pages.brands.create', [
|
||||
'brandModel' => $brand,
|
||||
'aisleModels' => $aisleModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Brands\StoreBrandRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreBrandRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$brand = new Brand();
|
||||
$brand->fill($request->validated());
|
||||
|
||||
if ($brand->saveOrFail()) {
|
||||
return redirect()->route('bo.brands.edit', $brand)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Brand $brand
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Brand $brand): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$aisleModels = Aisle::all();
|
||||
|
||||
return view('bo.pages.brands.edit', [
|
||||
'brandModel' => $brand,
|
||||
'aisleModels' => $aisleModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Brands\UpdateBrandRequest $request
|
||||
* @param \App\Models\Brand $brand
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateBrandRequest $request, Brand $brand): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $brand) {
|
||||
$brand->fill($request->validated());
|
||||
|
||||
if ($brand->saveOrFail()) {
|
||||
return redirect()->route('bo.brands.edit', $brand)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.brands.edit', $brand)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Brand $brand
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Brand $brand): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($brand) {
|
||||
if ($brand->deleteOrFail()) {
|
||||
return redirect()->route('bo.brands.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.brand'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Brand $brand
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Brand $brand): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($brand->replicate());
|
||||
}
|
||||
}
|
||||
228
app/Http/Controllers/Bo/CarouselController.php
Normal file
228
app/Http/Controllers/Bo/CarouselController.php
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Carousels\StoreCarouselRequest;
|
||||
use App\Http\Requests\Bo\Carousels\UpdateCarouselRequest;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Carousel;
|
||||
use App\Models\Section;
|
||||
use App\Traits\Controllers\UpdateModelOrder;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CarouselController extends Controller
|
||||
{
|
||||
use UpdateModelOrder;
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Carousel::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Carousel> $carouselModels */
|
||||
$carouselModels = Carousel::query()->with('section');
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Section> $sectionModels */
|
||||
$sectionModels = Section::query()->whereHas('carousels')->get();
|
||||
|
||||
$selectedSection = intval($request->section);
|
||||
|
||||
$carouselModels = $carouselModels->when($selectedSection, function ($query) use ($selectedSection) {
|
||||
$query->where('section_id', $selectedSection);
|
||||
});
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$carouselModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucFirst(trans('validation.attributes.title')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($carouselModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$carouselModels = $this->paginate($carouselModels);
|
||||
|
||||
return view('bo.pages.carousels.index', compact(
|
||||
'carouselModels',
|
||||
'sectionModels',
|
||||
'selectedSection',
|
||||
'search',
|
||||
'searchFields'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Carousel $carousel
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Carousel $carousel): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$sectionModels = Section::all();
|
||||
|
||||
return view('bo.pages.carousels.create', [
|
||||
'carouselModel' => $carousel,
|
||||
'sectionModels' => $sectionModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Carousels\StoreCarouselRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreCarouselRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$carousel = new Carousel();
|
||||
$carousel->fill($request->validated());
|
||||
|
||||
if (!Arr::exists($request->validated(), 'media')) {
|
||||
$carousel->media = [];
|
||||
}
|
||||
|
||||
// Set the new pictures files in the pictures array.
|
||||
collect($request->only(['media.pictures.*.path']))
|
||||
->each(
|
||||
function (mixed $value, string $attribute) use ($carousel) {
|
||||
foreach ($value['pictures']['*']['path'] as $index => $file) {
|
||||
if ($file instanceof \Illuminate\Http\UploadedFile) {
|
||||
$carousel->setAttribute(
|
||||
"{$attribute}->pictures->{$index}->path",
|
||||
FileStorageHelper::storeFile($carousel, $file, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ($carousel->saveOrFail()) {
|
||||
return redirect()->route('bo.carousels.edit', $carousel)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Carousel $carousel
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Carousel $carousel): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$sectionModels = Section::all();
|
||||
|
||||
return view('bo.pages.carousels.edit', [
|
||||
'carouselModel' => $carousel,
|
||||
'sectionModels' => $sectionModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Carousels\UpdateCarouselRequest $request
|
||||
* @param \App\Models\Carousel $carousel
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateCarouselRequest $request, Carousel $carousel): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $carousel) {
|
||||
$carousel->fill($request->validated());
|
||||
if (!Arr::exists($request->validated(), 'media')) {
|
||||
$carousel->media = [];
|
||||
}
|
||||
|
||||
// Set the new pictures files in the pictures array.
|
||||
collect($request->only(['media.pictures.*.path']))
|
||||
->each(
|
||||
function (mixed $value, string $attribute) use ($carousel) {
|
||||
foreach ($value['pictures']['*']['path'] as $index => $file) {
|
||||
if ($file instanceof \Illuminate\Http\UploadedFile) {
|
||||
$carousel->setAttribute(
|
||||
"{$attribute}->pictures->{$index}->path",
|
||||
FileStorageHelper::storeFile($carousel, $file, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
if ($carousel->saveOrFail()) {
|
||||
return redirect()->route('bo.carousels.edit', $carousel)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.carousels.edit', $carousel)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Carousel $carousel
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Carousel $carousel): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($carousel->deleteOrFail()) {
|
||||
return redirect()->route('bo.carousels.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Carousel $carousel
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Carousel $carousel): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($carousel->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,15 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Dashboard Page
|
||||
* Dashboard Page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
public function index(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.dashboard');
|
||||
}
|
||||
|
|
|
|||
167
app/Http/Controllers/Bo/HistoricalMilestoneController.php
Normal file
167
app/Http/Controllers/Bo/HistoricalMilestoneController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\HistoricalMilestones\StoreHistoricalMilestoneRequest;
|
||||
use App\Http\Requests\Bo\HistoricalMilestones\UpdateHistoricalMilestoneRequest;
|
||||
use App\Models\HistoricalMilestone;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class HistoricalMilestoneController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(HistoricalMilestone::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\HistoricalMilestone> $historicalMilestoneModels */
|
||||
$historicalMilestoneModels = HistoricalMilestone::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$historicalMilestoneModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
'year',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
trans('validation.attributes.year'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($historicalMilestoneModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$historicalMilestoneModels = $this->paginate($historicalMilestoneModels);
|
||||
|
||||
return view(
|
||||
'bo.pages.historicalmilestones.index',
|
||||
compact('historicalMilestoneModels', 'search', 'searchFields')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.historicalmilestones.create', ['historicalMilestoneModel' => $historicalMilestone]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestones\StoreHistoricalMilestoneRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreHistoricalMilestoneRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$historicalMilestone = new HistoricalMilestone();
|
||||
$historicalMilestone->fill($request->validated());
|
||||
|
||||
if ($historicalMilestone->saveOrFail()) {
|
||||
return redirect()->route('bo.historicalmilestones.edit', $historicalMilestone)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.historicalmilestones.edit', ['historicalMilestoneModel' => $historicalMilestone]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestones\UpdateHistoricalMilestoneRequest $request
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateHistoricalMilestoneRequest $request,
|
||||
HistoricalMilestone $historicalMilestone
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $historicalMilestone) {
|
||||
$historicalMilestone->fill($request->validated());
|
||||
|
||||
if ($historicalMilestone->saveOrFail()) {
|
||||
return redirect()->route('bo.historicalmilestones.edit', $historicalMilestone)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.historicalmilestones.edit', $historicalMilestone)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(HistoricalMilestone $historicalMilestone): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($historicalMilestone->deleteOrFail()) {
|
||||
return redirect()->route('bo.historicalmilestones.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.historicalMilestone', 1))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($historicalMilestone->replicate());
|
||||
}
|
||||
}
|
||||
167
app/Http/Controllers/Bo/JobVideoController.php
Normal file
167
app/Http/Controllers/Bo/JobVideoController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\JobVideos\StoreJobVideoRequest;
|
||||
use App\Http\Requests\Bo\JobVideos\UpdateJobVideoRequest;
|
||||
use App\Models\JobVideo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class JobVideoController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(JobVideo::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\JobVideo> $jobVideoModels */
|
||||
$jobVideoModels = JobVideo::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$jobVideoModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
'place',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
trans('validation.custom.place'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($jobVideoModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$jobVideoModels = $this->paginate($jobVideoModels);
|
||||
|
||||
return view(
|
||||
'bo.pages.job_videos.index',
|
||||
compact('jobVideoModels', 'search', 'searchFields')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\JobVideo $jobVideo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(JobVideo $jobVideo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.job_videos.create', ['jobVideoModel' => $jobVideo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\JobVideos\StoreJobVideoRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreJobVideoRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$jobVideo = new JobVideo();
|
||||
$jobVideo->fill($request->validated());
|
||||
|
||||
if ($jobVideo->saveOrFail()) {
|
||||
return redirect()->route('bo.jobvideos.edit', $jobVideo)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\JobVideo $jobVideo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(JobVideo $jobVideo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.job_videos.edit', ['jobVideoModel' => $jobVideo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\JobVideos\UpdateJobVideoRequest $request
|
||||
* @param \App\Models\JobVideo $jobVideo
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateJobVideoRequest $request,
|
||||
JobVideo $jobVideo
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $jobVideo) {
|
||||
$jobVideo->fill($request->validated());
|
||||
|
||||
if ($jobVideo->saveOrFail()) {
|
||||
return redirect()->route('bo.jobvideos.edit', $jobVideo)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.jobvideos.edit', $jobVideo)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\JobVideo $jobVideo
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(JobVideo $jobVideo): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($jobVideo->deleteOrFail()) {
|
||||
return redirect()->route('bo.jobvideos.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.job_video', 1))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\JobVideo $jobVideo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(JobVideo $jobVideo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($jobVideo->replicate());
|
||||
}
|
||||
}
|
||||
161
app/Http/Controllers/Bo/LogoController.php
Normal file
161
app/Http/Controllers/Bo/LogoController.php
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Logos\StoreLogoRequest;
|
||||
use App\Http\Requests\Bo\Logos\UpdateLogoRequest;
|
||||
use App\Models\Logo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LogoController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Logo::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Logo> $logoModels */
|
||||
$logoModels = Logo::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$logoModels,
|
||||
$search,
|
||||
null,
|
||||
'label',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.custom.label')),
|
||||
trans('validation.custom.alt_attribute'),
|
||||
trans('validation.custom.title_attribute'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($logoModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$logoModels = $this->paginate($logoModels);
|
||||
|
||||
return view('bo.pages.logos.index', compact('logoModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Logo $logo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Logo $logo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.logos.create', ['logoModel' => $logo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Logos\StoreLogoRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreLogoRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$logo = new Logo();
|
||||
|
||||
if ($logo->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.logos.edit', $logo)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Logo $logo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Logo $logo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.logos.edit', ['logoModel' => $logo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Logos\UpdateLogoRequest $request
|
||||
* @param \App\Models\Logo $logo
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateLogoRequest $request, Logo $logo): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $logo) {
|
||||
if ($logo->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.logos.edit', $logo)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.logos.edit', $logo)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Logo $logo
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Logo $logo): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($logo->deleteOrFail()) {
|
||||
return redirect()->route('bo.logos.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.logo'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Logo $logo
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Logo $logo): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($logo->replicate());
|
||||
}
|
||||
}
|
||||
171
app/Http/Controllers/Bo/NetworkController.php
Normal file
171
app/Http/Controllers/Bo/NetworkController.php
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Networks\StoreNetworkRequest;
|
||||
use App\Http\Requests\Bo\Networks\UpdateNetworkRequest;
|
||||
use App\Models\Network;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NetworkController extends Controller
|
||||
{
|
||||
use ChangesModelOrder;
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Network::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Network> $networkModels */
|
||||
$networkModels = Network::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$networkModels,
|
||||
$search,
|
||||
null,
|
||||
'name',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.name')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($networkModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$networkModels = $this->paginate($networkModels);
|
||||
|
||||
return view('bo.pages.networks.index', compact('networkModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Network $network
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Network $network): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.networks.create', [
|
||||
'networkModel' => $network,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Networks\StoreNetworkRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreNetworkRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$network = new Network();
|
||||
$network->fill($request->validated());
|
||||
|
||||
if ($network->saveOrFail()) {
|
||||
return redirect()->route('bo.networks.edit', $network)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Network $network
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Network $network): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.networks.edit', [
|
||||
'networkModel' => $network,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Networks\UpdateNetworkRequest $request
|
||||
* @param \App\Models\Network $network
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateNetworkRequest $request, Network $network): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $network) {
|
||||
$network->fill($request->validated());
|
||||
|
||||
if ($network->saveOrFail()) {
|
||||
return redirect()->route('bo.networks.edit', $network)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.networks.edit', $network)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Network $network
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Network $network): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($network) {
|
||||
if ($network->deleteOrFail()) {
|
||||
return redirect()->route('bo.networks.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.network', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Network $network
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Network $network): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($network->replicate());
|
||||
}
|
||||
}
|
||||
166
app/Http/Controllers/Bo/NewsController.php
Normal file
166
app/Http/Controllers/Bo/NewsController.php
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\News\StoreNewsRequest;
|
||||
use App\Http\Requests\Bo\News\UpdateNewsRequest;
|
||||
use App\Models\News;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
use ChangesModelOrder;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(News::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\News> $newsModels */
|
||||
$newsModels = News::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$newsModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
'introduction',
|
||||
'content',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
trans('validation.custom.introduction'),
|
||||
trans('validation.attributes.content'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($newsModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$newsModels = $this->paginate($newsModels);
|
||||
|
||||
return view('bo.pages.news.index', compact('newsModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(News $news): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.news.create', ['newsModel' => $news]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\News\StoreNewsRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreNewsRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$news = new News();
|
||||
|
||||
if ($news->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.news.edit', $news)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(News $news): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.news.edit', ['newsModel' => $news]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\News\UpdateNewsRequest $request
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateNewsRequest $request, News $news): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $news) {
|
||||
if ($news->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.news.edit', $news)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.news.edit', $news)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(News $news): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($news->deleteOrFail()) {
|
||||
return redirect()->route('bo.news.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.news'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(News $news): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($news->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Http\Requests\Bo\Sections\UpdateSectionRequest;
|
||||
use App\Models\Section;
|
||||
use App\Models\StaticPage;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -29,7 +30,7 @@ class SectionController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Section> $query */
|
||||
$query = Section::query()->with('page');
|
||||
|
||||
// Filter by related page if requested.
|
||||
|
|
@ -48,7 +49,7 @@ class SectionController extends Controller
|
|||
}
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$query,
|
||||
|
|
@ -73,7 +74,7 @@ class SectionController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\Section $section
|
||||
* @param \App\Models\Section $section
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Section $section): \Illuminate\Contracts\View\View
|
||||
|
|
@ -88,25 +89,63 @@ class SectionController extends Controller
|
|||
* @param \App\Models\Section $section
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateSectionRequest $request, Section $section): \Illuminate\Http\RedirectResponse
|
||||
public function update(UpdateSectionRequest $request, Section $section): RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $section) {
|
||||
$section->fill(array_replace_recursive(
|
||||
\json_decode(\json_encode($section->toArray()), true),
|
||||
$request->validated()
|
||||
));
|
||||
|
||||
$encoded = json_encode($section->toArray());
|
||||
if ($encoded === false) {
|
||||
return redirect()->back()->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.section'))
|
||||
]));
|
||||
}
|
||||
/** @var array<string, mixed> $data */
|
||||
$data = json_decode($encoded, true);
|
||||
$section->fill(array_replace_recursive($data, $request->validated()));
|
||||
|
||||
if ($section->saveOrFail()) {
|
||||
return redirect()->route('bo.sections.edit', $section)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.section'))
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.section'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.sections.edit', $section)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.section'))
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.section'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Section add PartPiece
|
||||
*
|
||||
* @param \App\Models\Section $section
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function addPartPiece(Section $section): RedirectResponse
|
||||
{
|
||||
$section->addPartPiece();
|
||||
$section->saveOrFail();
|
||||
return response()->redirectToRoute('bo.sections.edit', $section)
|
||||
->with('success', trans('Partie ajouté'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Section remove PartPiece
|
||||
*
|
||||
* @param \App\Models\Section $section
|
||||
* @param integer $index
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function removePartPiece(Section $section, int $index): RedirectResponse
|
||||
{
|
||||
$count = $section->removePartPiece($index);
|
||||
$section->saveOrFail();
|
||||
$response = response()->redirectToRoute('bo.sections.edit', $section);
|
||||
if ($count) {
|
||||
$response->with('error', trans('Partie enlevé'));
|
||||
} else {
|
||||
$response->with('info', trans('Aucune partie enlevé'));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
186
app/Http/Controllers/Bo/SiteController.php
Normal file
186
app/Http/Controllers/Bo/SiteController.php
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Sites\StoreSiteRequest;
|
||||
use App\Http\Requests\Bo\Sites\UpdateSiteRequest;
|
||||
use App\Models\Logo;
|
||||
use App\Models\Site;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
use ChangesModelOrder;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Site::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Site> $siteModels */
|
||||
$siteModels = Site::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$siteModels,
|
||||
$search,
|
||||
null,
|
||||
'name',
|
||||
'description',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.name')),
|
||||
trans('validation.attributes.description'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($siteModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$siteModels = $this->paginate($siteModels);
|
||||
|
||||
return view('bo.pages.sites.index', compact('siteModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Site $site): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$logoModels = Logo::all();
|
||||
|
||||
return view('bo.pages.sites.create', [
|
||||
'siteModel' => $site,
|
||||
'logoModels' => $logoModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Sites\StoreSiteRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreSiteRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$site = new Site();
|
||||
$site->fill($request->safe()->except(['logos']));
|
||||
|
||||
if ($site->saveOrFail()) {
|
||||
/** @var array<int, array<string, mixed>> $logos */
|
||||
$logos = $request->validated('logos') ?? [];
|
||||
$site->logos()->attach(collect($logos)->pluck('id'));
|
||||
return redirect()->route('bo.sites.edit', $site)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Site $site): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$logoModels = Logo::all();
|
||||
|
||||
return view('bo.pages.sites.edit', [
|
||||
'siteModel' => $site,
|
||||
'logoModels' => $logoModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Sites\UpdateSiteRequest $request
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateSiteRequest $request, Site $site): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $site) {
|
||||
/** @var array<int, array<string, mixed>> $logos */
|
||||
$logos = $request->validated('logos') ?? [];
|
||||
$site->logos()->sync(collect($logos)->pluck('id'));
|
||||
$site->fill($request->safe()->except(['logos']));
|
||||
|
||||
if ($site->saveOrFail()) {
|
||||
return redirect()->route('bo.sites.edit', $site)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.sites.edit', $site)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Site $site): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($site) {
|
||||
$site->logos()->detach();
|
||||
|
||||
if ($site->deleteOrFail()) {
|
||||
return redirect()->route('bo.sites.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.site'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Site $site): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($site->replicate());
|
||||
}
|
||||
}
|
||||
159
app/Http/Controllers/Bo/SlideController.php
Normal file
159
app/Http/Controllers/Bo/SlideController.php
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Slides\StoreSlideRequest;
|
||||
use App\Http\Requests\Bo\Slides\UpdateSlideRequest;
|
||||
use App\Models\Slide;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SlideController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Slide::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Slide> $slideModels */
|
||||
$slideModels = Slide::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$slideModels,
|
||||
$search,
|
||||
null,
|
||||
'type',
|
||||
'title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.custom.slider')),
|
||||
trans('validation.attributes.title'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($slideModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$slideModels = $this->paginate($slideModels);
|
||||
|
||||
return view('bo.pages.slides.index', compact('slideModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Slide $slide
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Slide $slide): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.slides.create', ['slideModel' => $slide]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Slides\StoreSlideRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreSlideRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$slide = new Slide();
|
||||
|
||||
if ($slide->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.slides.edit', $slide)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Slide $slide
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Slide $slide): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.slides.edit', ['slideModel' => $slide]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Slides\UpdateSlideRequest $request
|
||||
* @param \App\Models\Slide $slide
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateSlideRequest $request, Slide $slide): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $slide) {
|
||||
if ($slide->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.slides.edit', $slide)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.slides.edit', $slide)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Slide $slide
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Slide $slide): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($slide->deleteOrFail()) {
|
||||
return redirect()->route('bo.slides.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.slide'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Slide $slide
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Slide $slide): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($slide->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -27,11 +27,11 @@ class StaticPageController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\StaticPage> $query */
|
||||
$query = StaticPage::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$query,
|
||||
|
|
@ -56,7 +56,7 @@ class StaticPageController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\StaticPage $static_page
|
||||
* @param \App\Models\StaticPage $static_page
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View
|
||||
|
|
@ -78,12 +78,12 @@ class StaticPageController extends Controller
|
|||
|
||||
if ($static_page->saveOrFail()) {
|
||||
return redirect()->route('bo.static_pages.edit', $static_page)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.static_pages.edit', $static_page)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
|
||||
]));
|
||||
});
|
||||
|
|
|
|||
157
app/Http/Controllers/Bo/StickyController.php
Normal file
157
app/Http/Controllers/Bo/StickyController.php
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Stickies\StoreStickyRequest;
|
||||
use App\Http\Requests\Bo\Stickies\UpdateStickyRequest;
|
||||
use App\Models\Sticky;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StickyController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Sticky::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Sticky> $stickyModels */
|
||||
$stickyModels = Sticky::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$stickyModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($stickyModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$stickyModels = $this->paginate($stickyModels);
|
||||
|
||||
return view('bo.pages.stickies.index', compact('stickyModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Sticky $sticky
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Sticky $sticky): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.stickies.create', ['stickyModel' => $sticky]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Stickies\StoreStickyRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreStickyRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$sticky = new Sticky();
|
||||
|
||||
if ($sticky->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.stickies.edit', $sticky)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Sticky $sticky
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Sticky $sticky): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.stickies.edit', ['stickyModel' => $sticky]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Stickies\UpdateStickyRequest $request
|
||||
* @param \App\Models\Sticky $sticky
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateStickyRequest $request, Sticky $sticky): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $sticky) {
|
||||
if ($sticky->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.stickies.edit', $sticky)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.stickies.edit', $sticky)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Sticky $sticky
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Sticky $sticky): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($sticky->deleteOrFail()) {
|
||||
return redirect()->route('bo.stickies.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.sticky', 0))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Sticky $sticky
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Sticky $sticky): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($sticky->replicate());
|
||||
}
|
||||
}
|
||||
187
app/Http/Controllers/Bo/StripController.php
Normal file
187
app/Http/Controllers/Bo/StripController.php
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Strips\StoreStripRequest;
|
||||
use App\Http\Requests\Bo\Strips\UpdateStripRequest;
|
||||
use App\Models\News;
|
||||
use App\Models\Strip;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StripController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Strip::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Strip> $stripModels */
|
||||
$stripModels = Strip::query()->with('news');
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$stripModels,
|
||||
$search,
|
||||
null,
|
||||
'text',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.content')),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($stripModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$stripModels = $this->paginate($stripModels);
|
||||
|
||||
return view('bo.pages.strips.index', compact('stripModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Strip $strip
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Strip $strip): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$newsModels = News::query()->where('published', true)->get();
|
||||
return view('bo.pages.strips.create', [
|
||||
'stripModel' => $strip,
|
||||
'newsModels' => $newsModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Strips\StoreStripRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreStripRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$strip = new Strip();
|
||||
$strip->fill($request->validated());
|
||||
if ($request->news_id === null) {
|
||||
$strip->news()->dissociate();
|
||||
}
|
||||
|
||||
if ($strip->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.strips.edit', $strip)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Strip $strip
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Strip $strip): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$newsModels = News::query()->where('published', true)->get();
|
||||
return view('bo.pages.strips.edit', [
|
||||
'stripModel' => $strip,
|
||||
'newsModels' => $newsModels
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Strips\UpdateStripRequest $request
|
||||
* @param \App\Models\Strip $strip
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateStripRequest $request, Strip $strip): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $strip) {
|
||||
$strip->fill($request->validated());
|
||||
if ($request->news_id === null) {
|
||||
$strip->news()->dissociate();
|
||||
}
|
||||
|
||||
if (!Arr::exists($request->validated(), 'picture')) {
|
||||
$strip->picture = null;
|
||||
$strip->picture_alt = null;
|
||||
$strip->picture_title = null;
|
||||
} elseif (!Arr::exists($request->validated(), 'picto')) {
|
||||
$strip->picto = null;
|
||||
}
|
||||
|
||||
if ($strip->saveOrFail()) {
|
||||
return redirect()->route('bo.strips.edit', $strip)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.strips.edit', $strip)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Strip $strip
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Strip $strip): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($strip->deleteOrFail()) {
|
||||
return redirect()->route('bo.strips.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.strip', 1))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Strip $strip
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Strip $strip): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($strip->replicate());
|
||||
}
|
||||
}
|
||||
165
app/Http/Controllers/Bo/TestimonialController.php
Normal file
165
app/Http/Controllers/Bo/TestimonialController.php
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest;
|
||||
use App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest;
|
||||
use App\Models\Testimonial;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TestimonialController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Testimonial::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Testimonial> $testimonialModels */
|
||||
$testimonialModels = Testimonial::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$testimonialModels,
|
||||
$search,
|
||||
null,
|
||||
'name',
|
||||
'job',
|
||||
'content',
|
||||
'type',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.name')),
|
||||
trans('validation.custom.job'),
|
||||
trans('validation.attributes.content'),
|
||||
trans('validation.custom.type'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($testimonialModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$testimonialModels = $this->paginate($testimonialModels);
|
||||
|
||||
return view('bo.pages.testimonials.index', compact('testimonialModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Testimonial $testimonial
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.testimonials.create', ['testimonialModel' => $testimonial]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreTestimonialRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$testimonial = new Testimonial();
|
||||
|
||||
if ($testimonial->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Testimonial $testimonial
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.testimonials.edit', ['testimonialModel' => $testimonial]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest $request
|
||||
* @param \App\Models\Testimonial $testimonial
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateTestimonialRequest $request,
|
||||
Testimonial $testimonial
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $testimonial) {
|
||||
if ($testimonial->fill($request->validated())->saveOrFail()) {
|
||||
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Testimonial $testimonial
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Testimonial $testimonial): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($testimonial->deleteOrFail()) {
|
||||
return redirect()->route('bo.testimonials.index')
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.testimonial'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Testimonial $testimonial
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($testimonial->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bo;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\UploadFileRequest;
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Section;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
|
|
@ -18,10 +18,19 @@ class UploadController extends Controller
|
|||
*/
|
||||
public function uploadFile(UploadFileRequest $request)
|
||||
{
|
||||
/** @var \Illuminate\Http\UploadedFile $image */
|
||||
$image = $request->upload;
|
||||
$modelClass = "App\\Models\\$request->folder";
|
||||
|
||||
$path = FileStorageHelper::storeFile(new Section(), $image, true);
|
||||
if (!class_exists($modelClass) && !is_subclass_of($modelClass, Model::class)) {
|
||||
return response()->json(['error' => 'Invalid model class'], 404);
|
||||
}
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Model $model */
|
||||
$model = new $modelClass();
|
||||
|
||||
/** @var \Illuminate\Http\UploadedFile $image */
|
||||
$image = $request->file('upload');
|
||||
|
||||
$path = FileStorageHelper::storeFile($model, $image, true);
|
||||
|
||||
return response()->json([
|
||||
'url' => "/{$path}"
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $userModels */
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\User> $userModels */
|
||||
$userModels = User::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
$search = $request->input('search');
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$userModels,
|
||||
|
|
@ -63,7 +63,6 @@ class UserController extends Controller
|
|||
return view('bo.pages.users.index', compact('userModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
|
@ -89,13 +88,13 @@ class UserController extends Controller
|
|||
|
||||
if ($user->saveOrFail()) {
|
||||
return redirect()->route('bo.users.edit', $user)
|
||||
->with('success', __('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
->with('success', trans('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
->with('error', trans('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
|
@ -103,7 +102,7 @@ class UserController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(User $user): \Illuminate\Contracts\View\View
|
||||
|
|
@ -125,13 +124,13 @@ class UserController extends Controller
|
|||
|
||||
if ($user->saveOrFail()) {
|
||||
return redirect()->route('bo.users.edit', $user)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
->with('success', trans('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.users.edit', $user)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
->with('error', trans('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
|
@ -144,15 +143,18 @@ class UserController extends Controller
|
|||
*/
|
||||
public function destroy(User $user): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
$previousQueries = [];
|
||||
\parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
|
||||
if ($user->deleteOrFail()) {
|
||||
return redirect()->route('bo.users.index')
|
||||
->with('success', __('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
return redirect()->route('bo.users.index', $previousQueries)
|
||||
->with('success', trans('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.user'))
|
||||
->with('error', trans('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans('models.classes.user'))
|
||||
]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,19 @@ class Controller extends BaseController
|
|||
* Build Search query on specified fields
|
||||
* splitting search into words or using whole sentence
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query The eloquent query builder.
|
||||
* @param string $search The query string.
|
||||
* @param callable $searchQuery The query string.
|
||||
* @param string ...$fields Either a simple array or a string
|
||||
* in case of a string the two fields
|
||||
* would be concatenate to make the search.
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query The eloquent query builder.
|
||||
* @param string $search The searched string.
|
||||
* @param callable|null $searchQuery The query string.
|
||||
* @param string ...$fields Either a simple array or a string
|
||||
* in case of a string the two fields
|
||||
* would be concatenate to make the search.
|
||||
* @return \Illuminate\Database\Eloquent\Builder<TModel>
|
||||
*/
|
||||
protected function searchQuery(
|
||||
Builder $query,
|
||||
string $search,
|
||||
callable $searchQuery = null,
|
||||
callable|null $searchQuery = null,
|
||||
string ...$fields
|
||||
): \Illuminate\Database\Eloquent\Builder {
|
||||
if (count($fields)) {
|
||||
|
|
@ -61,15 +62,16 @@ class Controller extends BaseController
|
|||
/**
|
||||
* Build query search on all fields
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $search
|
||||
* @param array $fields
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
|
||||
* @param string $search
|
||||
* @param array<int|string, string|array<int, string>> $fields
|
||||
* @return \Illuminate\Database\Eloquent\Builder<TModel>
|
||||
*/
|
||||
private function searchOnFields(
|
||||
Builder $query,
|
||||
string $search,
|
||||
array $fields
|
||||
array $fields,
|
||||
): \Illuminate\Database\Eloquent\Builder {
|
||||
$table = $query->getModel()->getTable();
|
||||
foreach ($fields as $field) {
|
||||
|
|
@ -94,7 +96,7 @@ class Controller extends BaseController
|
|||
return $query;
|
||||
}
|
||||
// Get models with relation's name/label.
|
||||
if (Str::endsWith($field, '_id') && $query->getModel()->has(Str::remove('_id', $field))) {
|
||||
if (Str::endsWith($field, '_id')) {
|
||||
$query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) {
|
||||
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
|
||||
$queryRelation->where('name', 'like', '%' . $search . '%');
|
||||
|
|
@ -115,21 +117,28 @@ class Controller extends BaseController
|
|||
/**
|
||||
* Get the search value (on string or Enum).
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $search
|
||||
* @param string $field
|
||||
* @return string|array
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
|
||||
* @param string $search
|
||||
* @param string $field
|
||||
* @return string|array<int, mixed>
|
||||
*/
|
||||
protected function getSearchValue(Builder $query, string $search, string $field): string|array
|
||||
{
|
||||
protected function getSearchValue(
|
||||
Builder $query,
|
||||
string $search,
|
||||
string $field,
|
||||
): string|array {
|
||||
$cast = $query->getModel()->getCasts()[$field] ?? null;
|
||||
if (
|
||||
count($query->getModel()->getCasts()) and // Check if the model has casts.
|
||||
isset($query->getModel()->getCasts()[$field]) and // Check if there is cast about specific field.
|
||||
enum_exists($query->getModel()->getCasts()[$field]) // Check if the cast is an enum.
|
||||
$cast and // Check if there is cast about specific field.
|
||||
enum_exists($cast) // Check if the cast is an enum.
|
||||
) {
|
||||
$cases = collect($query->getModel()->getCasts()[$field]::toArray());
|
||||
$enum = $cases->filter(function ($item) use ($search) {
|
||||
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
|
||||
/** @var \App\Traits\Enums $cast */
|
||||
// @phpstan-ignore-next-line
|
||||
$cases = collect($cast::toArray());
|
||||
$enum = $cases->filter(function ($item) use ($search): bool {
|
||||
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label)) === 1;
|
||||
});
|
||||
return $enum->toArray();
|
||||
} else {
|
||||
|
|
@ -140,20 +149,23 @@ class Controller extends BaseController
|
|||
/**
|
||||
* Sort columns with a query.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $ignore
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
|
||||
* @param array<int, string> $ignore
|
||||
* @return \Illuminate\Database\Eloquent\Builder<TModel>
|
||||
*/
|
||||
protected function sortQuery(Builder $query, array $ignore = []): \Illuminate\Database\Eloquent\Builder
|
||||
{
|
||||
protected function sortQuery(
|
||||
Builder $query,
|
||||
array $ignore = [],
|
||||
): \Illuminate\Database\Eloquent\Builder {
|
||||
$rName = request()->route()->getName();
|
||||
$table = $query->getModel()->getTable();
|
||||
if (request()->sort_col) {
|
||||
Session::put("$rName.sort_col", request()->sort_col);
|
||||
if (request()->input('sort_col')) {
|
||||
Session::put("$rName.sort_col", request()->input('sort_col'));
|
||||
Session::put("$rName.sorted", true);
|
||||
}
|
||||
if (request()->sort_way) {
|
||||
Session::put("$rName.sort_way", request()->sort_way);
|
||||
if (request()->input('sort_way')) {
|
||||
Session::put("$rName.sort_way", request()->input('sort_way'));
|
||||
Session::put("$rName.sorted", true);
|
||||
}
|
||||
if (request()->rst) {
|
||||
|
|
@ -161,12 +173,16 @@ class Controller extends BaseController
|
|||
Session::remove("$rName.sort_col");
|
||||
Session::remove("$rName.sort_way");
|
||||
}
|
||||
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
|
||||
if (
|
||||
!isset($ignore) or
|
||||
(isset($ignore) and !in_array(request()->sort_col, $ignore))
|
||||
) {
|
||||
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
|
||||
if (
|
||||
request()->input('sort_col') and
|
||||
request()->input('sort_way') and
|
||||
Schema::hasColumn($table, request()->input('sort_col'))
|
||||
) {
|
||||
if (!in_array(request()->input('sort_col'), $ignore)) {
|
||||
$query = $query->orderBy(
|
||||
\sprintf("$table.%s", request()->input('sort_col')),
|
||||
request()->input('sort_way')
|
||||
);
|
||||
}
|
||||
} elseif (Schema::hasColumn($table, 'order')) {
|
||||
$query = $query->orderBy('order', 'ASC');
|
||||
|
|
@ -187,13 +203,14 @@ class Controller extends BaseController
|
|||
/**
|
||||
* Customize pagination with cache or config (default).
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
|
||||
* @param \App\Enums\Pagination\ItemsPerPaginationEnum|null $pagination
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<TModel>
|
||||
*/
|
||||
protected function paginate(
|
||||
Builder $query,
|
||||
ItemsPerPaginationEnum $pagination = null
|
||||
ItemsPerPaginationEnum|null $pagination = null
|
||||
): \Illuminate\Contracts\Pagination\LengthAwarePaginator {
|
||||
$currentRoutePath = Str::slug(request()->route()->getName());
|
||||
$cacheKey = "pagination.{$currentRoutePath}";
|
||||
|
|
@ -201,7 +218,7 @@ class Controller extends BaseController
|
|||
$pagination = ToolboxHelper::getValidatedEnum(
|
||||
Cache::get($cacheKey, $pagination->value()),
|
||||
'pagination',
|
||||
'\App\Enums\Pagination\ItemsPerPaginationEnum',
|
||||
ItemsPerPaginationEnum::class,
|
||||
);
|
||||
if (Cache::get($cacheKey) !== $pagination) {
|
||||
Cache::put($cacheKey, $pagination);
|
||||
|
|
@ -221,7 +238,7 @@ class Controller extends BaseController
|
|||
$theme = ToolboxHelper::getValidatedEnum(
|
||||
$request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
|
||||
'theme',
|
||||
'\App\Http\Controllers\BootstrapThemeEnum',
|
||||
BootstrapThemeEnum::class,
|
||||
);
|
||||
if (Cache::get("theme") !== $theme) {
|
||||
Cache::put("theme", $theme);
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('fo.pages.home');
|
||||
}
|
||||
}
|
||||
31
app/Http/Controllers/Fo/NetworkController.php
Normal file
31
app/Http/Controllers/Fo/NetworkController.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Network;
|
||||
|
||||
class NetworkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Network $network
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(Network $network): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$network->load(['aisles', 'aisles.brands']);
|
||||
$networkModels = Network::query()
|
||||
->whereNot('id', $network->id)
|
||||
->where('published', true)
|
||||
->orderBy('order')
|
||||
->get();
|
||||
|
||||
return view('fo.pages.networks.show', [
|
||||
'networkModel' => $network,
|
||||
'networkModels' => $networkModels,
|
||||
]);
|
||||
}
|
||||
}
|
||||
66
app/Http/Controllers/Fo/NewsController.php
Normal file
66
app/Http/Controllers/Fo/NewsController.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Enums\Sections\PageSectionEnum;
|
||||
use App\Enums\StaticPageType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\News;
|
||||
use App\Models\Section;
|
||||
use App\Models\StaticPage;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_move)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
|
||||
$newsModels = News::query()
|
||||
->where('published', true)
|
||||
->orderBy('displayed_date', 'DESC')
|
||||
->simplePaginate(4)
|
||||
->fragment('corpo');
|
||||
$lifeSection = $sectionModels->where('section', PageSectionEnum::move_life)->first();
|
||||
$commitmentSection = $sectionModels->where('section', PageSectionEnum::move_commitments)->first();
|
||||
return view('fo.pages.news.index', \compact(
|
||||
'staticPageModel',
|
||||
'sectionModels',
|
||||
'newsModels',
|
||||
'lifeSection',
|
||||
'commitmentSection'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a news articles
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(News $news): \Illuminate\Contracts\View\View
|
||||
{
|
||||
// Get only id from published news.
|
||||
$publishedNews = News::query()->where('published', true)->orderBy('publish_at', 'DESC')->get()->pluck('id');
|
||||
// Search the position of the current news id.
|
||||
$positionId = \array_search($news->id, $publishedNews->toArray());
|
||||
// Check if it's the last position.
|
||||
$nextPositionId = ($positionId === count($publishedNews) - 1) ? 0 : intval($positionId) + 1;
|
||||
// Find the next news from the id.
|
||||
$nextNews = News::query()->where('id', $publishedNews[$nextPositionId])->firstOrFail();
|
||||
// Check if it's the first position.
|
||||
$prevPositionId = ($positionId === 0) ? count($publishedNews) - 1 : intval($positionId) - 1;
|
||||
// Find the next news from the id.
|
||||
$prevNews = News::query()->where('id', $publishedNews[$prevPositionId])->firstOrFail();
|
||||
|
||||
return view('fo.pages.news.show', [
|
||||
'news' => $news,
|
||||
'nextNews' => $nextNews,
|
||||
'prevNews' => $prevNews,
|
||||
]);
|
||||
}
|
||||
}
|
||||
351
app/Http/Controllers/Fo/StaticPageController.php
Normal file
351
app/Http/Controllers/Fo/StaticPageController.php
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Enums\Listen\ObjectEnum;
|
||||
use App\Enums\Sections\PageSectionEnum;
|
||||
use App\Enums\Slides\SliderTypeEnum;
|
||||
use App\Enums\StaticPageType;
|
||||
use App\Enums\StickiesColorEnum;
|
||||
use App\Enums\Testimonials\TypeEnum;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Fo\ListenFormRequest;
|
||||
use App\Mail\SendConfirmationMail;
|
||||
use App\Mail\SendContactMail;
|
||||
use App\Models\Carousel;
|
||||
use App\Models\HistoricalMilestone;
|
||||
use App\Models\JobVideo;
|
||||
use App\Models\Network;
|
||||
use App\Models\News;
|
||||
use App\Models\Section;
|
||||
use App\Models\Site;
|
||||
use App\Models\Slide;
|
||||
use App\Models\StaticPage;
|
||||
use App\Models\Sticky;
|
||||
use App\Models\Strip;
|
||||
use App\Models\Testimonial;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StaticPageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
|
||||
$stripModels = Strip::query()
|
||||
->where('published', true)
|
||||
->orderBy('publish_at', 'DESC')
|
||||
->limit(6)
|
||||
->with('news')
|
||||
->whereHas('news', function (Builder $query) {
|
||||
$query->where('published', true);
|
||||
})
|
||||
->get();
|
||||
$newsModels = News::query()
|
||||
->where('published', true)
|
||||
->orderBy('displayed_date', 'DESC')
|
||||
->limit(4)
|
||||
->get();
|
||||
$slideModels = Slide::query()->where('type', SliderTypeEnum::home)->get();
|
||||
$missionSection = $sectionModels->where('section', PageSectionEnum::home_missions)->first();
|
||||
$ambitionSection = $sectionModels->where('section', PageSectionEnum::home_ambition)->first();
|
||||
$teamSection = $sectionModels->where('section', PageSectionEnum::home_team)->first();
|
||||
$lifeSection = $sectionModels->where('section', PageSectionEnum::home_life)->first();
|
||||
$slideTeams = Slide::query()->where('type', SliderTypeEnum::team)->get();
|
||||
|
||||
return view('fo.pages.home', compact(
|
||||
'staticPageModel',
|
||||
'sectionModels',
|
||||
'stripModels',
|
||||
'newsModels',
|
||||
'slideModels',
|
||||
'missionSection',
|
||||
'ambitionSection',
|
||||
'teamSection',
|
||||
'lifeSection',
|
||||
'slideTeams',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'unveil' page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function unveil(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::unveil)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->getKey())->get();
|
||||
$historicalMilestoneModels = HistoricalMilestone::query()->orderBy('year', 'ASC')->get();
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Site> */
|
||||
$siteModelList = Site::query()->orderBy('order')->get();
|
||||
$keySection = $sectionModels->where('section', PageSectionEnum::unveil_pole)->first();
|
||||
$missionsSection = $sectionModels->where('section', PageSectionEnum::unveil_missions)->first();
|
||||
$localSection = $sectionModels->where('section', PageSectionEnum::unveil_local)->first();
|
||||
$siteSection = $sectionModels->where('section', PageSectionEnum::unveil_sites)->first();
|
||||
$historySection = $sectionModels->where('section', PageSectionEnum::unveil_history)->first();
|
||||
$commitmentSection = $sectionModels->where('section', PageSectionEnum::unveil_commitments)->first();
|
||||
$navLinks = Sticky::query()->where('type', StaticPageType::unveil)->get();
|
||||
|
||||
$viewBox = null;
|
||||
$initialZoom = null;
|
||||
// * Calcul Viewbox leaflet map ().
|
||||
// Carte page “on se dévoile” : Point central = Laval + rayon = 100 km
|
||||
/** @var \App\Models\Site|null $lavalSite */
|
||||
$lavalSite = $siteModelList->first(fn(Site $site) => Str::contains($site->name, 'Laval'));
|
||||
if ($lavalSite) {
|
||||
$viewBox = (object) [
|
||||
'lat' => $lavalSite->latitude,
|
||||
'lng' => $lavalSite->longitude
|
||||
];
|
||||
$initialZoom = 9;
|
||||
}
|
||||
|
||||
return view('fo.pages.unveil', compact(
|
||||
'viewBox',
|
||||
'initialZoom',
|
||||
'staticPageModel',
|
||||
'sectionModels',
|
||||
'historicalMilestoneModels',
|
||||
'siteModelList',
|
||||
'keySection',
|
||||
'missionsSection',
|
||||
'localSection',
|
||||
'siteSection',
|
||||
'historySection',
|
||||
'commitmentSection',
|
||||
'navLinks'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'commitments' page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function commit(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_commit)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
|
||||
$slideLifeModels = Slide::query()->where('type', SliderTypeEnum::better_life)->latest()->get();
|
||||
$slideEarthModels = Slide::query()->where('type', SliderTypeEnum::respect_earth)->latest()->get();
|
||||
$testimonialModels = Testimonial::query()
|
||||
->whereIn('type', [
|
||||
TypeEnum::breeding->value,
|
||||
TypeEnum::better_life->value,
|
||||
TypeEnum::respect_earth->value,
|
||||
TypeEnum::feed->value,
|
||||
TypeEnum::volena->value,
|
||||
])->get();
|
||||
$ambitionSection = $sectionModels->where('section', PageSectionEnum::commit_ambition)->first();
|
||||
$breedingSection = $sectionModels->where('section', PageSectionEnum::commit_breeding)->first();
|
||||
$lifeSection = $sectionModels->where('section', PageSectionEnum::commit_living)->first();
|
||||
$earthSection = $sectionModels->where('section', PageSectionEnum::commit_respect_earth)->first();
|
||||
$feedSection = $sectionModels->where('section', PageSectionEnum::commit_feed)->first();
|
||||
$testimonialsSection = $sectionModels->where('section', PageSectionEnum::commit_commitments)->first();
|
||||
|
||||
$navLinks = Sticky::query()->where('type', StaticPageType::we_commit)->get();
|
||||
|
||||
return view('fo.pages.commitments', compact(
|
||||
'staticPageModel',
|
||||
'sectionModels',
|
||||
'slideLifeModels',
|
||||
'slideEarthModels',
|
||||
'testimonialModels',
|
||||
'ambitionSection',
|
||||
'breedingSection',
|
||||
'lifeSection',
|
||||
'earthSection',
|
||||
'feedSection',
|
||||
'testimonialsSection',
|
||||
'navLinks',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'legals' page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function legals(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::legals)->first();
|
||||
|
||||
return view('fo.pages.legals', compact(
|
||||
'staticPageModel',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'confidentiality' page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function confidentiality(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::confidentiality)->first();
|
||||
|
||||
return view('fo.pages.legals', compact(
|
||||
'staticPageModel',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'we_produce' page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function produce(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
// MODELS.
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_produce)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
|
||||
$networkModels = Network::query()->where('published', true)->orderBy('order')->get();
|
||||
|
||||
// SECTIONS.
|
||||
$localSection = $sectionModels->where('section', PageSectionEnum::produce_local)->first();
|
||||
$gmsSection = $sectionModels->where('section', PageSectionEnum::produce_gms)->first();
|
||||
$rhdSection = $sectionModels->where('section', PageSectionEnum::produce_rhd)->first();
|
||||
$exportSection = $sectionModels->where('section', PageSectionEnum::produce_export)->first();
|
||||
$qualitySection = $sectionModels->where('section', PageSectionEnum::produce_quality)->first();
|
||||
$networkSection = $sectionModels->where('section', PageSectionEnum::produce_networks)->first();
|
||||
|
||||
return view('fo.pages.produce.show', compact(
|
||||
'staticPageModel',
|
||||
'networkModels',
|
||||
'localSection',
|
||||
'gmsSection',
|
||||
'rhdSection',
|
||||
'exportSection',
|
||||
'qualitySection',
|
||||
'networkSection',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the 'we_listen' page.
|
||||
* This page is used to send a contact form.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function listen(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_listen)->first();
|
||||
$sectionModel = Section::query()->where('page_id', $staticPageModel->id)->first();
|
||||
|
||||
return view('fo.pages.listen', compact(
|
||||
'staticPageModel',
|
||||
'sectionModel',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send listen form data.
|
||||
*
|
||||
* @param \App\Http\Requests\Fo\ListenFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function listenForm(ListenFormRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
Mail::to(config('mail.contact.' . ObjectEnum::make(intval($request->validated()['object']))->name()))
|
||||
->send(new SendContactMail((object) $request->validated()));
|
||||
Mail::to($request->validated()['email'])->send(new SendConfirmationMail((object) $request->validated()));
|
||||
|
||||
return redirect()->route('fo.listen.show')
|
||||
->with('success', trans(
|
||||
'Bonjour, votre message a bien été transmis, nous vous en remercions. Cordialement, l’équipe :appName.',
|
||||
['appName' => config('app.name')]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function hire(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_hire)->first();
|
||||
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
|
||||
$videoModels = JobVideo::query()->inRandomOrder()->simplePaginate(4);
|
||||
$testimonialModels = Testimonial::query()->where('type', TypeEnum::hire)->get();
|
||||
$compagnyLifeSection = $sectionModels->where('section', PageSectionEnum::hire_life)->first();
|
||||
$formationSection = $sectionModels->where('section', PageSectionEnum::hire_formation)->first();
|
||||
$testimonialSection = $sectionModels->where('section', PageSectionEnum::hire_grow)->first();
|
||||
$paritySection = $sectionModels->where('section', PageSectionEnum::hire_parity)->first();
|
||||
$findSection = $sectionModels->where('section', PageSectionEnum::hire_find)->first();
|
||||
$carouselSectionParity = Carousel::query()
|
||||
->where('section_id', PageSectionEnum::hire_parity)
|
||||
->where('published', true)
|
||||
->orderBy('order')
|
||||
->get();
|
||||
$navLinks = Sticky::query()->where('type', StaticPageType::we_hire)->get();
|
||||
|
||||
return view('fo.pages.hire', \compact(
|
||||
'staticPageModel',
|
||||
'sectionModels',
|
||||
'videoModels',
|
||||
'testimonialModels',
|
||||
'compagnyLifeSection',
|
||||
'formationSection',
|
||||
'testimonialSection',
|
||||
'paritySection',
|
||||
'findSection',
|
||||
'carouselSectionParity',
|
||||
'navLinks'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \App\Models\Site $site
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function site(Site $site): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Site> */
|
||||
$siteModels = Site::query()->orderBy('order')->get();
|
||||
$siteModelList = $siteModels->keyBy('order');
|
||||
|
||||
$nextSiteModel = $siteModelList->where(
|
||||
'order',
|
||||
'>',
|
||||
$site->order
|
||||
)->first();
|
||||
if ($siteModelList->last()->is($site)) {
|
||||
$nextSiteModel = $siteModelList->first();
|
||||
}
|
||||
|
||||
$viewBox = (object) [
|
||||
'lat' => $site->latitude,
|
||||
'lng' => $site->longitude
|
||||
];
|
||||
$initialZoom = 10;
|
||||
|
||||
// Create datas similar to Sticky model.
|
||||
$navLinks = collect([
|
||||
(object) [
|
||||
'title' => $site->sticky_title,
|
||||
'anchor' => $site->sticky_link,
|
||||
'color' => StickiesColorEnum::quad,
|
||||
],
|
||||
]);
|
||||
|
||||
return view('fo.pages.site', [
|
||||
'siteModelList' => $siteModelList,
|
||||
'siteModel' => $site,
|
||||
'nextSiteModel' => $nextSiteModel,
|
||||
'viewBox' => $viewBox,
|
||||
'initialZoom' => $initialZoom,
|
||||
'navLinks' => $navLinks,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,11 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\SecureHeaders::class
|
||||
],
|
||||
|
||||
'saml' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
],
|
||||
'api' => [
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
@ -54,16 +58,16 @@ class Kernel extends HttpKernel
|
|||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Middleware;
|
|||
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HtmlSanitizer
|
||||
{
|
||||
|
|
@ -13,11 +12,14 @@ class HtmlSanitizer
|
|||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|array ...$params
|
||||
* @param string|array<int, mixed> ...$params
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next, string|array ...$params): Response
|
||||
{
|
||||
public function handle(
|
||||
Request $request,
|
||||
\Closure $next,
|
||||
string|array ...$params
|
||||
): \Symfony\Component\HttpFoundation\Response {
|
||||
$inputs = $request->all();
|
||||
/** @var callable|null */
|
||||
$cleanInput = null;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
|
|
@ -17,7 +16,7 @@ class RedirectIfAuthenticated
|
|||
* @throws \RuntimeException If guard is unhandled.
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next, ...$guards): Response
|
||||
public function handle(Request $request, \Closure $next, ...$guards): \Symfony\Component\HttpFoundation\Response
|
||||
{
|
||||
// phpcs:enable phpcs:disable
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
|
@ -26,10 +25,10 @@ class RedirectIfAuthenticated
|
|||
if (auth($guard)->check()) {
|
||||
switch ($guard) {
|
||||
case 'frontend':
|
||||
return \redirect()->route('fo.homepage');
|
||||
return \redirect()->route('fo.home.show');
|
||||
case 'backend':
|
||||
if (!$request->routeIs('bo.*')) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
return \redirect()->route('bo.dashboard');
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SecureHeaders
|
||||
{
|
||||
|
|
@ -16,7 +15,7 @@ class SecureHeaders
|
|||
* Great starting point would be to go check out @Scott_Helme's:
|
||||
* https://securityheaders.com/
|
||||
*
|
||||
* @var array
|
||||
* @var list<string>
|
||||
*/
|
||||
private $unwantedHeaderList = [
|
||||
'X-Powered-By',
|
||||
|
|
@ -31,7 +30,7 @@ class SecureHeaders
|
|||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
public function handle(Request $request, Closure $next): \Symfony\Component\HttpFoundation\Response
|
||||
{
|
||||
// phpcs:enable
|
||||
// * For Vite DEV
|
||||
|
|
@ -53,18 +52,26 @@ class SecureHeaders
|
|||
"default-src 'none';",
|
||||
"manifest-src 'self';",
|
||||
// * CKEDITOR Specific https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html
|
||||
"connect-src 'self' " . implode(' ', [
|
||||
"connect-src 'self' blob: " . implode(' ', [
|
||||
// * VITE DEV
|
||||
config('app.debug') ? "wss://{$host}:4443" : '',
|
||||
config('app.debug') ? "https://{$host}:4443" : '',
|
||||
'https://yl.s-web.fr'
|
||||
]) . ';',
|
||||
"img-src * data: blob:;",
|
||||
'frame-src ' . implode(' ', [
|
||||
'\'self\'',
|
||||
"img-src 'self' data: blob: " . implode(' ', [
|
||||
// * Leaftlet With OpenStreetmaps
|
||||
'https://tile.openstreetmap.org',
|
||||
// * Youtube thumbnails
|
||||
'https://img.youtube.com/vi/',
|
||||
// * VITE DEV
|
||||
config('app.debug') ? "https://{$host}:4443" : '',
|
||||
]) . ';',
|
||||
"object-src 'self' " . implode(' ', []) . ';',
|
||||
"frame-src 'self' " . implode(' ', [
|
||||
'https://www.google.com/recaptcha/',
|
||||
'https://recaptcha.google.com/recaptcha/',
|
||||
'https://www.google.com/maps/',
|
||||
'https://www.youtube.com',
|
||||
'https://www.youtube-nocookie.com/embed/',
|
||||
]) . ';',
|
||||
"font-src 'self' data: " . \implode(' ', [
|
||||
// * VITE DEV
|
||||
|
|
@ -105,9 +112,9 @@ class SecureHeaders
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove unwanted headers
|
||||
* Remove unwanted headers.
|
||||
*
|
||||
* @param array $headerList
|
||||
* @param list<string> $headerList
|
||||
* @return void
|
||||
*/
|
||||
private function removeUnwantedHeaders(array $headerList): void
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class TrustHosts extends Middleware
|
|||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ class TrustProxies extends Middleware
|
|||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* ! Added * as tmp Fix for #13
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
protected $proxies = '*';
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
|
|
@ -20,7 +22,7 @@ class TrustProxies extends Middleware
|
|||
* @var integer
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
|
|
|
|||
61
app/Http/Requests/Bo/Aisles/StoreAisleRequest.php
Normal file
61
app/Http/Requests/Bo/Aisles/StoreAisleRequest.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Aisles;
|
||||
|
||||
use App\Rules\WysiwygLength;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreAisleRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|between:3,255',
|
||||
'title' => 'required|string|between:3,255',
|
||||
'text' => [
|
||||
'required',
|
||||
'string',
|
||||
new WysiwygLength(3, 500),
|
||||
],
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'network_id' => 'required|exists:networks,id',
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 1400, 450, 1400, 450, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Aisles/UpdateAisleRequest.php
Normal file
7
app/Http/Requests/Bo/Aisles/UpdateAisleRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Aisles;
|
||||
|
||||
class UpdateAisleRequest extends StoreAisleRequest
|
||||
{
|
||||
}
|
||||
61
app/Http/Requests/Bo/Brands/StoreBrandRequest.php
Normal file
61
app/Http/Requests/Bo/Brands/StoreBrandRequest.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Brands;
|
||||
|
||||
use App\Rules\WysiwygLength;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreBrandRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|between:3,255',
|
||||
'text' => [
|
||||
'required',
|
||||
'string',
|
||||
new WysiwygLength(3, 500),
|
||||
],
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'link' => 'nullable|url:https',
|
||||
'aisle_id' => 'required|exists:aisles,id',
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 250, 250, 250, 250, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Brands/UpdateBrandRequest.php
Normal file
7
app/Http/Requests/Bo/Brands/UpdateBrandRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Brands;
|
||||
|
||||
class UpdateBrandRequest extends StoreBrandRequest
|
||||
{
|
||||
}
|
||||
127
app/Http/Requests/Bo/Carousels/StoreCarouselRequest.php
Normal file
127
app/Http/Requests/Bo/Carousels/StoreCarouselRequest.php
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Carousels;
|
||||
|
||||
use App\Models\Section;
|
||||
use App\Rules\IsMaxChildrenReached;
|
||||
use App\Rules\WysiwygLength;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreCarouselRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->input('media.pictures')) {
|
||||
foreach ($this->input('media.pictures') as $index => $pictureArray) {
|
||||
$this->mergePicture("media.pictures.$index.path");
|
||||
}
|
||||
}
|
||||
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => 'required|string|between:3,255',
|
||||
'section_id' => [
|
||||
'required',
|
||||
Rule::exists('sections', 'id'),
|
||||
new IsMaxChildrenReached(new Section(), 'carousels', 5)
|
||||
],
|
||||
'media' => 'required|array',
|
||||
'media.pictures.*.alt' => 'sometimes|string|between:3,255',
|
||||
'media.pictures.*.title' => 'sometimes|string|between:3,255',
|
||||
'media.pictures.*.legend' => [
|
||||
'sometimes',
|
||||
'string',
|
||||
new WysiwygLength(3, 255),
|
||||
],
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
if ($this->input('media')) {
|
||||
if (Arr::exists($this->input('media'), 'pictures')) {
|
||||
foreach ($this->input('media')['pictures'] as $pictureIndex => $pictureArray) {
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
[
|
||||
"media.pictures.$pictureIndex.alt" => 'required|string|between:3,255',
|
||||
"media.pictures.$pictureIndex.title" => 'required|string|between:3,255',
|
||||
"media.pictures.$pictureIndex.legend" => [
|
||||
'sometimes',
|
||||
'string',
|
||||
new WysiwygLength(3, 255),
|
||||
],
|
||||
],
|
||||
$this->pictureRules("media.pictures.$pictureIndex.path", 500, 500, 500, 500, false),
|
||||
);
|
||||
}
|
||||
} //end if
|
||||
} //end if
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
$attributes = [
|
||||
'title' => trans('validation.attributes.title'),
|
||||
];
|
||||
if ($this->input('media') && array_key_exists('pictures', $this->input('media'))) {
|
||||
foreach ($this->input('media.pictures') as $index => $pictureArray) {
|
||||
$attributes = array_merge(
|
||||
$attributes,
|
||||
[
|
||||
"media.pictures.$index.alt" => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1),
|
||||
]),
|
||||
"media.pictures.$index.title" => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1),
|
||||
]),
|
||||
"media.pictures.$index.legend" => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.legend'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1),
|
||||
]),
|
||||
],
|
||||
);
|
||||
} //end foreach
|
||||
} //end if
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Carousels/UpdateCarouselRequest.php
Normal file
7
app/Http/Requests/Bo/Carousels/UpdateCarouselRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Carousels;
|
||||
|
||||
class UpdateCarouselRequest extends StoreCarouselRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\HistoricalMilestones;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreHistoricalMilestoneRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'button_status' => $this->boolean('button_status'),
|
||||
'button_new_tab' => $this->boolean('button_new_tab')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'year' => 'required|integer|min:1900|max:2100',
|
||||
'title' => 'required|string|between:3,255',
|
||||
'text' => 'required|string|between:3,255',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'button_label' => 'required_if:button_status,true|nullable|string|between:3,35',
|
||||
'button_url' => 'required_if:button_status,true|nullable|string|between:3,255',
|
||||
'button_status' => 'required|boolean',
|
||||
'button_new_tab' => 'required|boolean',
|
||||
];
|
||||
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 606, 800, 606, 800, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'year' => trans('validation.attributes.year'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'text' => trans('validation.custom.text'),
|
||||
'picture_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
'picture_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
'button_label' => trans('validation.custom.button_label'),
|
||||
'button_url' => trans('validation.custom.button_url'),
|
||||
'button_status' => trans('validation.custom.button_status'),
|
||||
'button_new_tab' => trans('validation.custom.button_new_tab'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\HistoricalMilestones;
|
||||
|
||||
class UpdateHistoricalMilestoneRequest extends StoreHistoricalMilestoneRequest
|
||||
{
|
||||
}
|
||||
49
app/Http/Requests/Bo/JobVideos/StoreJobVideoRequest.php
Normal file
49
app/Http/Requests/Bo/JobVideos/StoreJobVideoRequest.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\JobVideos;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreJobVideoRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|between:3,255',
|
||||
'place' => 'required|string|between:3,255',
|
||||
'video_id' => 'required|string|regex:%([^"&?\/\s]{11})%i',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'place' => trans('validation.custom.place'),
|
||||
'video_id' => trans('validation.custom.video_id'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/JobVideos/UpdateJobVideoRequest.php
Normal file
7
app/Http/Requests/Bo/JobVideos/UpdateJobVideoRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\JobVideos;
|
||||
|
||||
class UpdateJobVideoRequest extends StoreJobVideoRequest
|
||||
{
|
||||
}
|
||||
71
app/Http/Requests/Bo/Logos/StoreLogoRequest.php
Normal file
71
app/Http/Requests/Bo/Logos/StoreLogoRequest.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Logos;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreLogoRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'label' => 'required|string|between:3,255',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 450, 450, 450, 450, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'picture_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
'picture_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Logos/UpdateLogoRequest.php
Normal file
7
app/Http/Requests/Bo/Logos/UpdateLogoRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Logos;
|
||||
|
||||
class UpdateLogoRequest extends StoreLogoRequest
|
||||
{
|
||||
}
|
||||
59
app/Http/Requests/Bo/Networks/StoreNetworkRequest.php
Normal file
59
app/Http/Requests/Bo/Networks/StoreNetworkRequest.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Networks;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreNetworkRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'seo_title' => 'required|string|between:45,70',
|
||||
'seo_description' => 'required|string|between:50,160',
|
||||
'name' => 'required|string|between:3,255',
|
||||
'title' => 'required|string|between:3,255',
|
||||
'subtitle' => 'required|string|between:3,255',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'button_text' => 'required|string|between:3,255',
|
||||
'published' => 'required|boolean',
|
||||
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 1920, 1080, 1920, 1080, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Networks/UpdateNetworkRequest.php
Normal file
7
app/Http/Requests/Bo/Networks/UpdateNetworkRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Networks;
|
||||
|
||||
class UpdateNetworkRequest extends StoreNetworkRequest
|
||||
{
|
||||
}
|
||||
91
app/Http/Requests/Bo/News/StoreNewsRequest.php
Normal file
91
app/Http/Requests/Bo/News/StoreNewsRequest.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\News;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreNewsRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
$this->mergePicture('thumbnail');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'seo_title' => 'required|between:45,70',
|
||||
'seo_description' => 'required|between:50,160',
|
||||
'title' => 'required|string|between:3,100',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'thumbnail_alt' => 'required|string|between:3,255',
|
||||
'thumbnail_title' => 'required|string|between:3,255',
|
||||
'introduction' => 'required|string|min:15',
|
||||
'content' => 'nullable|string|min:15',
|
||||
'linkedin_url' => 'nullable|url',
|
||||
'published' => 'required|boolean',
|
||||
'publish_at' => 'nullable|date',
|
||||
'displayed_date' => 'required|date',
|
||||
'unpublish_at' => 'nullable|date|after:publish_at',
|
||||
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 500, 390, 500, 390, true),
|
||||
$this->pictureRules('thumbnail', 660, 440, 660, 440, true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => trans('validation.custom.seo_title'),
|
||||
'seo_description' => trans('validation.custom.seo_description'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'introduction' => trans('validation.attributes.content'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
'linkedin_url' => trans('validation.attributes.content'),
|
||||
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||
'picture_title' => trans('validation.custom.picture_title'),
|
||||
'thumbnail_alt' => trans('validation.custom.thumbnail_alt'),
|
||||
'thumbnail_title' => trans('validation.custom.thumbnail_title'),
|
||||
'published' => trans('validation.custom.activated'),
|
||||
'publish_at' => trans('validation.custom.publish_at'),
|
||||
'unpublish_at' => trans('validation.custom.unpublish_at'),
|
||||
'displayed_date' => trans('validation.custom.displayed_date'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/News/UpdateNewsRequest.php
Normal file
7
app/Http/Requests/Bo/News/UpdateNewsRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\News;
|
||||
|
||||
class UpdateNewsRequest extends StoreNewsRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -33,36 +33,37 @@ class UpdateSectionRequest extends UpdateMiniCrudRequest
|
|||
$rules = [
|
||||
'h2_title' => 'required|between:3,255',
|
||||
];
|
||||
if ($this->route('section')->section !== \app\Enums\Sections\PageSectionEnum::hire_grow) {
|
||||
$rules = \array_merge($rules, [
|
||||
'text' => 'present',
|
||||
]);
|
||||
/** @var \App\Models\Section|null $section */
|
||||
$section = $this->route('section');
|
||||
if ($section) {
|
||||
if (
|
||||
$section->section !== \App\Enums\Sections\PageSectionEnum::hire_grow
|
||||
) {
|
||||
$rules = \array_merge($rules, [
|
||||
'text' => 'present',
|
||||
]);
|
||||
}
|
||||
if ($section->section->containsData()) {
|
||||
$rules = \array_merge($rules, [
|
||||
'data' => 'present|array',
|
||||
'data.*' => 'required|array',
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($this->route('section')->section->containsData()) {
|
||||
$rules = \array_merge($rules, [
|
||||
'data' => 'present|array',
|
||||
'data.*' => 'required|array',
|
||||
]);
|
||||
}
|
||||
|
||||
return \array_merge(
|
||||
parent::rules(),
|
||||
$rules
|
||||
);
|
||||
return \array_merge(parent::rules(), $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'h2_title' => __('validation.custom.h2_title'),
|
||||
'text' => __('validation.attributes.content'),
|
||||
|
||||
'data' => trans('Valeurs du contenu spécifique'),
|
||||
'h2_title' => trans('validation.custom.h2_title'),
|
||||
'text' => trans('validation.attributes.content'),
|
||||
'data' => trans('Valeurs du contenu spécifique'),
|
||||
'data.*.value' => trans('Valeur du contenu spécifique'),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
171
app/Http/Requests/Bo/Sites/StoreSiteRequest.php
Normal file
171
app/Http/Requests/Bo/Sites/StoreSiteRequest.php
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Sites;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StoreSiteRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
/** @var array<int, mixed> $pictos */
|
||||
$pictos = $this->input('pictos') ?? [];
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published'),
|
||||
'invert_director_block' => $this->boolean('invert_director_block'),
|
||||
'pictos' => \collect($pictos)->all(),
|
||||
]);
|
||||
$this->mergePicture('logo');
|
||||
$this->mergePicture('picture_1');
|
||||
$this->mergePicture('picture_2');
|
||||
$this->mergePicture('picture_3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'seo_title' => 'required|between:45,70',
|
||||
'seo_description' => 'required|between:50,160',
|
||||
'name' => 'required|string|between:3,100',
|
||||
'description' => 'required|string|between:3,255',
|
||||
'description_2' => 'nullable|string|between:3,255',
|
||||
'employees' => 'required|numeric|min:0',
|
||||
'pictos' => 'present|array',
|
||||
'pictos.*' => 'required|integer',
|
||||
'address' => 'required|string|between:3,255',
|
||||
'phone_number' => 'required|string|between:10,20',
|
||||
'access_line' => 'present|array',
|
||||
'access_line.*' => 'nullable|string|between:3,255',
|
||||
'director_name' => 'required|string|between:3,255',
|
||||
'director_function' => 'required|string|between:3,255',
|
||||
'director_speach' => 'required|string|min:15',
|
||||
'invert_director_block' => 'required|boolean',
|
||||
'employee_name' => 'nullable|string|between:3,255',
|
||||
'employee_function' => 'nullable|string|between:3,255',
|
||||
'employee_speach' => 'nullable|string|min:15',
|
||||
'highlights' => 'nullable|string|min:15',
|
||||
'latitude' => 'required|numeric|between:-90,90',
|
||||
'longitude' => 'required|numeric|between:-180,180',
|
||||
'sticky_title' => 'required_with:sticky_link|nullable|string|between:3,255',
|
||||
'sticky_link' => 'required_with:sticky_title|nullable|string|between:3,255',
|
||||
'logo_alt' => 'required|string|between:3,255',
|
||||
'logo_title' => 'required|string|between:3,255',
|
||||
'picture_1_alt' => 'required|string|between:3,255',
|
||||
'picture_1_title' => 'required|string|between:3,255',
|
||||
'picture_2_alt' => 'required_with:picture_2|nullable|string|between:3,255',
|
||||
'picture_2_title' => 'required_with:picture_2|nullable|string|between:3,255',
|
||||
'picture_3_alt' => 'required_with:picture_3|nullable|string|between:3,255',
|
||||
'picture_3_title' => 'required_with:picture_3|nullable|string|between:3,255',
|
||||
'logos' => 'nullable|array',
|
||||
'logos.*.id' => 'required|exists:logos,id',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('logo', 1000, 727, 1000, 727, false),
|
||||
$this->pictureRules('picture_1', 1000, 562, 1000, 562, false),
|
||||
$this->pictureRules('picture_2', 1000, 562, 1000, 562, true),
|
||||
$this->pictureRules('picture_3', 1000, 562, 1000, 562, true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => trans('validation.custom.seo_title'),
|
||||
'seo_description' => trans('validation.custom.seo_description'),
|
||||
'name' => trans('validation.attributes.name'),
|
||||
'description' => trans('validation.custom.description'),
|
||||
'description_2' => trans('validation.custom.description_2'),
|
||||
'employees' => trans('validation.custom.employees_count'),
|
||||
'pictos' => Str::plural(trans('validation.custom.picto')),
|
||||
'pictos.*' => trans('validation.custom.picto'),
|
||||
'address' => trans('validation.attributes.address'),
|
||||
'phone_number' => trans('validation.attributes.phone'),
|
||||
'access_line' => trans('validation.custom.access_line'),
|
||||
'access_line.*' => trans('ligne d\'accès au site'),
|
||||
'director_name' => trans('validation.custom.director_name'),
|
||||
'director_function' => trans('validation.custom.director_function'),
|
||||
'director_speach' => trans('validation.custom.director_speach'),
|
||||
'invert_director_block' => trans('validation.custom.invert_block'),
|
||||
'employee_name' => trans('validation.custom.employee_name'),
|
||||
'employee_function' => trans('validation.custom.employee_function'),
|
||||
'employee_speach' => trans('validation.custom.employee_speach'),
|
||||
'highlights' => Str::plural(trans('validation.custom.highlight')),
|
||||
'latitude' => trans('validation.custom.latitude'),
|
||||
'longitude' => trans('validation.custom.longitude'),
|
||||
'sticky_title' => trans('validation.custom.sticky_item.title'),
|
||||
'sticky_link' => trans('validation.custom.sticky_item.link'),
|
||||
'logos' => Str::plural(trans('models.classes.logo')),
|
||||
'logos.*' => trans('models.classes.logo'),
|
||||
'logo_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.male'),
|
||||
'model' => trans('validation.custom.logo'),
|
||||
]),
|
||||
'logo_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.male'),
|
||||
'model' => trans('validation.custom.logo'),
|
||||
]),
|
||||
'picture_1_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_1'),
|
||||
]),
|
||||
'picture_1_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_1'),
|
||||
]),
|
||||
'picture_2_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_2'),
|
||||
]),
|
||||
'picture_2_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_2'),
|
||||
]),
|
||||
'picture_3_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_3'),
|
||||
]),
|
||||
'picture_3_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture_3'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Sites/UpdateSiteRequest.php
Normal file
7
app/Http/Requests/Bo/Sites/UpdateSiteRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Sites;
|
||||
|
||||
class UpdateSiteRequest extends StoreSiteRequest
|
||||
{
|
||||
}
|
||||
140
app/Http/Requests/Bo/Slides/StoreSlideRequest.php
Normal file
140
app/Http/Requests/Bo/Slides/StoreSlideRequest.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Slides;
|
||||
|
||||
use App\Enums\Slides\SliderTypeEnum;
|
||||
use App\Rules\WysiwygLength;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreSlideRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'button_status' => $this->boolean('button_status'),
|
||||
'button_new_tab' => $this->boolean('button_new_tab'),
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'type' => [
|
||||
'required',
|
||||
new Enum(SliderTypeEnum::class)
|
||||
],
|
||||
'title' => [
|
||||
'required_unless:type,' . SliderTypeEnum::home->value(),
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,255'
|
||||
],
|
||||
'content' => [
|
||||
'required_if:type,' . SliderTypeEnum::home->value() . ', ' . SliderTypeEnum::team->value(),
|
||||
'nullable',
|
||||
'string',
|
||||
new WysiwygLength(3, 275),
|
||||
'max:500'
|
||||
],
|
||||
'video_id' => 'nullable|string|regex:%([^"&?\/\s]{11})%i',
|
||||
'picture_alt' => [
|
||||
'required_unless:type,' . SliderTypeEnum::team->value(),
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,255'
|
||||
],
|
||||
'picture_title' => [
|
||||
'required_unless:type,' . SliderTypeEnum::team->value(),
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,255'
|
||||
],
|
||||
'button_label' => 'required_if:button_status,true|nullable|string|between:3,35',
|
||||
'button_url' => 'required_if:button_status,true|nullable|string|between:3,255',
|
||||
'button_status' => [
|
||||
'required_unless:type,' . SliderTypeEnum::home->value() . ', ' . SliderTypeEnum::team->value(),
|
||||
'nullable',
|
||||
'boolean'
|
||||
],
|
||||
'button_new_tab' => 'required|boolean',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 1920, 1080, 1920, 1080, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'type' => trans('validation.custom.type'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
'video_id' => trans('validation.custom.video_id'),
|
||||
'picture' => trans('validation.custom.picture'),
|
||||
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||
'picture_title' => trans('validation.custom.picture_title'),
|
||||
'button_label' => trans('validation.custom.button_label'),
|
||||
'button_url' => trans('validation.custom.button_url'),
|
||||
'button_status' => trans('validation.custom.button_status'),
|
||||
'button_new_tab' => trans('validation.custom.button_new_tab'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validaton messages.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required_unless' => __('Le champ :attribute est obligatoire si le slider n\'est pas :name.', [
|
||||
'attribute' => trans('validation.attributes.title'),
|
||||
'name' => SliderTypeEnum::home->label()
|
||||
]),
|
||||
'content.required_if' => __('Le champ :attribute est obligatoire si le slider est :name1 ou :name2.', [
|
||||
'attribute' => trans('validation.attributes.content'),
|
||||
'name1' => SliderTypeEnum::home->label(),
|
||||
'name2' => SliderTypeEnum::team->label()
|
||||
]),
|
||||
'content.max' => __(
|
||||
'Le champ :attribute ne peut pas contenir plus de :max caractères (balises incluses).',
|
||||
[
|
||||
'attribute' => trans('validation.attributes.content'),
|
||||
'max' => '500',
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Slides/UpdateSlideRequest.php
Normal file
7
app/Http/Requests/Bo/Slides/UpdateSlideRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Slides;
|
||||
|
||||
class UpdateSlideRequest extends StoreSlideRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -2,11 +2,15 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\StaticPages;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UpdateStaticPageRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
|
@ -14,7 +18,7 @@ class UpdateStaticPageRequest extends FormRequest
|
|||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
return Gate::check('update', $this->route('static_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -25,8 +29,11 @@ class UpdateStaticPageRequest extends FormRequest
|
|||
public function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'content' => (string)Str::of($this->post('content'))
|
||||
'content' => (empty(Str::of($this->input('content'))->value())) ?
|
||||
null :
|
||||
Str::of($this->input('content'))->value()
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,11 +43,43 @@ class UpdateStaticPageRequest extends FormRequest
|
|||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => 'required|min:45|max:70',
|
||||
$rules = [
|
||||
'seo_title' => 'required|min:45|max:70',
|
||||
'seo_description' => 'required|min:50|max:160',
|
||||
'title' => 'required|min:3|max:255',
|
||||
'content' => 'present',
|
||||
'title' => 'required|min:3|max:255',
|
||||
'content' => 'sometimes|nullable',
|
||||
];
|
||||
if (request()->route()->parameters()['static_page']->type->containsContent()) {
|
||||
$rules = array_merge($rules, ['content' => 'required|string|min:15']);
|
||||
}
|
||||
if (request()->route()->parameters()['static_page']->type->containsBanner()) {
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 1920, 1080, 1920, 1080, false),
|
||||
[
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
]
|
||||
);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => trans('validation.custom.seo_title'),
|
||||
'seo_description' => trans('validation.custom.seo_description'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
'picture' => trans('validation.custom.banner'),
|
||||
'picture_alt' => trans('validation.custom.attribute_alt'),
|
||||
'picture_title' => trans('validation.custom.attribute_title'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
62
app/Http/Requests/Bo/Stickies/StoreStickyRequest.php
Normal file
62
app/Http/Requests/Bo/Stickies/StoreStickyRequest.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Stickies;
|
||||
|
||||
use App\Enums\StaticPageType;
|
||||
use App\Enums\StickiesColorEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreStickyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
||||
new Enum(StaticPageType::class)
|
||||
],
|
||||
'title' => 'required|string|between:3,255',
|
||||
'anchor' => [
|
||||
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
||||
'string',
|
||||
'between:3,255'
|
||||
],
|
||||
'color' => [
|
||||
Rule::requiredIf($this->user()->can('create', $this->sticky)),
|
||||
new Enum(StickiesColorEnum::class)
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'type' => trans('validation.custom.type'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'anchor' => trans('validation.custom.anchor'),
|
||||
'color' => trans('validation.custom.color'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Stickies/UpdateStickyRequest.php
Normal file
7
app/Http/Requests/Bo/Stickies/UpdateStickyRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Stickies;
|
||||
|
||||
class UpdateStickyRequest extends StoreStickyRequest
|
||||
{
|
||||
}
|
||||
101
app/Http/Requests/Bo/Strips/StoreStripRequest.php
Normal file
101
app/Http/Requests/Bo/Strips/StoreStripRequest.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Strips;
|
||||
|
||||
use App\Rules\WysiwygLength;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreStripRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published'),
|
||||
]);
|
||||
if ($this->input('picture')) {
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'text' => [
|
||||
'required',
|
||||
'string',
|
||||
new WysiwygLength(3, 90),
|
||||
],
|
||||
'news_id' => 'nullable|exists:news,id',
|
||||
'published' => 'required|boolean',
|
||||
'publish_at' => 'nullable|date',
|
||||
'unpublish_at' => 'nullable|date|after:publish_at',
|
||||
];
|
||||
|
||||
if ($this->input('picture')) {
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
[
|
||||
'picture_alt' => 'required_with|string|between:3,255',
|
||||
'picture_title' => 'required_with|string|between:3,255',
|
||||
],
|
||||
$this->pictureRules('picture', 100, 65, 100, 65, true),
|
||||
);
|
||||
} else {
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
[
|
||||
'picto' => [
|
||||
'required',
|
||||
new Enum(\App\Enums\Strips\PictoEnum::class)
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'picto' => trans('validation.custom.picto'),
|
||||
'picture' => trans('validation.custom.picture'),
|
||||
'picture_alt' => trans('validation.custom.alt_attribute'),
|
||||
'picture_title' => trans('validation.custom.title_attribute'),
|
||||
'text' => trans('validation.attributes.content'),
|
||||
'news_id' => trans('models.classes.news'),
|
||||
'published' => trans('validation.custom.activated'),
|
||||
'publish_at' => trans('validation.custom.publish_at'),
|
||||
'unpublish_at' => trans('validation.custom.unpublish_at'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Strips/UpdateStripRequest.php
Normal file
7
app/Http/Requests/Bo/Strips/UpdateStripRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Strips;
|
||||
|
||||
class UpdateStripRequest extends StoreStripRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Testimonials;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreTestimonialRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'type' => [
|
||||
'required',
|
||||
new Enum(\App\Enums\Testimonials\TypeEnum::class)
|
||||
],
|
||||
'name' => 'required|string|between:3,255',
|
||||
'job' => 'required|string|between:3,255',
|
||||
'content' => 'required|string|min:3',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 150, 150, 150, 150, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'type' => trans('validation.custom.type'),
|
||||
'name' => trans('validation.attributes.name'),
|
||||
'job' => trans('validation.custom.job'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
'picture_alt' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.alt_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
'picture_title' => trans(':field :inter:model', [
|
||||
'field' => trans('validation.custom.title_attribute'),
|
||||
'inter' => trans('validation.custom.of_the.vowel'),
|
||||
'model' => trans('validation.custom.picture'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Testimonials;
|
||||
|
||||
class UpdateTestimonialRequest extends StoreTestimonialRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -24,14 +24,14 @@ class UpdateChangeOrderRequest extends FormRequest
|
|||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'direction' => $this->direction === 'up' ? true : false
|
||||
'direction' => $this->route('direction') === 'up' ? true : false
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Illuminate\Validation\ValidationException;
|
|||
abstract class UpdateMiniCrudRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* The model parameter name
|
||||
* The model parameter name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -21,45 +21,25 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
foreach ($this->{$this->modelName}->data as $iptName => $input) {
|
||||
$input = \json_decode(\json_encode($input), true);
|
||||
switch ($input['inputType']) {
|
||||
case InputType::text->value:
|
||||
if (is_null($this->data[$iptName]['value']) && !$input['required']) {
|
||||
$this->merge([
|
||||
$this->data[$iptName]['value'] => ''
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.MaxExceeded
|
||||
* @phpcs:disable Generic.Metrics.NestingLevel.TooHigh
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
// phpcs:enable
|
||||
$rules = [];
|
||||
foreach ($this->{$this->modelName}->data as $iptName => $input) {
|
||||
$input = \json_decode(\json_encode($input), true);
|
||||
$encoded = \json_encode($input);
|
||||
$input = \json_decode($encoded !== false ? $encoded : '[]', true);
|
||||
switch ($input['inputType']) {
|
||||
case InputType::number->value:
|
||||
$rules = array_merge($rules, [
|
||||
|
|
@ -89,11 +69,10 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
]);
|
||||
break;
|
||||
case InputType::text->value:
|
||||
$required = $input['required'] ? 'required' : 'nullable';
|
||||
$mergeRules = $this->compileValidate($required . '|string|min:15', $input);
|
||||
$mergeRules = $this->compileValidate('required|string|min:15', $input);
|
||||
$mergeRules = collect($mergeRules)
|
||||
->map(function ($rule) {
|
||||
if (\strpos($rule, 'max:') !== false) {
|
||||
if (\is_string($rule) && \strpos($rule, 'max:') !== false) {
|
||||
$max = \intval(str_replace('max:', '', $rule));
|
||||
return function ($attribute, $value, $fail) use ($max) {
|
||||
if (\strlen(\strip_tags($value)) > $max) {
|
||||
|
|
@ -102,17 +81,16 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
};
|
||||
}
|
||||
return $rule;
|
||||
});
|
||||
})->all();
|
||||
$rules = array_merge($rules, [
|
||||
"data.$iptName.value" => $mergeRules
|
||||
]);
|
||||
break;
|
||||
case InputType::image->value:
|
||||
$required = $this->isUpdate() ? 'sometimes' : 'required';
|
||||
|
||||
$ipt = $this->data[$iptName];
|
||||
$max = isset($ipt['dimensionsMax']);
|
||||
$dim = \is_string($input['dimensions']) ? collect(explode(
|
||||
$required = $this->isUpdate() ? 'sometimes' : ($input['required'] ? 'required' : 'nullable');
|
||||
$ipt = $this->data[$iptName];
|
||||
$max = isset($ipt['dimensionsMax']);
|
||||
$dim = \is_string($input['dimensions']) ? collect(explode(
|
||||
',',
|
||||
(isset($ipt['dimensionsMax']) and is_string($ipt['dimensionsMax'])) ?
|
||||
$ipt['dimensionsMax'] : $input['dimensions']
|
||||
|
|
@ -122,20 +100,16 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
}) : $input['dimensions'];
|
||||
|
||||
// * Adapt dimensions
|
||||
$sizes = (object)[
|
||||
$sizes = [
|
||||
'minHeight' => $dim['height'],
|
||||
'maxHeight' => $dim['height'],
|
||||
'minWith' => $dim['width'],
|
||||
'maxWith' => $dim['width'],
|
||||
'minWidth' => $dim['width'],
|
||||
'maxWidth' => $dim['width'],
|
||||
];
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"data.$iptName.value" => [
|
||||
function (string $attribute, $value, callable $fail) use ($sizes, $input) {
|
||||
// Picture can be null.
|
||||
if ($input['required'] || $value !== null) {
|
||||
return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||
}
|
||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
||||
ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||
}
|
||||
],
|
||||
$this->compileValidate(
|
||||
|
|
@ -153,28 +127,17 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
]),
|
||||
$input
|
||||
),
|
||||
]);
|
||||
|
||||
// Attributes are required if a picture is set.
|
||||
$required = $this->data['bloc_image']['value'] ? 'required' : 'nullable';
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"data.$iptName.alt" => $this->compileValidate("$required|string|min:5", $input),
|
||||
"data.$iptName.alt" => $this->compileValidate("$required|string|min:5", $input),
|
||||
"data.$iptName.title" => $this->compileValidate("$required|string|min:5", $input)
|
||||
]);
|
||||
break;
|
||||
case InputType::url->value:
|
||||
$rules = array_merge($rules, [
|
||||
"data.$iptName.value" => [
|
||||
'required', 'url',
|
||||
$this->compileValidate('url', $input),
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
try {
|
||||
ToolboxHelper::assertNoInternalUrls($attribute, $value);
|
||||
ToolboxHelper::assertNoInternalBoUrls($attribute, $value);
|
||||
} catch (ValidationException $e) {
|
||||
$fail(collect($e->errors())->first()[0]);
|
||||
}
|
||||
$this->validateUrl($attribute, $value, $fail);
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
@ -193,22 +156,23 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
break;
|
||||
} //end switch
|
||||
} //end foreach
|
||||
// @phpstan-ignore-next-line
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* Undocumented function.
|
||||
*
|
||||
* @param string|array $inputTypeValidate
|
||||
* @param array $input
|
||||
* @return array
|
||||
* @param string|array<int, string> $inputTypeValidate
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
public function compileValidate(string|array $inputTypeValidate, array $input): array
|
||||
{
|
||||
if (\is_string($inputTypeValidate)) {
|
||||
$inputTypeValidate = explode('|', $inputTypeValidate);
|
||||
}
|
||||
/** @var array|string */
|
||||
/** @var array<int|string, mixed>|string $inputValidate */
|
||||
$inputValidate = \collect($input)->get('validate', $input);
|
||||
$inputValidate = \is_string($inputValidate) ? explode('|', $inputValidate) : $inputValidate;
|
||||
foreach ($inputValidate as $validate) {
|
||||
|
|
@ -217,18 +181,32 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
}
|
||||
}
|
||||
|
||||
$test = \collect($inputTypeValidate)->all();
|
||||
$test = \collect($inputTypeValidate)->sort(function ($valueA, $valueB) {
|
||||
$valueA = $this->ruleHasToComeFirst($valueA) ? 0 : 2;
|
||||
$valueB = $this->ruleHasToComeFirst($valueB) ? 1 : 2;
|
||||
return $valueA - $valueB;
|
||||
})->unique()->all();
|
||||
|
||||
return \collect($inputTypeValidate)->unique()->sort(function ($valueA, $valueB) {
|
||||
$valueA = $this->ruleHasToComeFirst($valueA) ? 0 : 2;
|
||||
$valueB = $this->ruleHasToComeFirst($valueB) ? 1 : 2;
|
||||
return $valueA - $valueB;
|
||||
})->all();
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate URl
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $url
|
||||
* @param \Closure $fail
|
||||
* @return void
|
||||
*/
|
||||
private function validateUrl(string $attribute, mixed $url, \Closure $fail): void
|
||||
{
|
||||
try {
|
||||
if (!is_null($url)) {
|
||||
$url = is_string($url) ? $url : '';
|
||||
ToolboxHelper::assertNoInternalUrls($attribute, $url);
|
||||
ToolboxHelper::assertNoInternalBoUrls($attribute, $url);
|
||||
}
|
||||
} catch (ValidationException $e) {
|
||||
$fail(collect($e->errors())->first()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
60
app/Http/Requests/Bo/UpdateOrderRequest.php
Normal file
60
app/Http/Requests/Bo/UpdateOrderRequest.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateOrderRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Attribute model needed.
|
||||
*
|
||||
* @var Model $orderable
|
||||
*/
|
||||
private Model $orderableModel;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->orderableModel = collect($this->route()->parameters())
|
||||
->first(fn($param) => $param instanceof Model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'order' => [
|
||||
'required',
|
||||
'integer',
|
||||
'min:1',
|
||||
sprintf('max:%s', $this->orderableModel->max('order')),
|
||||
function ($attribute, $value, $fail) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
if ($this->orderableModel && intval($value) === $this->orderableModel->order) {
|
||||
$fail("La valeur de {$attribute} doit être différente de la valeur actuelle.");
|
||||
}
|
||||
},
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ class UploadFileRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check() and $this->ajax();
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class UploadFileRequest extends FormRequest
|
|||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'upload' => 'required|image|mimes:jpeg,png,jpg|max:2048'
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
namespace App\Http\Requests\Bo\Users;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class StoreUserRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -16,7 +17,7 @@ class StoreUserRequest extends FormRequest
|
|||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
return Gate::check('create', User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -24,51 +25,42 @@ class StoreUserRequest extends FormRequest
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required|string|min:3|max:255',
|
||||
'last_name' => 'required|string|min:3|max:255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
||||
'password' => [
|
||||
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
||||
->letters()
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()
|
||||
->uncompromised()
|
||||
],
|
||||
'role' => ['required', new Enum(RoleEnum::class)],
|
||||
'published' => 'required|boolean',
|
||||
'last_name' => 'required|string|min:3|max:255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
||||
'role' => ['required', new Enum(RoleEnum::class)],
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => trans('validation.attributes.first_name'),
|
||||
'last_name' => trans('validation.attributes.last_name'),
|
||||
'email' => trans('validation.attributes.email'),
|
||||
'password' => trans('validation.attributes.password'),
|
||||
'role' => trans('validation.attributes.role'),
|
||||
'published' => trans('validation.custom.publication')
|
||||
'last_name' => trans('validation.attributes.last_name'),
|
||||
'email' => trans('validation.attributes.email'),
|
||||
'role' => trans('validation.attributes.role'),
|
||||
'published' => trans('validation.custom.publication')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,47 +2,46 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\Users;
|
||||
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateUserRequest extends StoreUserRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false,
|
||||
'password' => $this->password ? $this->password : $this->route('user')->password,
|
||||
'password_confirmation' => $this->password_confirmation ?
|
||||
$this->password_confirmation :
|
||||
$this->route('user')->password
|
||||
'published' => $this->boolean('published'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return array_merge(parent::rules(), [
|
||||
'email' => [
|
||||
'email' => [
|
||||
'required',
|
||||
'email:rfc,strict,dns,spoof,filter',
|
||||
'unique:users,email,' . $this->route('user')->id . ',id',
|
||||
],
|
||||
'password' => [
|
||||
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
||||
->letters()
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()
|
||||
->uncompromised()
|
||||
],
|
||||
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
125
app/Http/Requests/Fo/ListenFormRequest.php
Normal file
125
app/Http/Requests/Fo/ListenFormRequest.php
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Fo;
|
||||
|
||||
use App\Enums\Country;
|
||||
use App\Enums\Listen\ObjectEnum;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class ListenFormRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'country' => $this->post('country') ?? null,
|
||||
'accept_rules' => $this->boolean('accept_rules'),
|
||||
'send_data' => $this->boolean('send_data'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
$rules = [
|
||||
'first_name' => 'present|nullable|string|between:3,100',
|
||||
'last_name' => 'required|string|between:3,100',
|
||||
'society' => 'present|nullable|string|between:3,255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|max:255',
|
||||
'phone' => array_merge(
|
||||
['present', 'nullable'],
|
||||
!is_null(request()->input('country'))
|
||||
? (Country::make(request()->input('country'))->value === Country::france->value
|
||||
? ['phone:FR', 'max:25']
|
||||
: ['numeric', 'max:50'])
|
||||
: ['numeric', 'max:50']
|
||||
),
|
||||
'postal_code' => array_merge(
|
||||
['present', 'nullable'],
|
||||
!is_null(request()->input('country'))
|
||||
? (Country::make(request()->input('country'))->value === Country::france->value
|
||||
? ['postal_code:FR', 'max:25']
|
||||
: ['numeric', 'max:50'])
|
||||
: ['numeric', 'max:50']
|
||||
),
|
||||
'city' => 'present|nullable|string|between:3,20',
|
||||
'country' => ['present', 'nullable', new Enum(Country::class)],
|
||||
'address' => 'present|nullable|string|between:3,255',
|
||||
'object' => ['required', new Enum(ObjectEnum::class)],
|
||||
'message' => 'required|min:20|max:35656',
|
||||
];
|
||||
if (
|
||||
isset(request()->file) and
|
||||
(request()->file->getClientMimeType() === "image/jpeg" ||
|
||||
request()->file->getClientMimeType() === "image/png")
|
||||
) {
|
||||
$rules = \array_merge($rules, $this->pictureRules(
|
||||
'file',
|
||||
0,
|
||||
0,
|
||||
1920,
|
||||
1080,
|
||||
true,
|
||||
3000,
|
||||
));
|
||||
} elseif (isset(request()->file) and (request()->file->getClientMimeType() === "application/pdf")) {
|
||||
$rules = \array_merge($rules, [
|
||||
'file' => 'present|nullable|mimes:pdf'
|
||||
]);
|
||||
} elseif (
|
||||
isset(request()->file) and
|
||||
(request()->file->getClientMimeType() !== "application/pdf") and
|
||||
(request()->file->getClientMimeType() !== "image/jpeg") and
|
||||
(request()->file->getClientMimeType() !== "image/png")
|
||||
) {
|
||||
$rules = \array_merge($rules, [
|
||||
'file' => [
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
$fail(\trans('Le format du fichier doit être .jpg, .png ou .pdf'));
|
||||
}
|
||||
],
|
||||
]);
|
||||
} //end if
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => trans('validation.attributes.first_name'),
|
||||
'last_name' => trans('validation.attributes.last_name'),
|
||||
'society' => trans('validation.attributes.society'),
|
||||
'email' => trans('validation.attributes.email'),
|
||||
'phone' => trans('validation.attributes.phone'),
|
||||
'postal_code' => trans('validation.attributes.postal_code'),
|
||||
'city' => trans('validation.attributes.city'),
|
||||
'country' => trans('validation.attributes.country'),
|
||||
'address' => trans('validation.attributes.address'),
|
||||
'object' => trans('validation.attributes.object'),
|
||||
'message' => trans('validation.attributes.message'),
|
||||
'file' => trans('validation.attributes.file'),
|
||||
'accept_rules' => trans('validation.attributes.custom.accept_rules'),
|
||||
'send_data' => trans('validation.attributes.custom.send_data'),
|
||||
];
|
||||
}
|
||||
}
|
||||
48
app/Jobs/CleanOldActivities.php
Normal file
48
app/Jobs/CleanOldActivities.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Permanently deletes entries that have been stored for more than one year.
|
||||
*/
|
||||
class CleanOldActivities implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*
|
||||
* @param boolean $force
|
||||
*/
|
||||
public function __construct(public readonly bool $force = false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete entries if it has been stored for more than one year.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$query = ActivityLog::query();
|
||||
|
||||
if (!$this->force) {
|
||||
$query->where('created_at', '<', Carbon::now()->subYear());
|
||||
}
|
||||
|
||||
$query->cursor()->each(fn($model) => $model->delete());
|
||||
}
|
||||
}
|
||||
54
app/Jobs/UpdatePlanificatedStatus.php
Normal file
54
app/Jobs/UpdatePlanificatedStatus.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Models\Strip;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Update published attribute reading its
|
||||
* publish_at and unpublish_at attributes.
|
||||
*/
|
||||
class UpdatePlanificatedStatus
|
||||
{
|
||||
/**
|
||||
* Called when the job will be executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
collect([News::class, Strip::class])
|
||||
->each(function (string $model) {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> */
|
||||
$modelListToPublish = $model::query()
|
||||
->whereNotNull('publish_at')
|
||||
->where('publish_at', '<=', Carbon::now())
|
||||
->where(function ($query) {
|
||||
$query->whereNull('unpublish_at')
|
||||
->orWhere('unpublish_at', '>', Carbon::now());
|
||||
})
|
||||
->where('published', false)
|
||||
->get();
|
||||
Log::debug(__CLASS__ . " models to publish " . $modelListToPublish->count());
|
||||
$modelListToPublish->each(function ($currentModel) {
|
||||
$currentModel->published = true;
|
||||
$currentModel->saveOrFail();
|
||||
});
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> */
|
||||
$modelListToUnpublish = $model::query()
|
||||
->whereNotNull('unpublish_at')
|
||||
->where('unpublish_at', '<=', Carbon::now())
|
||||
->where('published', true)
|
||||
->get();
|
||||
Log::debug(__CLASS__ . " models to unpublish " . $modelListToUnpublish->count());
|
||||
$modelListToUnpublish->each(function ($currentModel) {
|
||||
$currentModel->published = false;
|
||||
$currentModel->saveOrFail();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -10,33 +10,37 @@ use Illuminate\Support\Collection;
|
|||
class CollectionHelper
|
||||
{
|
||||
/**
|
||||
* Paginate a collection
|
||||
* Paginate a collection.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $results
|
||||
* @param integer $pageSize
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Support\Collection<int, TModel> $results
|
||||
* @param integer $pageSize
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
|
||||
*/
|
||||
public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator
|
||||
public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator
|
||||
{
|
||||
$page = Paginator::resolveCurrentPage('page');
|
||||
|
||||
return self::paginateManually($results, $pageSize, $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paginate a collection
|
||||
* Paginate a collection.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $results
|
||||
* @param integer $pageSize
|
||||
* @param integer $page
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Support\Collection<int, TModel> $results
|
||||
* @param integer $pageSize
|
||||
* @param integer $page
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
|
||||
*/
|
||||
public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator
|
||||
{
|
||||
public static function paginateManually(
|
||||
Collection $results,
|
||||
int $pageSize,
|
||||
int $page = 1
|
||||
): \Illuminate\Pagination\LengthAwarePaginator {
|
||||
$total = $results->count();
|
||||
|
||||
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
|
||||
'path' => Paginator::resolveCurrentPath(),
|
||||
'path' => Paginator::resolveCurrentPath(),
|
||||
'pageName' => 'page',
|
||||
]);
|
||||
}
|
||||
|
|
@ -44,21 +48,27 @@ class CollectionHelper
|
|||
/**
|
||||
* Create a new length-aware paginator instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $items
|
||||
* @param integer $total
|
||||
* @param integer $perPage
|
||||
* @param integer $currentPage
|
||||
* @param array $options
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param \Illuminate\Support\Collection<int, TModel> $items
|
||||
* @param integer $total
|
||||
* @param integer $perPage
|
||||
* @param integer $currentPage
|
||||
* @param array<mixed> $options
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
|
||||
*/
|
||||
protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
|
||||
{
|
||||
protected static function paginator(
|
||||
Collection $items,
|
||||
int $total,
|
||||
int $perPage,
|
||||
int $currentPage,
|
||||
array $options
|
||||
): \Illuminate\Pagination\LengthAwarePaginator {
|
||||
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
|
||||
'items' => $items,
|
||||
'total' => $total,
|
||||
'perPage' => $perPage,
|
||||
'items' => $items,
|
||||
'total' => $total,
|
||||
'perPage' => $perPage,
|
||||
'currentPage' => $currentPage,
|
||||
'options' => $options
|
||||
'options' => $options
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace App\Lib\Helpers;
|
|||
class ExceptionsHelper
|
||||
{
|
||||
/**
|
||||
* Handle sentry event
|
||||
* Handle sentry event.
|
||||
*
|
||||
* @param \Sentry\Event $event
|
||||
* @return null|\Sentry\Event
|
||||
|
|
@ -26,7 +26,7 @@ class ExceptionsHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Anonimize Sentry Exception bag
|
||||
* Anonimize Sentry Exception bag.
|
||||
*
|
||||
* @param \Sentry\ExceptionDataBag $exceptionDataBag
|
||||
* @return \Sentry\ExceptionDataBag
|
||||
|
|
@ -42,7 +42,7 @@ class ExceptionsHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Anonymise sentry stacktrace
|
||||
* Anonymise sentry stacktrace.
|
||||
*
|
||||
* @param \Sentry\Stacktrace $stackTrace
|
||||
* @return \Sentry\Stacktrace
|
||||
|
|
@ -70,7 +70,7 @@ class ExceptionsHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Get anonymized sentry params
|
||||
* Get anonymized sentry params.
|
||||
*
|
||||
* @param mixed[] $params
|
||||
* @return string[]
|
||||
|
|
@ -80,7 +80,7 @@ class ExceptionsHelper
|
|||
foreach ($params as &$param) {
|
||||
$type = \strtolower(\gettype($param));
|
||||
if (\is_string($param)) {
|
||||
$type = \explode(' ', \trim(strtolower($param)))[0] ?? null;
|
||||
$type = \explode(' ', \trim(strtolower($param)))[0];
|
||||
}
|
||||
switch (true) {
|
||||
case $type === 'lambda':
|
||||
|
|
@ -103,9 +103,8 @@ class ExceptionsHelper
|
|||
return $params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Anonymize at least Sql queries
|
||||
* Anonymize at least Sql queries.
|
||||
*
|
||||
* @param string $message
|
||||
* @return string
|
||||
|
|
@ -120,14 +119,14 @@ class ExceptionsHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Anonymize stack trace
|
||||
* Anonymize stack trace.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return string
|
||||
*/
|
||||
public static function getAnonymizedStackTrace(\Throwable $e): string
|
||||
{
|
||||
$projectPath = \realpath(\sprintf('%s/../', \app_path()));
|
||||
$projectPath = \realpath(\sprintf('%s/../', \app_path())) ?: '';
|
||||
$traceStack = $e->getTrace();
|
||||
$traceStr = '';
|
||||
$maxStackStage = 0;
|
||||
|
|
@ -145,7 +144,7 @@ class ExceptionsHelper
|
|||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
} elseif (isset($stack['function'])) {
|
||||
} else {
|
||||
$traceStr .= "{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
|
|
@ -159,9 +158,9 @@ class ExceptionsHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Handle Args
|
||||
* Handle Args.
|
||||
*
|
||||
* @param array $stack
|
||||
* @param array<string, mixed> $stack
|
||||
* @return string
|
||||
*/
|
||||
public static function handleArgs(array $stack): string
|
||||
|
|
|
|||
|
|
@ -25,11 +25,23 @@ use Illuminate\Support\Str;
|
|||
* The final path will be storage/modelfiles/posts/10/04/19/5f/black-cat-under-red-car-286071690833400.png
|
||||
*
|
||||
* ! No limits of file per folder will be handled.
|
||||
*
|
||||
* @author Munsch Jérémy <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class FileStorageHelper
|
||||
{
|
||||
/**
|
||||
* Remove all files from string attribute html that are stored in public
|
||||
*
|
||||
* @param string $publicStorageFilePath The file path from public directory.
|
||||
* @return string The local storage path.
|
||||
*/
|
||||
public static function getFileFullPath(string $publicStorageFilePath): string
|
||||
{
|
||||
/** @var \Illuminate\Filesystem\FilesystemAdapter */
|
||||
$disk = Storage::disk('uploads');
|
||||
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
|
||||
return $disk->path($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the file associate with the attribute.
|
||||
*
|
||||
|
|
@ -43,7 +55,7 @@ class FileStorageHelper
|
|||
if (\strpos($path, 'storage') !== 0) {
|
||||
return;
|
||||
}
|
||||
$path = ToolboxHelper::mbReplace('storage/', '', $path);
|
||||
$path = ToolboxHelper::mbReplaceString('storage/', '', $path);
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
Storage::disk('public')->delete($path);
|
||||
}
|
||||
|
|
@ -67,7 +79,7 @@ class FileStorageHelper
|
|||
if (\strpos($originalPath, 'storage') !== 0) {
|
||||
return;
|
||||
}
|
||||
$originalPath = ToolboxHelper::mbReplace('storage/', '', $originalPath);
|
||||
$originalPath = ToolboxHelper::mbReplaceString('storage/', '', $originalPath);
|
||||
if (Storage::disk('public')->exists($originalPath)) {
|
||||
Storage::disk('public')->delete($originalPath);
|
||||
}
|
||||
|
|
@ -91,8 +103,8 @@ class FileStorageHelper
|
|||
Model $model,
|
||||
$file,
|
||||
bool $slugify = false,
|
||||
string $filename = null,
|
||||
bool $private = false
|
||||
string|null $filename = null,
|
||||
bool $private = false,
|
||||
): string {
|
||||
// phpcs:enable
|
||||
$tableName = $model->getTable();
|
||||
|
|
@ -152,16 +164,16 @@ class FileStorageHelper
|
|||
public static function storeModelFilesFromHtml(
|
||||
Model $model,
|
||||
string $htmlString,
|
||||
string $oldHtmlString = null
|
||||
string|null $oldHtmlString = null
|
||||
): string {
|
||||
\collect(self::onlyUploadedFilesWithFileManager(self::findFilesInHtml($htmlString)))
|
||||
->each(function (string $path) use ($model, &$htmlString) {
|
||||
/** @var \Illuminate\Filesystem\FilesystemAdapter */
|
||||
$disk = Storage::disk('uploads');
|
||||
$fileInfo = new \SplFileInfo($disk->path(
|
||||
ToolboxHelper::mbReplace('/uploads/', '', \urldecode($path))
|
||||
ToolboxHelper::mbReplaceString('/uploads/', '', \urldecode($path))
|
||||
));
|
||||
$htmlString = ToolboxHelper::mbReplace(
|
||||
$htmlString = ToolboxHelper::mbReplaceString(
|
||||
$path,
|
||||
'/' . self::storeFile($model, $fileInfo, true),
|
||||
$htmlString
|
||||
|
|
@ -202,7 +214,7 @@ class FileStorageHelper
|
|||
$filesToKeep = \collect(self::onlyUploadedFilesWithFileStorageHelper($newFiles));
|
||||
$filesToRemove = $oldFiles->diff($filesToKeep);
|
||||
$filesToRemove->each(function (string $publicStorageFilePath) {
|
||||
$path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
|
||||
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
Storage::disk('public')->delete($path);
|
||||
}
|
||||
|
|
@ -219,7 +231,7 @@ class FileStorageHelper
|
|||
{
|
||||
$filesToRemove = \collect(self::onlyUploadedFilesWithFileStorageHelper(self::findFilesInHtml($htmlString)));
|
||||
$filesToRemove->each(function (string $publicStorageFilePath) {
|
||||
$path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
|
||||
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
Storage::disk('public')->delete($path);
|
||||
}
|
||||
|
|
@ -230,7 +242,7 @@ class FileStorageHelper
|
|||
* Find all occurence of files in html
|
||||
*
|
||||
* @param string $html
|
||||
* @return array
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function findFilesInHtml(string $html): array
|
||||
{
|
||||
|
|
@ -245,20 +257,20 @@ class FileStorageHelper
|
|||
* Filter array to get only uploaded files that exists
|
||||
* on disk 'public' (using helper storage strategy)
|
||||
*
|
||||
* @param array $urls
|
||||
* @return array
|
||||
* @param array<int, string> $urls
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function onlyUploadedFilesWithFileStorageHelper(array $urls): array
|
||||
{
|
||||
return \collect($urls)->unique()
|
||||
// * Filter to get only /uploads and using app url or empty
|
||||
->filter(function (string $url) {
|
||||
$path = \parse_url($url, \PHP_URL_PATH);
|
||||
$path = (string) \parse_url($url, \PHP_URL_PATH);
|
||||
return \strpos(\ltrim($path, '/'), 'storage/modelfiles') === 0;
|
||||
})->filter(function (string $url) {
|
||||
$path = \parse_url($url, \PHP_URL_PATH);
|
||||
$path = (string) \parse_url($url, \PHP_URL_PATH);
|
||||
return Storage::disk('public')
|
||||
->exists(ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($path), '/')));
|
||||
->exists(ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($path), '/')));
|
||||
})->all();
|
||||
}
|
||||
|
||||
|
|
@ -266,22 +278,22 @@ class FileStorageHelper
|
|||
* Filter array to get only uploaded files that exists
|
||||
* on disk 'uploads'
|
||||
*
|
||||
* @param array $urls
|
||||
* @return array
|
||||
* @param array<int, string> $urls
|
||||
* @return array<mixed>
|
||||
*/
|
||||
private static function onlyUploadedFilesWithFileManager(array $urls): array
|
||||
{
|
||||
return \collect($urls)->unique()
|
||||
// * Filter to get only /uploads and using app url or empty
|
||||
->filter(function (string $url) {
|
||||
$host = \parse_url($url, \PHP_URL_HOST);
|
||||
$path = \parse_url($url, \PHP_URL_PATH);
|
||||
return ($host === \parse_url(config('app.url'), PHP_URL_HOST) or \is_null($host)) and
|
||||
$host = (string) \parse_url($url, \PHP_URL_HOST);
|
||||
$path = (string) \parse_url($url, \PHP_URL_PATH);
|
||||
return ($host === (string) \parse_url(config('app.url'), PHP_URL_HOST) or $host === '') and
|
||||
\strpos(\ltrim($path, '/'), 'uploads') === 0;
|
||||
})->filter(function (string $url) {
|
||||
$path = \parse_url($url, \PHP_URL_PATH);
|
||||
$path = (string) \parse_url($url, \PHP_URL_PATH);
|
||||
return Storage::disk('uploads')
|
||||
->exists(ToolboxHelper::mbReplace('uploads/', '', \ltrim(\urldecode($path), '/')));
|
||||
->exists(ToolboxHelper::mbReplaceString('uploads/', '', \ltrim(\urldecode($path), '/')));
|
||||
})->all();
|
||||
}
|
||||
|
||||
|
|
@ -308,8 +320,7 @@ class FileStorageHelper
|
|||
$folderPath = self::getStoragePath(
|
||||
$private ? 'app/private/modelfiles' : 'app/public/modelfiles',
|
||||
$tableName,
|
||||
$filename,
|
||||
$private
|
||||
$filename
|
||||
);
|
||||
$filename = self::getFileUniqueName($folderPath, $filename);
|
||||
return "{$folderPath}/{$filename}";
|
||||
|
|
@ -404,7 +415,7 @@ class FileStorageHelper
|
|||
$filename = Str::of($filename)->ltrim('.-');
|
||||
// * Optional beautification
|
||||
if ($beautify) {
|
||||
$filename = static::beautifyFilename($filename);
|
||||
$filename = self::beautifyFilename($filename);
|
||||
}
|
||||
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||
/** @var string */
|
||||
|
|
@ -446,7 +457,7 @@ class FileStorageHelper
|
|||
'/\.{2,}/'
|
||||
], '.', $filename);
|
||||
// Lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 .
|
||||
$filename = mb_strtolower($filename, mb_detect_encoding($filename));
|
||||
$filename = mb_strtolower($filename, mb_detect_encoding($filename) ?: null);
|
||||
// * ".file-name.-" becomes "file-name"
|
||||
$filename = trim($filename, '.-');
|
||||
return $filename;
|
||||
|
|
@ -455,7 +466,7 @@ class FileStorageHelper
|
|||
/**
|
||||
* Remove all model files for the given Model.
|
||||
*
|
||||
* @param Model $model
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return void
|
||||
*/
|
||||
public static function removeModelFiles(Model $model): void
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue