mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 10:43:48 +00:00
Compare commits
405 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a80e4364ae | ||
|
|
bfb3888555 | ||
|
|
5e408267ee | ||
|
|
a4725df5f7 | ||
|
|
dee562c56e | ||
|
|
e1016502a1 | ||
|
|
541924448b | ||
|
|
18b97866f2 | ||
|
|
6f2278b908 | ||
|
|
bdd8d63162 | ||
|
|
8ca7881c5e | ||
|
|
8d04a94dbc | ||
|
|
44158c74e3 | ||
|
|
847bcec22f | ||
|
|
e984ae6beb | ||
|
|
e2a52d27f5 | ||
|
|
9c92cffde3 | ||
|
|
ce20452f38 | ||
|
|
6c888c6bd3 | ||
|
|
2b2d9a0764 | ||
|
|
ed2d008f4b | ||
|
|
9972f471c4 | ||
|
|
03ef16d90d | ||
|
|
4158d4f31e | ||
|
|
e65acd8a4f | ||
|
|
ba5e05f77a | ||
|
|
82cf82e4b5 | ||
|
|
f5e19e47f7 | ||
|
|
43b1aa7f89 | ||
|
|
0e1ebdd809 | ||
|
|
6e3adcd459 | ||
|
|
9c147165e1 | ||
|
|
689b064756 | ||
|
|
6b32ae9795 | ||
|
|
267556b39d | ||
|
|
eb2e39cd32 | ||
|
|
58ae75ecc9 | ||
|
|
a5dd0e0d30 | ||
|
|
cec2450940 | ||
|
|
fdd8f16384 | ||
|
|
2112fe879b | ||
|
|
078d920c19 | ||
|
|
98d1926ab3 | ||
|
|
2263cc9511 | ||
|
|
9a736a2615 | ||
|
|
4b1e5fcb46 | ||
|
|
a0c39bd955 | ||
|
|
973b301a46 | ||
|
|
e0f192777f | ||
|
|
ce1bad57cd | ||
|
|
77b126b85a | ||
|
|
3adf57a6b1 | ||
|
|
cc72e4e3a2 | ||
|
|
3285af3603 | ||
|
|
04990fcf7b | ||
|
|
ba28ac6184 | ||
|
|
a100671cc0 | ||
|
|
ded02fc15b | ||
|
|
64fd6a2265 | ||
|
|
c2a5d4bc74 | ||
|
|
fed95cbd64 | ||
|
|
e60bbb369a | ||
|
|
7379d17a40 | ||
|
|
26e0535407 | ||
|
|
0f8a89bbad | ||
|
|
2f89f6303a | ||
|
|
4b3ca7e34b | ||
|
|
2c0cf43802 | ||
|
|
d255b01c70 | ||
|
|
6a9edc49c0 | ||
|
|
96faf2de0e | ||
|
|
5a2e6a5e53 | ||
|
|
c509eeceb1 | ||
|
|
299292a817 | ||
|
|
b11bd0e521 | ||
|
|
8fb859b441 | ||
|
|
28a5f58b80 | ||
|
|
7da4d1f64b | ||
|
|
07086c7550 | ||
|
|
5246c47c86 | ||
|
|
2975d1555d | ||
|
|
bd946be0b0 | ||
|
|
e6ff90f6fc | ||
|
|
08dc813af9 | ||
|
|
9098634b99 | ||
|
|
00213824f1 | ||
|
|
65624326c7 | ||
|
|
e92d9344b9 | ||
|
|
55cf58fffd | ||
|
|
a3c43af7ba | ||
|
|
a10d394abb | ||
|
|
b16f22b0eb | ||
|
|
5bc66d51be | ||
|
|
7b27fa70d8 | ||
|
|
372b3aa407 | ||
|
|
bda293bc53 | ||
|
|
11873d06ff | ||
|
|
89ea50b893 | ||
|
|
874b4bb768 | ||
|
|
1e49f52abe | ||
|
|
94088e76ec | ||
|
|
c7abcce729 | ||
|
|
e9d2f4bacc | ||
|
|
7e7965f98e | ||
|
|
d823ae687b | ||
|
|
21a36c0965 | ||
|
|
c3d162b991 | ||
|
|
7e325c5101 | ||
|
|
59ff07fb01 | ||
|
|
2ba92ed3b6 | ||
|
|
418c072414 | ||
|
|
397fe6b7e4 | ||
|
|
97d500028a | ||
|
|
527dfeef9f | ||
|
|
1b3baab691 | ||
|
|
5d512f7806 | ||
|
|
0da525f692 | ||
|
|
d076817c9e | ||
|
|
d2af7c1f5e | ||
|
|
ef002f9186 | ||
|
|
f1006355c4 | ||
|
|
ec6087a03c | ||
|
|
2e465f4d03 | ||
|
|
08bf6654fc | ||
|
|
77e29852a5 | ||
|
|
6bc84d4b25 | ||
|
|
d31e2ab98b | ||
|
|
ee14c34671 | ||
|
|
a8b290692e | ||
|
|
441f911560 | ||
|
|
10090b474a | ||
|
|
aff2594ef2 | ||
|
|
66aad7c488 | ||
|
|
896be9c9c9 | ||
|
|
8d1821e05d | ||
|
|
b7014552d2 | ||
|
|
8561556f5c | ||
|
|
58f7479380 | ||
|
|
7b70c81d4d | ||
|
|
1981f39f9e | ||
|
|
e86ea3e5c4 | ||
|
|
8e01b837a2 | ||
|
|
f33fe84350 | ||
|
|
dbbad817c7 | ||
|
|
0eb0939598 | ||
|
|
65f7855703 | ||
|
|
45d482d347 | ||
|
|
1654dc8678 | ||
|
|
cb417ea76d | ||
|
|
17df4aea35 | ||
|
|
714429d8f4 | ||
|
|
0df03f1d32 | ||
|
|
fefc10afb8 | ||
|
|
1658627069 | ||
|
|
16ab540298 | ||
|
|
4e5afa4747 | ||
|
|
d76ff07bf4 | ||
|
|
b38333bb64 | ||
|
|
f863537190 | ||
|
|
a72a672aaf | ||
|
|
a3dd817e7a | ||
|
|
9d9e07d0fa | ||
|
|
30783d0e5d | ||
|
|
3a296f0f9c | ||
|
|
c0d5a771a5 | ||
|
|
8fc7272e38 | ||
|
|
8b8dc34ba6 | ||
|
|
966145d384 | ||
|
|
2b4060cb7b | ||
|
|
9455a361dc | ||
|
|
26132e23a3 | ||
|
|
5acaadeaae | ||
|
|
324f4b1ffa | ||
|
|
0c02952f7a | ||
|
|
f76a4b37e4 | ||
|
|
f33f93006e | ||
|
|
382756a6f0 | ||
|
|
559bee6ca2 | ||
|
|
190fc651ae | ||
|
|
1c62da4e7c | ||
|
|
8a9d2d7f9a | ||
|
|
ae3be12934 | ||
|
|
4683e0d084 | ||
|
|
c55d3f5350 | ||
|
|
7273d60154 | ||
|
|
587daa5ffe | ||
|
|
064e635d35 | ||
|
|
06db522545 | ||
|
|
e5335c2472 | ||
|
|
a2ec066c6d | ||
|
|
15d4ffc349 | ||
|
|
9af9e45b8a | ||
|
|
f30dd38b96 | ||
|
|
d5f3599b9e | ||
|
|
de62ab535c | ||
|
|
8b8562916b | ||
|
|
0d7b920cbe | ||
|
|
f3254a380f | ||
|
|
0e12029efc | ||
|
|
fd6aa5c6b2 | ||
|
|
5be9db83f7 | ||
|
|
12d6b0bf57 | ||
|
|
961462fe54 | ||
|
|
f0e0103d81 | ||
|
|
755523e07b | ||
|
|
c4ace0697b | ||
|
|
69489c4ee2 | ||
|
|
e05d7468b5 | ||
|
|
1a6a91335e | ||
|
|
80de069c7b | ||
|
|
2de8bbe548 | ||
|
|
7ba2a3bec1 | ||
|
|
89fa2fce23 | ||
|
|
84b47416d6 | ||
|
|
55c72cddba | ||
|
|
6effd4a7d9 | ||
|
|
95f6695d00 | ||
|
|
fde7f0f73b | ||
|
|
dd1bffec09 | ||
|
|
83a951b3af | ||
|
|
6762ed25dc | ||
|
|
6ba869234e | ||
|
|
2c04376a61 | ||
|
|
f180f1fff8 | ||
|
|
ab65ca7a13 | ||
|
|
8895b5062a | ||
|
|
2f4aafb1b3 | ||
|
|
be08c8487a | ||
|
|
0d5df91d2d | ||
|
|
72e4067beb | ||
|
|
ba4f888826 | ||
|
|
82b43eb996 | ||
|
|
777132ec40 | ||
|
|
7f6f60227a | ||
|
|
ab6ff5dbfd | ||
|
|
0d272bc9b7 | ||
|
|
2b08d7801b | ||
|
|
cec4ff6cda | ||
|
|
6f300ba1d5 | ||
|
|
86813629ed | ||
|
|
73a728e606 | ||
|
|
af1228e363 | ||
|
|
f3a2758bcc | ||
|
|
6f9f2f2d34 | ||
|
|
9f4c21a1b1 | ||
|
|
88315e4a91 | ||
|
|
25bb186c89 | ||
|
|
cca832a1c1 | ||
|
|
aac0aa755f | ||
|
|
4be77c07ac | ||
|
|
9372906a3e | ||
|
|
e12e521622 | ||
|
|
6dd0b4f026 | ||
|
|
0082c3a6a8 | ||
|
|
f79973e922 | ||
|
|
3e6e046dfc | ||
|
|
59ca45e9b1 | ||
|
|
5f5caae9e7 | ||
|
|
93a7542502 | ||
|
|
bb22ec1e88 | ||
|
|
5c2326e492 | ||
|
|
47faadef51 | ||
|
|
aa26501100 | ||
|
|
d333d53e9c | ||
|
|
ba315014fa | ||
|
|
4a9f040c32 | ||
|
|
13de58fdbd | ||
|
|
40111b95c1 | ||
|
|
f03c6edec1 | ||
|
|
840898ec9a | ||
|
|
a906a98cce | ||
|
|
962b76dd8b | ||
|
|
23bbae8a74 | ||
|
|
8387f56048 | ||
|
|
68acf5f986 | ||
|
|
785dade6b2 | ||
|
|
8e93a92fcc | ||
|
|
4393fc6f12 | ||
|
|
cba38b58c3 | ||
|
|
1ff43b3557 | ||
|
|
bfc2253f4d | ||
|
|
fb790200d4 | ||
|
|
fc2c4de50f | ||
|
|
a947882449 | ||
|
|
192b843a85 | ||
|
|
cd0627e8b8 | ||
|
|
46256f6332 | ||
|
|
9935db4bb1 | ||
|
|
18761eb5b3 | ||
|
|
bf8db1be52 | ||
|
|
9fea65bd52 | ||
|
|
fe8e329fea | ||
|
|
6ac543128e | ||
|
|
3a643da14e | ||
|
|
8cbc0d65dc | ||
|
|
4ac81f1ceb | ||
|
|
032f4f357a | ||
|
|
35e1262676 | ||
|
|
5c86f4dbb3 | ||
|
|
a32b87334f | ||
|
|
4858d82ce3 | ||
|
|
6f6115d5cb | ||
|
|
b67297f160 | ||
|
|
6f95fc2565 | ||
|
|
827b34e1dd | ||
|
|
35543e6f06 | ||
|
|
6c96fe2f46 | ||
|
|
9ce64b2d58 | ||
|
|
caa586ceb4 | ||
|
|
59b6dfb841 | ||
|
|
abe7f0dafd | ||
|
|
eeada5468b | ||
|
|
6b36480097 | ||
|
|
25d15390ef | ||
|
|
7ff7decbb6 | ||
|
|
4cbdea4143 | ||
|
|
38da639e26 | ||
|
|
b1860eac21 | ||
|
|
c9d300769c | ||
|
|
2ae60003d6 | ||
|
|
a74c1c7b6e | ||
|
|
3c3a18cf6b | ||
|
|
5bd6455f7f | ||
|
|
5a9f5813c8 | ||
|
|
a43f0e6908 | ||
|
|
5a5125967f | ||
|
|
e1ebb70035 | ||
|
|
05bc598405 | ||
|
|
2764fd6dd5 | ||
|
|
a98625876d | ||
|
|
aedc98cc8b | ||
|
|
a2dfc627a7 | ||
|
|
a2cab6198e | ||
|
|
766368bace | ||
|
|
fee2cef980 | ||
|
|
95bc310def | ||
|
|
0b7bc27a5f | ||
|
|
bc7950b245 | ||
|
|
321bac6c9f | ||
|
|
cffdc3ced9 | ||
|
|
ca14838212 | ||
|
|
331ee52ea3 | ||
|
|
16c3625b0b | ||
|
|
6392ce1727 | ||
|
|
181f090901 | ||
|
|
61a8849e2d | ||
|
|
252b6fd0bf | ||
|
|
a76d1dec3b | ||
|
|
143aca64dc | ||
|
|
3dc3f37cf6 | ||
|
|
deff8d8741 | ||
|
|
beae4277ca | ||
|
|
be7d1bdc73 | ||
|
|
2eaf399441 | ||
|
|
65f902fbcf | ||
|
|
5df0fa93b3 | ||
|
|
67b9416f64 | ||
|
|
8255597fd5 | ||
|
|
633bef7660 | ||
|
|
dfe4991177 | ||
|
|
8daa05f710 | ||
|
|
62434bcedb | ||
|
|
6272f62e85 | ||
|
|
4c8028696f | ||
|
|
355f6a96ff | ||
|
|
bdcfc26af7 | ||
|
|
d2c4f2aa23 | ||
|
|
41656235fc | ||
|
|
26e79e7baa | ||
|
|
cfecf542ca | ||
|
|
edd0b5195d | ||
|
|
232d560cc4 | ||
|
|
b8b56584bd | ||
|
|
ce2daaf6c4 | ||
|
|
78d9e0bd2a | ||
|
|
55695ba06c | ||
|
|
ca3514d1d2 | ||
|
|
b2db3755d8 | ||
|
|
606c1895a9 | ||
|
|
968b12c4ac | ||
|
|
0f3cbaec3d | ||
|
|
2614efe601 | ||
|
|
eb6bd646c8 | ||
|
|
65147870fd | ||
|
|
586f0bba68 | ||
|
|
c4b26d70b5 | ||
|
|
8cbc58f775 | ||
|
|
8740cc7685 | ||
|
|
506c39896a | ||
|
|
9db34fd90e | ||
|
|
ae4353cc4b | ||
|
|
bde58fbf60 | ||
|
|
01b399e4a6 | ||
|
|
6235ffd0dc | ||
|
|
4504276563 | ||
|
|
96da39923d | ||
|
|
8633650f82 | ||
|
|
182091c21a | ||
|
|
7bed9ad7b8 | ||
|
|
7eb4238efd | ||
|
|
ea74c8885f | ||
|
|
7cdf463e4e | ||
|
|
850f910b96 | ||
|
|
4492696e3d | ||
|
|
dc74020f2d |
67
.env.example
67
.env.example
@@ -1,11 +1,18 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_NAME=VueFileManager
|
||||
APP_ENV=production
|
||||
APP_KEY=base64:sB1YuKsbWv7MdWugb9ZsYBqv2QZJ+QOuHZHEddOsUuo=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEMO=false
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
SCOUT_DRIVER=tntsearch
|
||||
SCOUT_QUEUE=true
|
||||
|
||||
FILESYSTEM_DRIVER=
|
||||
CHUNK_SIZE=128
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
@@ -15,7 +22,7 @@ DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
QUEUE_CONNECTION=database
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
@@ -23,24 +30,46 @@ REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
MAIL_DRIVER=
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=
|
||||
MAIL_USERNAME=
|
||||
MAIL_PASSWORD=
|
||||
MAIL_ENCRYPTION=
|
||||
MAIL_FROM_ADDRESS="${MAIL_USERNAME}"
|
||||
MAIL_FROM_NAME="${MAIL_USERNAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_DEFAULT_REGION=
|
||||
AWS_BUCKET=
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
DO_SPACES_KEY=
|
||||
DO_SPACES_SECRET=
|
||||
DO_SPACES_ENDPOINT=
|
||||
DO_SPACES_REGION=
|
||||
DO_SPACES_BUCKET=
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
WASABI_KEY=
|
||||
WASABI_SECRET=
|
||||
WASABI_ENDPOINT=
|
||||
WASABI_REGION=
|
||||
WASABI_BUCKET=
|
||||
|
||||
BACKBLAZE_KEY=
|
||||
BACKBLAZE_SECRET=
|
||||
BACKBLAZE_ENDPOINT=
|
||||
BACKBLAZE_REGION=
|
||||
BACKBLAZE_BUCKET=
|
||||
|
||||
PASSPORT_CLIENT_ID=
|
||||
PASSPORT_CLIENT_SECRET=
|
||||
|
||||
APP_DEPLOY_SECRET=
|
||||
|
||||
CASHIER_LOGGER=stack
|
||||
CASHIER_CURRENCY=
|
||||
STRIPE_KEY=
|
||||
STRIPE_SECRET=
|
||||
STRIPE_WEBHOOK_SECRET=
|
||||
CASHIER_PAYMENT_NOTIFICATION=App\Notifications\ConfirmPayment
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,14 +1,21 @@
|
||||
/app/Console/Commands/SetupDevelopmentEnvironment.php
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/*.index
|
||||
/storage/framework/cache/*
|
||||
/vendor
|
||||
/resources/babel.babel
|
||||
.idea
|
||||
.env
|
||||
.env.backup
|
||||
.phpunit.result.cache
|
||||
.phpstorm.meta.php
|
||||
.vscode/
|
||||
_ide_helper.php
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
prettier.json
|
||||
|
||||
3
.htaccess
Normal file
3
.htaccess
Normal file
@@ -0,0 +1,3 @@
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_URI} !^public
|
||||
RewriteRule ^(.*)$ public/$1 [L]
|
||||
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/vue-filemanager-laravel.iml" filepath="$PROJECT_DIR$/.idea/vue-filemanager-laravel.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
128
.idea/php.xml
generated
128
.idea/php.xml
generated
@@ -1,128 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
|
||||
<path value="$PROJECT_DIR$/vendor/gabrielelana/byte-units" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
|
||||
<path value="$PROJECT_DIR$/vendor/asm89/stack-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/psy/psysh" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
|
||||
<path value="$PROJECT_DIR$/vendor/mockery/mockery" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
|
||||
<path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
|
||||
<path value="$PROJECT_DIR$/vendor/intervention/image" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
|
||||
<path value="$PROJECT_DIR$/vendor/monolog/monolog" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpoption/phpoption" />
|
||||
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/opis/closure" />
|
||||
<path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
|
||||
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
|
||||
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/teamtnt/laravel-scout-tntsearch-driver" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
|
||||
<path value="$PROJECT_DIR$/vendor/teamtnt/tntsearch" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
|
||||
<path value="$PROJECT_DIR$/vendor/composer" />
|
||||
<path value="$PROJECT_DIR$/vendor/fideloper/proxy" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-token-stream" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
|
||||
<path value="$PROJECT_DIR$/vendor/dnoegel/php-xdg-base-dir" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/ramsey/uuid" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/flysystem" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/debug" />
|
||||
<path value="$PROJECT_DIR$/vendor/erusev/parsedown" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-iconv" />
|
||||
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/console" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/process" />
|
||||
<path value="$PROJECT_DIR$/vendor/swiftmailer/swiftmailer" />
|
||||
<path value="$PROJECT_DIR$/vendor/fzaninotto/faker" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpspec/prophecy" />
|
||||
<path value="$PROJECT_DIR$/vendor/askedio/laravel-soft-cascade" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/framework" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/scout" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/tinker" />
|
||||
<path value="$PROJECT_DIR$/vendor/hamcrest/hamcrest-php" />
|
||||
<path value="$PROJECT_DIR$/vendor/dragonmantank/cron-expression" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
|
||||
<path value="$PROJECT_DIR$/vendor/beyondcode/laravel-dump-server" />
|
||||
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
|
||||
<path value="$PROJECT_DIR$/vendor/nunomaduro/collision" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
|
||||
<path value="$PROJECT_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
|
||||
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
|
||||
<path value="$PROJECT_DIR$/vendor/filp/whoops" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
|
||||
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-color" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/container" />
|
||||
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-highlighter" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/log" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
|
||||
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/passport" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/event" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/oauth2-server" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/flare-client-php" />
|
||||
<path value="$PROJECT_DIR$/vendor/defuse/php-encryption" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpseclib/phpseclib" />
|
||||
<path value="$PROJECT_DIR$/vendor/laminas/laminas-zendframework-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
|
||||
<path value="$PROJECT_DIR$/vendor/laminas/laminas-diactoros" />
|
||||
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
|
||||
<path value="$PROJECT_DIR$/vendor/fruitcake/laravel-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/scrivo/highlight.php" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
|
||||
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/commonmark" />
|
||||
<path value="$PROJECT_DIR$/vendor/php-http/message-factory" />
|
||||
<path value="$PROJECT_DIR$/vendor/nyholm/psr7" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
|
||||
<component name="PhpUnit">
|
||||
<phpunit_settings>
|
||||
<PhpUnitSettings load_method="CUSTOM_LOADER" configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
|
||||
</phpunit_settings>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
34
.idea/vue-filemanager-laravel.iml
generated
34
.idea/vue-filemanager-laravel.iml
generated
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Tests\" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/defuse/php-encryption" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/flare-client-php" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/ignition" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/ignition-contracts" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/firebase/php-jwt" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/fruitcake/laravel-cors" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laminas/laminas-diactoros" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laminas/laminas-zendframework-bridge" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/passport" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/jwt" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/commonmark" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/event" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/oauth2-server" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/nyholm/psr7" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/php-http/message-factory" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpseclib/phpseclib" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/scrivo/highlight.php" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/psr-http-message-bridge" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
4
.idea/watcherTasks.xml
generated
4
.idea/watcherTasks.xml
generated
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectTasksOptions" suppressed-tasks="SCSS" />
|
||||
</project>
|
||||
739
.idea/workspace.xml
generated
739
.idea/workspace.xml
generated
@@ -1,739 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="6ba7f65e-b845-4413-bbbb-cad4b4fb5f38" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.editorconfig" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/vue-filemanager-laravel.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vue-filemanager-laravel.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/FileManagerFile.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/FileManagerFile.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/FileManagerFolder.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/FileManagerFolder.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/FileManagerController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/FileManagerController.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/vuefilemanager.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/vuefilemanager.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/css/app.css" beforeDir="false" afterPath="$PROJECT_DIR$/public/css/app.css" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/js/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/public/js/main.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/mix-manifest.json" beforeDir="false" afterPath="$PROJECT_DIR$/public/mix-manifest.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManager.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManager.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Auth.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Auth.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/Alert.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/Alert.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ContextMenu.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ContextMenu.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/DesktopToolbar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/DesktopToolbar.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileInfoPanel.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileInfoPanel.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileItemList.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileItemList.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FilesContainer.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FilesContainer.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileActionButton.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileActionButton.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileActionButtonUpload.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileActionButtonUpload.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileOptionList.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileOptionList.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileToolbar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/MobileToolbar.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButton.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButton.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/PageHeader.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/PageHeader.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/TextLabel.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/TextLabel.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/StorageSize.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/StorageSize.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/UserHeadline.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/UserHeadline.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/UserSettings.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/UserSettings.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/components/router.js" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/helpers.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/helpers.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/store/modules/filesView.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/store/modules/filesView.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/store/modules/userAuth.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/store/modules/userAuth.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/sass/vue-file-manager/_forms.scss" beforeDir="false" afterPath="$PROJECT_DIR$/resources/sass/vue-file-manager/_forms.scss" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/views/index.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/index.blade.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/webpack.mix.js" beforeDir="false" afterPath="$PROJECT_DIR$/webpack.mix.js" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ComposerSettings" doNotAsk="true" synchronizationState="SYNCHRONIZE">
|
||||
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
|
||||
<execution>
|
||||
<executable />
|
||||
</execution>
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Auth.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="201">
|
||||
<caret line="516" column="13" selection-start-line="516" selection-start-column="13" selection-end-line="516" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/resources/sass/vue-file-manager/_forms.scss">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="112">
|
||||
<caret line="28" column="26" lean-forward="true" selection-start-line="28" selection-start-column="26" selection-end-line="28" selection-end-column="26" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>SET_AUTHORIZED</find>
|
||||
<find>error.data</find>
|
||||
<find>SET_START_DIREC</find>
|
||||
<find>Nunito:400</find>
|
||||
<find>context</find>
|
||||
<find>token</find>
|
||||
<find>cookie</find>
|
||||
<find>getAppData</find>
|
||||
<find>SET_AUT</find>
|
||||
<find>PublicCloud</find>
|
||||
<find>Illuminate\Http\Response</find>
|
||||
<find>$updateText</find>
|
||||
<find>...map</find>
|
||||
<find>...mapGetters</find>
|
||||
<find>access_token</find>
|
||||
<find>user_account_capacity</find>
|
||||
<find>'bo</find>
|
||||
<find>SET_CURRENT</find>
|
||||
<find>logOut</find>
|
||||
<find>255</find>
|
||||
<find>_forms</find>
|
||||
<find>limit</find>
|
||||
<find>max_file_uploads</find>
|
||||
<find>post_max_size</find>
|
||||
<find>uploadFiles</find>
|
||||
<find>whereIn</find>
|
||||
<find>trash</find>
|
||||
<find>you exceed your storage</find>
|
||||
<find>deleted_files</find>
|
||||
<find>trashed_files</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="FrameworkCommandLineHistory">
|
||||
<commandsHistory>
|
||||
<command text="npm update" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm update" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm update" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm remove sass-loader" />
|
||||
<command text="npm update" />
|
||||
<command text="npm rebuild" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm run hot" />
|
||||
<command text="php artisan make:controller AppFunctionsController" />
|
||||
<command text="php artisan dump-autoload" />
|
||||
<command text="composer dump-autoload" />
|
||||
<command text="php artisan serve" />
|
||||
<command text="composer update" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm run hot" />
|
||||
<command text="php artisan serve" />
|
||||
<command text="npm run hot" />
|
||||
<command text="php artisan serve" />
|
||||
<command text="npm run hot" />
|
||||
<command text="npm run prod" />
|
||||
<command text="npm run hot" />
|
||||
<command text="npm run prod" />
|
||||
</commandsHistory>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="mock:///Dummy.txt" root0="SKIP_INSPECTION" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/package.json" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Middleware/Authenticate.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/bootstrap.js" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Middleware/CookieAuth.php" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Kernel.php" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Middleware/EncryptCookies.php" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/PrivateCLoud/AuthController.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/main.js" />
|
||||
<option value="$PROJECT_DIR$/resources/js/store/modules/app.js" />
|
||||
<option value="$PROJECT_DIR$/.gitignore" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/PrivateCLoud/FileManagerController.php" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/PrivateCLoud/UserAccountController.php" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/AppFunctionsController.php" />
|
||||
<option value="$PROJECT_DIR$/resources/sass/app.scss" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/UserImageInput.vue" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/Auth/AuthController.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/StorageSize.vue" />
|
||||
<option value="$PROJECT_DIR$/app/Http/helpers.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar/UserHeadline.vue" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/UserAccountController.php" />
|
||||
<option value="$PROJECT_DIR$/routes/web.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/store/modules/userAuth.js" />
|
||||
<option value="$PROJECT_DIR$/resources/js/App.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManager.vue" />
|
||||
<option value="$PROJECT_DIR$/.env" />
|
||||
<option value="$USER_HOME$/Desktop/vue-file-manager-file-manager-127.0.0.111-03-2020" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/var/www/devvuefilemanagerlaravel.hi5ve.digital/.env" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/etc/apache2/sites-available/devvuefilemanager.hi5ve.digital.conf" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/var/www/devvuefilemanager.hi5ve.digital/.env" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/UserSettings.vue" />
|
||||
<option value="$PROJECT_DIR$/app/FileManagerFile.php" />
|
||||
<option value="$PROJECT_DIR$/routes/api.php" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/var/www/devvuefilemanager.hi5ve.digital/config/vuefilemanager.php" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/var/www/devvuefilemanager.hi5ve.digital/public/info.php" />
|
||||
<option value="<d768a9d2-ae0a-4b11-a436-c632a530c3ce>/etc/php/7.3/apache2/php.ini" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/Alert.vue" />
|
||||
<option value="$PROJECT_DIR$/app/Http/Controllers/FileManagerController.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileItemList.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/TextLabel.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/helpers.js" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView.vue" />
|
||||
<option value="$PROJECT_DIR$/webpack.mix.js" />
|
||||
<option value="$PROJECT_DIR$/public/mix-manifest.json" />
|
||||
<option value="$PROJECT_DIR$/resources/views/index.blade.php" />
|
||||
<option value="$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Auth.vue" />
|
||||
<option value="$PROJECT_DIR$/resources/js/store/modules/filesView.js" />
|
||||
<option value="$PROJECT_DIR$/app/FileManagerFolder.php" />
|
||||
<option value="$PROJECT_DIR$/config/vuefilemanager.php" />
|
||||
<option value="$PROJECT_DIR$/resources/sass/vue-file-manager/_forms.scss" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="PhpWorkspaceProjectConfiguration">
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
|
||||
<path value="$PROJECT_DIR$/vendor/gabrielelana/byte-units" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
|
||||
<path value="$PROJECT_DIR$/vendor/asm89/stack-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/psy/psysh" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
|
||||
<path value="$PROJECT_DIR$/vendor/mockery/mockery" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
|
||||
<path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
|
||||
<path value="$PROJECT_DIR$/vendor/intervention/image" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
|
||||
<path value="$PROJECT_DIR$/vendor/monolog/monolog" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpoption/phpoption" />
|
||||
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/opis/closure" />
|
||||
<path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
|
||||
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
|
||||
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/teamtnt/laravel-scout-tntsearch-driver" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
|
||||
<path value="$PROJECT_DIR$/vendor/teamtnt/tntsearch" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
|
||||
<path value="$PROJECT_DIR$/vendor/composer" />
|
||||
<path value="$PROJECT_DIR$/vendor/fideloper/proxy" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-token-stream" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
|
||||
<path value="$PROJECT_DIR$/vendor/dnoegel/php-xdg-base-dir" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/ramsey/uuid" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/flysystem" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/debug" />
|
||||
<path value="$PROJECT_DIR$/vendor/erusev/parsedown" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-iconv" />
|
||||
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/console" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/process" />
|
||||
<path value="$PROJECT_DIR$/vendor/swiftmailer/swiftmailer" />
|
||||
<path value="$PROJECT_DIR$/vendor/fzaninotto/faker" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpspec/prophecy" />
|
||||
<path value="$PROJECT_DIR$/vendor/askedio/laravel-soft-cascade" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/framework" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/scout" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/tinker" />
|
||||
<path value="$PROJECT_DIR$/vendor/hamcrest/hamcrest-php" />
|
||||
<path value="$PROJECT_DIR$/vendor/dragonmantank/cron-expression" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
|
||||
<path value="$PROJECT_DIR$/vendor/beyondcode/laravel-dump-server" />
|
||||
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
|
||||
<path value="$PROJECT_DIR$/vendor/nunomaduro/collision" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
|
||||
<path value="$PROJECT_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
|
||||
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
|
||||
<path value="$PROJECT_DIR$/vendor/filp/whoops" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
|
||||
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-color" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/container" />
|
||||
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-highlighter" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/log" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
|
||||
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
|
||||
<path value="$PROJECT_DIR$/vendor/laravel/passport" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/event" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/oauth2-server" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/flare-client-php" />
|
||||
<path value="$PROJECT_DIR$/vendor/defuse/php-encryption" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpseclib/phpseclib" />
|
||||
<path value="$PROJECT_DIR$/vendor/laminas/laminas-zendframework-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
|
||||
<path value="$PROJECT_DIR$/vendor/laminas/laminas-diactoros" />
|
||||
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
|
||||
<path value="$PROJECT_DIR$/vendor/fruitcake/laravel-cors" />
|
||||
<path value="$PROJECT_DIR$/vendor/scrivo/highlight.php" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
|
||||
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/commonmark" />
|
||||
<path value="$PROJECT_DIR$/vendor/php-http/message-factory" />
|
||||
<path value="$PROJECT_DIR$/vendor/nyholm/psr7" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" fullScreen="true">
|
||||
<option name="width" value="1680" />
|
||||
<option name="height" value="1050" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="vue-filemanager-laravel-v1.1" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vue-filemanager-laravel-v1.1" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||
<property name="WebServerToolWindowFactoryState" value="true" />
|
||||
<property name="WebServerToolWindowPanel.toolwindow.highlight.mappings" value="true" />
|
||||
<property name="WebServerToolWindowPanel.toolwindow.highlight.symlinks" value="true" />
|
||||
<property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
|
||||
<property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
|
||||
<property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/resources/sass" />
|
||||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
||||
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
||||
<property name="nodejs_package_manager_path" value="npm" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/app/Http/Controllers" />
|
||||
<recent name="$PROJECT_DIR$/resources/sass/vue-file-manager" />
|
||||
<recent name="$PROJECT_DIR$/app/Http/Controllers/PrivateCLoud" />
|
||||
</key>
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/resources/sass" />
|
||||
<recent name="$PROJECT_DIR$/resources/js" />
|
||||
<recent name="$PROJECT_DIR$/public/assets/images" />
|
||||
<recent name="$PROJECT_DIR$/app/Http/Controllers/PublicCloud" />
|
||||
<recent name="$PROJECT_DIR$/app" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="phpunit.xml" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
|
||||
<TestRunner scope="XML" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="6ba7f65e-b845-4413-bbbb-cad4b4fb5f38" name="Default Changelist" comment="" />
|
||||
<created>1582538406416</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1582538406416</updated>
|
||||
<workItem from="1582538408226" duration="28590000" />
|
||||
<workItem from="1583169038847" duration="49277000" />
|
||||
<workItem from="1583771973016" duration="47540000" />
|
||||
<workItem from="1584014365621" duration="499000" />
|
||||
<workItem from="1584201902438" duration="1297000" />
|
||||
<workItem from="1584205890781" duration="1931000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="129134000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="0" width="1680" height="1050" extended-state="0" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.15654762" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="npm" order="2" side_tool="true" />
|
||||
<window_info id="Favorites" order="3" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.3295238" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Version Control" order="8" />
|
||||
<window_info anchor="bottom" id="Database Changes" order="9" />
|
||||
<window_info active="true" anchor="bottom" id="Command Line Tools Console" order="10" visible="true" weight="0.36761904" />
|
||||
<window_info anchor="bottom" id="Terminal" order="11" weight="0.3295238" />
|
||||
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" />
|
||||
<window_info anchor="bottom" id="File Transfer" order="13" weight="0.3295238" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
<window_info anchor="right" id="Database" order="3" />
|
||||
<window_info anchor="right" id="Remote Host" order="4" weight="0.23869048" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-RlTVKdTenHVQeDuC-8f8b71f93d874c58899eae34ff855b91.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-qu7zENEPpyXacK9u-8acb7489e4354e9fa12b786f4f1014b3.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-PwOYrH3X4Q5MFNnJ-b828ce5c1d014deab79c6b1ac8dd5500.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-PeK8nBe7vKFR2DXN-8480033d08b555735bcc1df441eeec0f.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-Ogjq9EIILgeojKDb-nf88xyvvCWOJHY93-kitchen-island.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-NfLjyaaboBPCGi3X-7bec4e11b047456780d83011701a662c.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-md1FYpic11mXzsMH-59352395_2290695347810363_751927439731487941_n.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-lnh7N5vgH74DhOOh-57bad2c20c758f20b83b2344212a2a93.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-ddGQjKsXe6smj3Jx-7bec4e11b047456780d83011701a662c.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-eIXPHBrXEjqxydte-d5410c8079e3a3970303779305d11048.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-Fg3cXWFgEn6Cmt5M-6f5362be8aca06dc4ea234865ac49736.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-fNx1iGh1lpGyS66P-af0c68fb4d3b82da011ca4b0c18c8a65.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-Gv6TX9lZl8TZ5kCK-8f8b71f93d874c58899eae34ff855b91.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-HlK34TY0sfw4lDk3-nf88xyvvCWOJHY93-kitchen-island.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-i2BdCpXqXyMcS5oB-ea7afab3993a45c3a88ee7eb9ce42a8e.jpg.1280x0_q85.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-IseiNdZqCg7dQRD0-ItWorksOnMyMachine.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-Jaupegd57IHxsSGE-57bad2c20c758f20b83b2344212a2a93.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/storage/app/file-manager/thumbnail-JVdvcCD7WcFNG6MF-ViewOfElephantinWater.jpg">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Sidebar.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="363">
|
||||
<caret line="194" column="9" selection-start-line="194" selection-start-column="9" selection-end-line="194" selection-end-column="9" />
|
||||
<folding>
|
||||
<element signature="n#div#0;n#div#0;n#transition#0;n#template#0;n#!!top" />
|
||||
<element signature="e#3246#3349#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/Alert.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="713">
|
||||
<caret line="89" column="17" selection-start-line="89" selection-start-column="17" selection-end-line="89" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/Http/helpers.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="330">
|
||||
<caret line="116" column="22" selection-start-line="116" selection-start-column="9" selection-end-line="116" selection-end-column="22" />
|
||||
<folding>
|
||||
<element signature="n#store_avatar#0;n#!!top" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/helpers.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="320">
|
||||
<caret line="148" column="38" selection-start-line="148" selection-start-column="22" selection-end-line="148" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#0#33#0" expanded="true" />
|
||||
<element signature="e#201#287#0" />
|
||||
<element signature="e#730#1219#0" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ToolbarButtonUpload.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="280">
|
||||
<caret line="10" column="60" selection-start-line="10" selection-start-column="60" selection-end-line="10" selection-end-column="60" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/FileItemList.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="448">
|
||||
<caret line="47" column="77" selection-start-line="47" selection-start-column="59" selection-end-line="47" selection-end-column="77" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Others/TextLabel.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="672">
|
||||
<caret line="24" selection-start-line="21" selection-start-column="27" selection-end-line="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.editorconfig">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.env">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManager.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="560">
|
||||
<caret line="20" column="26" selection-start-line="20" selection-start-column="17" selection-end-line="20" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#618#695#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="187">
|
||||
<caret line="57" column="40" selection-start-line="57" selection-start-column="40" selection-end-line="57" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="e#314#409#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/public/mix-manifest.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="56">
|
||||
<caret line="2" column="35" selection-start-line="2" selection-start-column="35" selection-end-line="2" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/DemoPageComponents/MobileMenu.vue">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/main.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/App.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="56">
|
||||
<caret line="2" column="31" lean-forward="true" selection-start-line="2" selection-start-column="31" selection-end-line="2" selection-end-column="31" />
|
||||
<folding>
|
||||
<element signature="n#style#0;n#VueFileManager#0;n#div#0;n#template#0;n#!!top" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/webpack.mix.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="476">
|
||||
<caret line="17" column="14" lean-forward="true" selection-start-line="17" selection-start-column="14" selection-end-line="17" selection-end-column="14" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.styleci.yml">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/config/auth.php">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/store/modules/filesView.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="594">
|
||||
<caret line="185" column="48" selection-start-line="185" selection-start-column="12" selection-end-line="185" selection-end-column="48" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/store/modules/userAuth.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2734">
|
||||
<caret line="101" column="4" selection-start-line="101" selection-start-column="4" selection-end-line="101" selection-end-column="4" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/FilesView/ContextMenu.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="442">
|
||||
<caret line="50" column="51" selection-start-line="50" selection-start-column="51" selection-end-line="50" selection-end-column="51" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/AppFunctionsController.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-186">
|
||||
<caret line="8" column="6" selection-start-line="8" selection-start-column="6" selection-end-line="8" selection-end-column="6" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/FileManagerFolder.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="3342">
|
||||
<caret line="120" column="5" selection-start-line="120" selection-start-column="5" selection-end-line="120" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#23#41#0#PHP" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/FileManagerFile.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-1682">
|
||||
<caret line="13" column="6" selection-start-line="13" selection-start-column="6" selection-end-line="13" selection-end-column="6" />
|
||||
<folding>
|
||||
<element signature="e#23#44#0#PHP" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/Auth/AuthController.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-2678">
|
||||
<caret line="19" column="6" selection-start-line="19" selection-start-column="6" selection-end-line="19" selection-end-column="6" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/UserAccountController.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-3070">
|
||||
<caret line="14" column="6" selection-start-line="14" selection-start-column="6" selection-end-line="14" selection-end-column="6" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/Http/Controllers/FileManagerController.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-11946">
|
||||
<caret line="164" column="49" lean-forward="true" selection-start-line="164" selection-start-column="49" selection-end-line="164" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="e#40#67#0#PHP" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/views/index.blade.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="326">
|
||||
<caret line="26" column="46" selection-start-line="26" selection-start-column="46" selection-end-line="26" selection-end-column="46" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/config/vuefilemanager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="308">
|
||||
<caret line="11" column="35" selection-start-line="11" selection-start-column="35" selection-end-line="11" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/routes/web.php">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/routes/api.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-40">
|
||||
<caret line="45" column="37" selection-start-line="45" selection-start-column="37" selection-end-line="45" selection-end-column="37" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/js/components/VueFileManagerComponents/Auth.vue">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="201">
|
||||
<caret line="516" column="13" selection-start-line="516" selection-start-column="13" selection-end-line="516" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/resources/sass/vue-file-manager/_forms.scss">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="112">
|
||||
<caret line="28" column="26" lean-forward="true" selection-start-line="28" selection-start-column="26" selection-end-line="28" selection-end-column="26" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
1893
.phpstorm.meta.php
Normal file
1893
.phpstorm.meta.php
Normal file
File diff suppressed because it is too large
Load Diff
418
README.md
418
README.md
@@ -1,78 +1,380 @@
|
||||
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
|
||||

|
||||
# Private Cloud Storage Build on Laravel & Vue.js
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
||||
</p>
|
||||
## Contents
|
||||
|
||||
## About Laravel
|
||||
- [Installation](#installation)
|
||||
- [Server Requirements](#server-requirements)
|
||||
- [Installation](#installation)
|
||||
- [PHP Configuration](#php-configuration)
|
||||
- [Chunk Upload](#chunk-upload)
|
||||
- [Upgrade Guide](#upgrade-guide)
|
||||
- [Common Instructions](#common-instructions)
|
||||
- [Update from 1.7.12 to 1.8](#update-from-1712-to-18)
|
||||
- [Update from 1.7.10 to 1.7.11](#update-from-1710-to-1711)
|
||||
- [Update from 1.7.8 to 1.7.9](#update-from-178-to-179)
|
||||
- [Update from 1.7.x to 1.7.8](#update-from-17x-to-178)
|
||||
- [Update from 1.6.x to 1.7](#update-from-16x-to-17)
|
||||
- [Nginx Configuration](#nginx-configuration)
|
||||
- [Apache Configuration](#apache-configuration)
|
||||
- [Payments](#payments)
|
||||
- [Get your active plans](#get-your-active-plans)
|
||||
- [Manage Failed Payments](#manage-failed-payments)
|
||||
- [Tax Rates](#tax-rates)
|
||||
- [Developers](#developers)
|
||||
- [Running development environment on your localhost](#running-development-environment-on-your-localhost)
|
||||
- [Supported Storages](#supported-storages)
|
||||
- [How to Create New Language](#how-to-create-new-language)
|
||||
- [Others](#others)
|
||||
- [Changelog](#changelog)
|
||||
- [GitHub Repository](#github-repository)
|
||||
- [Support](#support)
|
||||
- [Security Vulnerabilities](#security-vulnerabilities)
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
# Installation
|
||||
## Server Requirements
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
**For running app make sure you have installed:**
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
- PHP >= 7.2.5 version
|
||||
- MySQL 5.6+
|
||||
- Nginx or Apache
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
**These PHP Extensions are required:**
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
- GD
|
||||
- BCMath
|
||||
- PDO
|
||||
- SQLite
|
||||
- Ctype
|
||||
- Fileinfo
|
||||
- JSON
|
||||
- Mbstring
|
||||
- OpenSSL
|
||||
- Tokenizer
|
||||
- XML
|
||||
- Exif
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[British Software Development](https://www.britishsoftware.co)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- [UserInsights](https://userinsights.com)
|
||||
- [Fragrantica](https://www.fragrantica.com)
|
||||
- [SOFTonSOFA](https://softonsofa.com/)
|
||||
- [User10](https://user10.com)
|
||||
- [Soumettre.fr](https://soumettre.fr/)
|
||||
- [CodeBrisk](https://codebrisk.com)
|
||||
- [1Forge](https://1forge.com)
|
||||
- [TECPRESSO](https://tecpresso.co.jp/)
|
||||
- [Runtime Converter](http://runtimeconverter.com/)
|
||||
- [WebL'Agence](https://weblagence.com/)
|
||||
- [Invoice Ninja](https://www.invoiceninja.com)
|
||||
- [iMi digital](https://www.imi-digital.de/)
|
||||
- [Earthlink](https://www.earthlink.ro/)
|
||||
- [Steadfast Collective](https://steadfastcollective.com/)
|
||||
- [We Are The Robots Inc.](https://watr.mx/)
|
||||
- [Understand.io](https://www.understand.io/)
|
||||
- [Abdel Elrafa](https://abdelelrafa.com)
|
||||
- [Hyper Host](https://hyper.host)
|
||||
- [Appoly](https://www.appoly.co.uk)
|
||||
- [OP.GG](https://op.gg)
|
||||
## Installation
|
||||
|
||||
## Contributing
|
||||
#### 1. Upload files on your server
|
||||
Upload project files to web root folder of your domain. It's mostly located in `html`, `www` or `public_html` folder name.
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
#### 2. Configure your web root folder
|
||||
Configure your web server's document root to point to the public directory of the files you previously uploaded. For example, if you've uploaded the files in `html` folder, your domain root directory should be changed to `html/project_files/public` folder or anything else where domain root is in project `/public` directory.
|
||||
|
||||
## Code of Conduct
|
||||
Please don't try go to `yourdomain.com/public` URL address, you will have issue to verify your purchase code, this is not correct domain root setup, you must do this in your webhosting settings panel.
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||

|
||||
|
||||
#### 3. Check your .env file
|
||||
Make sure `.env` file was uploaded. This type of file can be hidden in default.
|
||||
|
||||
#### 3.1 When you install from GitHub
|
||||
When you download repository from GitHub, you have to rename your `.env.example` file to `.env`. Then run command below in your terminal to install vendors. Composer is required.
|
||||
```
|
||||
composer install
|
||||
```
|
||||
|
||||
#### 4. Set write permissions
|
||||
Set `755` permission (CHMOD) to these file and folders directory within all children subdirectories:
|
||||
|
||||
- /bootstrap/cache
|
||||
- /storage
|
||||
- /.env
|
||||
|
||||
#### 5. Open your application in your web browser
|
||||
Then open your application in web browser. If everything works fine, you will be redirect to setup wizard installation process.
|
||||
|
||||
At first step you have to verify your purchase code. **Subscription service with stripe payments is available only for Extended License.** If you can't verify your purchase code, check, if you did previously steps correctly.
|
||||
|
||||
#### 6. Follow setup wizard steps
|
||||
|
||||
That was the hardest part of installation proces. Please follow instructions in every step of Setup Wizard to successfully install VueFileManager.
|
||||
|
||||
#### 7. Set up Cron
|
||||
|
||||
Add the following Cron entry to your server. Just update your php path (if it's different) and project path:
|
||||
```
|
||||
* * * * * /usr/local/bin/php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
|
||||
```
|
||||
|
||||
## PHP Configuration
|
||||
There are several PHP settings good to know to setup before you try upload any file. Please set these values in your php.ini, we provide minimal setup for you. When you set `-1` then you set infinity limits.
|
||||
|
||||
```
|
||||
memory_limit = 512M
|
||||
upload_max_filesize = 128M
|
||||
post_max_size = 128M
|
||||
max_file_uploads = 50
|
||||
max_execution_time = 3600
|
||||
```
|
||||
|
||||
## Chunk & Multipart Upload
|
||||
VueFileManager in default supporting chunk upload. Default chunk upload size is `128MB`. If you wish change this default value, go to your `.env` and change `CHUNK_SIZE` attribute.
|
||||
|
||||
When you use external storage, and upload large files, to prevent failing upload process make sure you have enough space in your application space and set higher `max_execution_time` in your php.ini to move your files to external storage.
|
||||
|
||||
## Upgrade Guide
|
||||
|
||||
### Common Instructions
|
||||
`Don't forget create backup of your database before make any changes in your production application. If you serve your files in local storage driver pay attention and don't delete your /storage folder!`
|
||||
|
||||
These instructions is applicable for all updates. Please follow this step:
|
||||
|
||||
- Just rewrite all project files with new excluded `/.env` file and `/storage` folder. These items must be preserved!
|
||||
|
||||
### Update from 1.7.12 to 1.8
|
||||
- Before upload new files to your hosting, log in to VueFileManager as Admin. After uploading new files on your webhosting, visit this url `your-domain.com/service/upgrade-database` for upgrading your database.
|
||||
- Just rewrite all project files with new, excluded /.env file and /storage folder. These items must be preserved!
|
||||
- set **QUEUE_CONNECTION** to **database** in your **.env** file
|
||||
- Clear cache in your administration panel - Settings / Application / Clear Cache
|
||||
|
||||
If you are upgrading from GitHub, don't forget run `composer install` to install new vendors.
|
||||
|
||||
### Update from 1.7.10 to 1.7.11
|
||||
Before upload new files to your hosting, log in to VueFileManager as Admin. After uploading new files on your webhosting, visit this url `your-domain.com/service/upgrade-database` for upgrading your database.
|
||||
|
||||
### Update from 1.7.8 to 1.7.9
|
||||
After rewrited old files with new files, log in as admin to the app and go to `your-domain.com/service/upgrade-database`. This will upgrade your database on the background.
|
||||
|
||||
Add the following Cron entry to your server. Just update your php path (if it's different) and project path:
|
||||
```
|
||||
* * * * * /usr/local/bin/php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
|
||||
```
|
||||
|
||||
### Update from 1.7.x to 1.7.8
|
||||
For those who have installed VueFileManager via git or any other repository synchronization tool, dont't forget after updated code run `composer update` command to update your vendors.
|
||||
|
||||
### Update from 1.6.x to 1.7
|
||||
|
||||
For those, who purchase extended licence, place these lines at the end of your `/.env` file:
|
||||
```
|
||||
CASHIER_LOGGER=stack
|
||||
CASHIER_CURRENCY=
|
||||
STRIPE_KEY=
|
||||
STRIPE_SECRET=
|
||||
STRIPE_WEBHOOK_SECRET=
|
||||
CASHIER_PAYMENT_NOTIFICATION=App\Notifications\ConfirmPayment
|
||||
```
|
||||
|
||||
Then go to https://your-domain.com/upgrade and follow the setup wizard instructions.
|
||||
|
||||
## Nginx Configuration
|
||||
If you running VueFileManager undex Nginx, don't forget set this value in your `nginx.conf` file:
|
||||
```
|
||||
http {
|
||||
client_max_body_size 1024M;
|
||||
}
|
||||
```
|
||||
|
||||
And example Nginx config for your domain:
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
# Log files for Debugging
|
||||
access_log /var/log/nginx/laravel-access.log;
|
||||
error_log /var/log/nginx/laravel-error.log;
|
||||
|
||||
# Webroot Directory for Laravel project
|
||||
root /var/www/vuefilemanager/public;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
# Your Domain Name
|
||||
server_name example.com;
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# PHP-FPM Configuration Nginx
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Apache Configuration
|
||||
Make sure you have enabled mod_rewrite. There is an example config for running VueFileManager under apache:
|
||||
|
||||
```
|
||||
<VirtualHost example.com:80>
|
||||
DocumentRoot /var/www/vuefilemanager/public
|
||||
ServerName example.com
|
||||
|
||||
<Directory "/var/www/vuefilemanager/public">
|
||||
AllowOverride All
|
||||
allow from all
|
||||
Options +Indexes
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
RewriteEngine on
|
||||
RewriteCond %{SERVER_NAME} =example.com
|
||||
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
# Payments
|
||||
VueFileManager is packed with **Stripe** payment options. To configure Stripe, you will be asked in Setup Wizard to set up. Or, if you skip this installation process, you will find stripe set up in you admin `Dashboard / Settings / Payments`.
|
||||
|
||||
## Get your active plans
|
||||
Would you like to get your subscription plans for your custom front-end page? Create GET request and get all your active plans:
|
||||
```
|
||||
GET /api/public/pricing
|
||||
```
|
||||
|
||||
## Manage Failed Payments
|
||||
VueFileManager manage failed payments with additional email notification. But, there is more you can do for better User Experience. There is some additionals option in Stripe, look on [prevent failed payments](https://dashboard.stripe.com/settings/billing/automatic).
|
||||
|
||||
## Tax Rates
|
||||
You are able to manage tax rates. When adding a new tax rate, if no Region is specified, the tax rate will apply to everyone. Add a [ISO 3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) to the Region field if you wish to apply taxes per country.
|
||||
|
||||
Just log in to your stripe dashboard, and you will find taxes under `Dashboard / Products / Tax Rates`.
|
||||
|
||||
# Developers
|
||||
## Running development environment on your localhost
|
||||
|
||||
When you download repository from GitHub, you have to rename your `.env.example` file to `.env`. Then run command below in your terminal to install vendors. Composer is required.
|
||||
```
|
||||
composer install
|
||||
```
|
||||
|
||||
Set your `APP_ENV` to local mode, in default, it's in production mode.
|
||||
```
|
||||
APP_ENV=local
|
||||
```
|
||||
|
||||
Also, to debug application, set `APP_DEBUG` on true:
|
||||
```
|
||||
APP_DEBUG=true
|
||||
```
|
||||
|
||||
To start server on your localhost, run command below. Then go to your generated localhost URL by terminal, and follow Setup Wizard steps to configure VueFileManager.
|
||||
```
|
||||
php artisan serve
|
||||
```
|
||||
|
||||
After successfully installation via Setup Wizard, stop your artisan server, clear config cache and run your artisan server again:
|
||||
```
|
||||
php artisan config:clear
|
||||
php artisan serve
|
||||
```
|
||||
*After any change in your .env you have to restart your artisan server to reload your config cache.*
|
||||
|
||||
To develop your Vue front-end, you have to install npm modules by this command:
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
To compiles and hot-reloads for front-end development. Then run this command:
|
||||
```
|
||||
npm run hot
|
||||
```
|
||||
|
||||
To compiles for production build, run this command
|
||||
```
|
||||
npm run prod
|
||||
```
|
||||
|
||||
## Supported Storages
|
||||
VueFileManager support these storages for your files:
|
||||
|
||||
- [Amazon Web Services S3](https://aws.amazon.com/s3/)
|
||||
- [Digital Ocean Spaces](https://www.digitalocean.com/products/spaces/)
|
||||
- [Object Cloud Storage by Wasabi](https://wasabi.com/)
|
||||
- [Backblaze B2 Cloud Storage](https://www.backblaze.com/b2/cloud-storage.html)
|
||||
- Your local disk
|
||||
|
||||
In case of installation process, you will be able to set storage driver and credentials. After this, you can change your credentials later in `/.env` file.
|
||||
|
||||
To set or change your storage driver, you have to edit `FILESYSTEM_DRIVER` in your `/.env` file. Supported drivers are `s3`, `spaces`, `wasabi`,`backblaze` or `local`:
|
||||
```
|
||||
FILESYSTEM_DRIVER=local
|
||||
```
|
||||
Then you can find corresponding credentials options for your storage driver like key, secret, region in `/.env` file.
|
||||
|
||||
|
||||
## How to Create New Language
|
||||
VueFileManager front-end support i18n standard for localization. This mean, you can translate app to any language
|
||||
|
||||
### How to create translation for Vue Front-End
|
||||
Go to `/resources/js/i18n/lang` And make copy of `en.json` and rename it to your local name (eg: Slovak language has 'sk' shortcut, it means `sk.json`). If you have created your copy, then feel free to translate this file.
|
||||
|
||||
Open `/resources/js/i18n/index.js` import your new language and assign it to languages object:
|
||||
|
||||
```
|
||||
import Vue from 'vue';
|
||||
import VueI18n from 'vue-i18n';
|
||||
|
||||
import en from './lang/en.json'
|
||||
import sk from './lang/sk.json'
|
||||
|
||||
Vue.use(VueI18n);
|
||||
|
||||
const i18n = new VueI18n({
|
||||
locale: config.locale,
|
||||
messages: Object.assign({
|
||||
en,
|
||||
sk
|
||||
}),
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
```
|
||||
After this, you have to compile language to your application code via this command in your terminal:
|
||||
```
|
||||
npm run prod
|
||||
```
|
||||
|
||||
### How to Create Translation for Laravel Back-End
|
||||
Go to `/resources/lang/` And make copy of `en` folder and rename it to your local name (eg: Slovak language has 'sk' shortcut, it means `sk`). If you have created your copy, then feel free to translate this file.
|
||||
|
||||
### Set locale
|
||||
To set your locale in app, go to `/config/app.php` and set your locale string in `locale` option:
|
||||
|
||||
```
|
||||
'locale' => 'YOUR_LOCALE',
|
||||
```
|
||||
|
||||
**Small hint:** We use for translating localizations this awesome software, [check it](https://www.codeandweb.com/babeledit).
|
||||
|
||||
# Others
|
||||
## Changelog
|
||||
|
||||
Refer to the [Changelog](https://vuefilemanager.com/changelog) for a full history of the project.
|
||||
|
||||
## GitHub Repository
|
||||
[Join our GitHub repository](https://vuefilemanager.com/github-access) to submit your issues or suggestions, track VueFileManager progress and get new updates as fast as possible.
|
||||
|
||||
## Support
|
||||
|
||||
The following support channels are available at your fingertips:
|
||||
|
||||
- [CodeCanyon support message](https://codecanyon.net/item/vue-file-manager-with-laravel-backend/25815986/support)
|
||||
- [GitHub repository](https://vuefilemanager.com/github-access)
|
||||
|
||||
## Supporting VueFileManager
|
||||
Hi, we are trying make the best experience with VueFileManager. There is a lot things to do, and a lot of features we can make.
|
||||
|
||||
But, it can't be done without you, development is more and more complicated and we have to hire new colleagues to help with it. There is couple way you can support us, and then, we support you with all great new features which can be. Thanks you for participating on this awesome software!
|
||||
|
||||
- [Buy me a Coffe](https://www.buymeacoffee.com/pepe)
|
||||
- [Become a Patreon](https://www.patreon.com/vuefilemanager)
|
||||
- [One-time donation via PayPal](https://www.paypal.me/peterpapp)
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
If you discover a security vulnerability within this project, please send an e-mail to [peterpapp@makingcg.com](peterpapp@makingcg.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
17803
_ide_helper.php
Normal file
17803
_ide_helper.php
Normal file
File diff suppressed because it is too large
Load Diff
66
app/Console/Commands/Deploy.php
Normal file
66
app/Console/Commands/Deploy.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Deploy extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'deploy:production';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Automatic deployment for production';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Start deployment
|
||||
$this->info('Running auto deployment');
|
||||
$this->call('down');
|
||||
|
||||
// Exec commands
|
||||
exec('git pull origin ' . config('app.deploy_branch'));
|
||||
//exec('composer update --no-interaction --prefer-dist');
|
||||
$this->migrateDatabase();
|
||||
|
||||
// Stop deployment
|
||||
$this->call('up');
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
|
||||
Log::info('Application was updated!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate database
|
||||
*/
|
||||
public function migrateDatabase()
|
||||
{
|
||||
$this->call('migrate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\Deploy;
|
||||
|
||||
// use App\Console\Commands\SetupDevelopmentEnvironment;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProductionEnvironment;
|
||||
use App\Console\Commands\UpgradeApp;
|
||||
use App\Share;
|
||||
use App\Zip;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -13,19 +22,30 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
Deploy::class,
|
||||
// SetupDevelopmentEnvironment::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
$schedule->call(function () {
|
||||
$this->delete_expired_shared_links();
|
||||
})->everyMinute();
|
||||
|
||||
$schedule->call(function () {
|
||||
$this->delete_old_zips();
|
||||
})->everySixHours();
|
||||
|
||||
// Run queue jobs every minute
|
||||
$schedule->command('queue:work --tries=3')
|
||||
->everyMinute()
|
||||
->withoutOverlapping();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,8 +55,46 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete old zips
|
||||
*/
|
||||
protected function delete_old_zips(): void
|
||||
{
|
||||
// Get all zips
|
||||
$zips = Zip::where('created_at', '<=', Carbon::now()->subDay()->toDateTimeString())->get();
|
||||
|
||||
$zips->each(function ($zip) {
|
||||
|
||||
// Delete zip file
|
||||
\Storage::disk('local')->delete('zip/' . $zip->basename);
|
||||
|
||||
// Delete zip record
|
||||
$zip->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and delete expired shared links
|
||||
*/
|
||||
protected function delete_expired_shared_links(): void
|
||||
{
|
||||
// Get all shares with expiration time
|
||||
$shares = Share::whereNotNull('expire_in')->get();
|
||||
|
||||
$shares->each(function ($share) {
|
||||
|
||||
// Get dates
|
||||
$created_at = Carbon::parse($share->created_at);
|
||||
|
||||
// If time was over, then delete share record
|
||||
if ($created_at->diffInHours(Carbon::now()) >= $share->expire_in) {
|
||||
$share->delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
@@ -29,12 +29,12 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
@@ -43,13 +43,13 @@ class Handler extends ExceptionHandler
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,65 @@
|
||||
namespace App;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use \Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
|
||||
/**
|
||||
* App\FileManagerFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $user_id
|
||||
* @property int $unique_id
|
||||
* @property int $folder_id
|
||||
* @property string $thumbnail
|
||||
* @property string|null $name
|
||||
* @property string|null $basename
|
||||
* @property string|null $mimetype
|
||||
* @property string $filesize
|
||||
* @property string|null $type
|
||||
* @property string $user_scope
|
||||
* @property string $deleted_at
|
||||
* @property string $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\FileManagerFolder|null $folder
|
||||
* @property-read string $file_url
|
||||
* @property-read \App\FileManagerFolder $parent
|
||||
* @property-read \App\Share|null $shared
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFile onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereBasename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereFilesize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereFolderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereMimetype($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereThumbnail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereUniqueId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFile whereUserScope($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFile withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFile withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $metadata
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|FileManagerFile sortable($defaultParameters = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|FileManagerFile whereMetadata($value)
|
||||
*/
|
||||
class FileManagerFile extends Model
|
||||
{
|
||||
use Searchable, SoftDeletes, SoftCascadeTrait;
|
||||
use Searchable, SoftDeletes , Sortable;
|
||||
|
||||
public $public_access = null;
|
||||
|
||||
protected $guarded = [
|
||||
'id'
|
||||
@@ -24,6 +71,30 @@ class FileManagerFile extends Model
|
||||
'file_url'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'metadata' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $sortable = [
|
||||
'name',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Set routes with public access
|
||||
*
|
||||
* @param $token
|
||||
*/
|
||||
public function setPublicUrl($token)
|
||||
{
|
||||
$this->public_access = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format created at date
|
||||
*
|
||||
@@ -31,7 +102,7 @@ class FileManagerFile extends Model
|
||||
*/
|
||||
public function getCreatedAtAttribute()
|
||||
{
|
||||
return Carbon::create($this->attributes['created_at'])->format('j M Y \a\t H:i');;
|
||||
return format_date(set_time_by_user_timezone($this->attributes['created_at']), __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,15 +112,14 @@ class FileManagerFile extends Model
|
||||
*/
|
||||
public function getDeletedAtAttribute()
|
||||
{
|
||||
if (! $this->attributes['deleted_at']) return null;
|
||||
if (!$this->attributes['deleted_at']) return null;
|
||||
|
||||
return Carbon::create($this->attributes['deleted_at'])->format('j M Y at H:i');
|
||||
return format_date(set_time_by_user_timezone($this->attributes['deleted_at']), __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format filesize
|
||||
* Format fileSize
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getFilesizeAttribute()
|
||||
@@ -60,23 +130,65 @@ class FileManagerFile extends Model
|
||||
/**
|
||||
* Format thumbnail url
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getThumbnailAttribute()
|
||||
{
|
||||
return $this->attributes['thumbnail'] ? route('thumbnail', ['name' => $this->attributes['thumbnail']]) : null;
|
||||
// Get thumbnail from external storage
|
||||
if ($this->attributes['thumbnail'] && is_storage_driver(['s3', 'spaces', 'wasabi', 'backblaze'])) {
|
||||
|
||||
return Storage::temporaryUrl('file-manager/' . $this->attributes['thumbnail'], now()->addHour());
|
||||
}
|
||||
|
||||
// Get thumbnail from local storage
|
||||
if ($this->attributes['thumbnail']) {
|
||||
|
||||
// Thumbnail route
|
||||
$route = route('thumbnail', ['name' => $this->attributes['thumbnail']]);
|
||||
|
||||
if ($this->public_access) {
|
||||
return $route . '/public/' . $this->public_access;
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format file url
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getFileUrlAttribute()
|
||||
{
|
||||
return route('file', ['name' => $this->attributes['basename']]);
|
||||
// Get file from external storage
|
||||
if (is_storage_driver(['s3', 'spaces', 'wasabi', 'backblaze'])) {
|
||||
|
||||
$file_pretty_name = is_storage_driver('backblaze')
|
||||
? Str::snake(mb_strtolower($this->attributes['name']))
|
||||
: get_pretty_name($this->attributes['basename'], $this->attributes['name'], $this->attributes['mimetype']);
|
||||
|
||||
$header = [
|
||||
"ResponseAcceptRanges" => "bytes",
|
||||
"ResponseContentType" => $this->attributes['mimetype'],
|
||||
"ResponseContentLength" => $this->attributes['filesize'],
|
||||
"ResponseContentRange" => "bytes 0-600/" . $this->attributes['filesize'],
|
||||
'ResponseContentDisposition' => 'attachment; filename=' . $file_pretty_name,
|
||||
];
|
||||
|
||||
return Storage::temporaryUrl('file-manager/' . $this->attributes['basename'], now()->addDay(), $header);
|
||||
}
|
||||
|
||||
// Get thumbnail from local storage
|
||||
$route = route('file', ['name' => $this->attributes['basename']]);
|
||||
|
||||
if ($this->public_access) {
|
||||
return $route . '/public/' . $this->public_access;
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,4 +227,14 @@ class FileManagerFile extends Model
|
||||
{
|
||||
return $this->hasOne('App\FileManagerFolder', 'unique_id', 'folder_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sharing attributes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function shared()
|
||||
{
|
||||
return $this->hasOne('App\Share', 'item_id', 'unique_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,24 +11,82 @@ use RecursiveArrayIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use \Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
|
||||
/**
|
||||
* App\FileManagerFolder
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $user_id
|
||||
* @property int $unique_id
|
||||
* @property int $parent_id
|
||||
* @property string|null $name
|
||||
* @property string|null $type
|
||||
* @property string $user_scope
|
||||
* @property string $deleted_at
|
||||
* @property string $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFolder[] $children
|
||||
* @property-read int|null $children_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFile[] $files
|
||||
* @property-read int|null $files_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFolder[] $folders
|
||||
* @property-read int|null $folders_count
|
||||
* @property-read int $items
|
||||
* @property-read int $trashed_items
|
||||
* @property-read \App\FileManagerFolder $parent
|
||||
* @property-read \App\Share|null $shared
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFolder[] $trashed_children
|
||||
* @property-read int|null $trashed_children_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFile[] $trashed_files
|
||||
* @property-read int|null $trashed_files_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\FileManagerFolder[] $trashed_folders
|
||||
* @property-read int|null $trashed_folders_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFolder onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereUniqueId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\FileManagerFolder whereUserScope($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFolder withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\FileManagerFolder withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|FileManagerFolder sortable($defaultParameters = null)
|
||||
*/
|
||||
class FileManagerFolder extends Model
|
||||
{
|
||||
use Searchable, SoftDeletes, SoftCascadeTrait;
|
||||
use Searchable, SoftDeletes , Sortable;
|
||||
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
protected $softCascade = [
|
||||
'children', 'files'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'items', 'trashed_items'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'icon_emoji' => 'object',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $sortable = [
|
||||
'name',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Index folder
|
||||
*
|
||||
@@ -79,7 +137,7 @@ class FileManagerFolder extends Model
|
||||
*/
|
||||
public function getCreatedAtAttribute()
|
||||
{
|
||||
return Carbon::create($this->attributes['created_at'])->format('j M Y \a\t H:i');
|
||||
return format_date(set_time_by_user_timezone($this->attributes['created_at']), __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +149,7 @@ class FileManagerFolder extends Model
|
||||
{
|
||||
if (! $this->attributes['deleted_at']) return null;
|
||||
|
||||
return Carbon::create($this->attributes['deleted_at'])->format('j M Y \a\t H:i');
|
||||
return format_date(set_time_by_user_timezone($this->attributes['deleted_at']), __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +174,6 @@ class FileManagerFolder extends Model
|
||||
*/
|
||||
public function files()
|
||||
{
|
||||
|
||||
return $this->hasMany('App\FileManagerFile', 'folder_id', 'unique_id');
|
||||
}
|
||||
|
||||
@@ -171,6 +228,16 @@ class FileManagerFolder extends Model
|
||||
return $this->hasMany('App\FileManagerFolder', 'parent_id', 'unique_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sharing attributes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function shared()
|
||||
{
|
||||
return $this->hasOne('App\Share', 'item_id', 'unique_id');
|
||||
}
|
||||
|
||||
// Delete all folder childrens
|
||||
public static function boot()
|
||||
{
|
||||
@@ -178,9 +245,22 @@ class FileManagerFolder extends Model
|
||||
|
||||
static::deleting(function ($item) {
|
||||
|
||||
$item->children()->each(function($folder) {
|
||||
$folder->delete();
|
||||
});
|
||||
if ( $item->isForceDeleting() ) {
|
||||
|
||||
$item->trashed_children()->each(function($folder) {
|
||||
$folder->forceDelete();
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$item->children()->each(function($folder) {
|
||||
$folder->delete();
|
||||
});
|
||||
|
||||
$item->files()->each(function($file) {
|
||||
$file->delete();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
static::restoring(function ($item) {
|
||||
@@ -196,4 +276,4 @@ class FileManagerFolder extends Model
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
66
app/Http/Controllers/Admin/DashboardController.php
Normal file
66
app/Http/Controllers/Admin/DashboardController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\FileManagerFile;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Services\StripeService;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use ByteUnits\Metric;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Cashier\Subscription;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* DashboardController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for dashboard
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Get total users
|
||||
$total_users = User::all()->count();
|
||||
|
||||
// Get total used space
|
||||
$total_used_space = FileManagerFile::all()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
// Get total premium users
|
||||
$total_premium_users = Subscription::where('stripe_status', 'active')->get()->count();
|
||||
|
||||
// Get License
|
||||
$license = Setting::where('name', 'license')->first();
|
||||
|
||||
return [
|
||||
'license' => $license ? $license->value : null,
|
||||
'app_version' => config('vuefilemanager.version'),
|
||||
'total_users' => $total_users,
|
||||
'total_used_space' => Metric::bytes($total_used_space)->format(),
|
||||
'total_premium_users' => $total_premium_users,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the newest users
|
||||
*
|
||||
* @return UsersCollection
|
||||
*/
|
||||
public function new_registrations()
|
||||
{
|
||||
return new UsersCollection(
|
||||
User::sortable(['created_at' => 'desc'])->paginate(10)
|
||||
);
|
||||
}
|
||||
}
|
||||
52
app/Http/Controllers/Admin/InvoiceController.php
Normal file
52
app/Http/Controllers/Admin/InvoiceController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceAdminCollection;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Invoice;
|
||||
use App\Services\StripeService;
|
||||
use App\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* PlanController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all invoices
|
||||
*
|
||||
* @return InvoiceAdminCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new InvoiceAdminCollection(
|
||||
$this->stripe->getInvoices()['data']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single invoice by $token
|
||||
*
|
||||
* @param $customer
|
||||
* @param $token
|
||||
* @return InvoiceResource
|
||||
*/
|
||||
public function show($customer, $token)
|
||||
{
|
||||
$settings = json_decode(Setting::all()->pluck('value', 'name')->toJson());
|
||||
|
||||
$invoice = $this->stripe->getUserInvoice($customer, $token);
|
||||
|
||||
return view('vuefilemanager.invoice')
|
||||
->with('settings', $settings)
|
||||
->with('invoice', $invoice);
|
||||
}
|
||||
}
|
||||
61
app/Http/Controllers/Admin/PagesController.php
Normal file
61
app/Http/Controllers/Admin/PagesController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PageCollection;
|
||||
use App\Http\Resources\PageResource;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Page;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PagesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all pages
|
||||
*
|
||||
* @return PageCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new PageCollection(
|
||||
Page::sortable()->paginate(10)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page resource
|
||||
*
|
||||
* @param $slug
|
||||
* @return PageResource
|
||||
*/
|
||||
public function show($slug)
|
||||
{
|
||||
return new PageResource(
|
||||
Page::where('slug', $slug)->first()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update page content
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $slug
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $slug)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Get page
|
||||
$page = Page::where('slug', $slug)->first();
|
||||
|
||||
// Update page
|
||||
$page->update(make_single_input($request));
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
159
app/Http/Controllers/Admin/PlanController.php
Normal file
159
app/Http/Controllers/Admin/PlanController.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PlanCollection;
|
||||
use App\Http\Resources\PlanResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Plan;
|
||||
use App\Services\StripeService;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use Rinvex\Subscriptions\Models\PlanFeature;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
/**
|
||||
* PlanController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plans
|
||||
*
|
||||
* @return PlanCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Store or Get plans to cache
|
||||
if (Cache::has('plans')) {
|
||||
$plans = Cache::get('plans');
|
||||
} else {
|
||||
$plans = Cache::rememberForever('plans', function () {
|
||||
return $this->stripe->getPlans();
|
||||
});
|
||||
}
|
||||
|
||||
return new PlanCollection($plans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plan record
|
||||
*
|
||||
* @param $id
|
||||
* @return PlanResource
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
// Store or Get plan to cache
|
||||
if (Cache::has('plan-' . $id)) {
|
||||
$plan = Cache::get('plan-' . $id);
|
||||
} else {
|
||||
$plan = Cache::rememberForever('plan-' . $id, function () use ($id) {
|
||||
return $this->stripe->getPlan($id);
|
||||
});
|
||||
}
|
||||
|
||||
return new PlanResource($plan);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new plan
|
||||
*
|
||||
* @param Request $request
|
||||
* @return PlanResource
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
|
||||
if (Cache::has('plan-starter-pack')) {
|
||||
$plan = Cache::get('plan-starter-pack');
|
||||
} else {
|
||||
$plan = Cache::rememberForever('plan-starter-pack', function () {
|
||||
return $this->stripe->getPlan('starter-pack');
|
||||
});
|
||||
}
|
||||
|
||||
return new PlanResource($plan);
|
||||
}
|
||||
|
||||
$plan = new PlanResource(
|
||||
$this->stripe->createPlan($request)
|
||||
);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing']);
|
||||
|
||||
return $plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update plan attribute
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Update plan
|
||||
$this->stripe->updatePlan($request, $id);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing', 'plan-' . $id]);
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete plan
|
||||
*
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Delete plan
|
||||
$this->stripe->deletePlan($id);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing']);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subscriptions
|
||||
*
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function subscribers($id)
|
||||
{
|
||||
$subscribers = Subscription::where('stripe_plan', $id)->pluck('user_id');
|
||||
|
||||
return new UsersCollection(
|
||||
User::sortable()->findMany($subscribers)
|
||||
);
|
||||
}
|
||||
}
|
||||
274
app/Http/Controllers/Admin/UserController.php
Normal file
274
app/Http/Controllers/Admin/UserController.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\ChangeRoleRequest;
|
||||
use App\Http\Requests\Admin\ChangeStorageCapacityRequest;
|
||||
use App\Http\Requests\Admin\CreateUserByAdmin;
|
||||
use App\Http\Requests\Admin\DeleteUserRequest;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Services\StripeService;
|
||||
use App\Share;
|
||||
use App\User;
|
||||
use App\UserSettings;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Storage;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user details
|
||||
*
|
||||
* @param $id
|
||||
* @return UserResource
|
||||
*/
|
||||
public function details($id)
|
||||
{
|
||||
return new UserResource(
|
||||
User::findOrFail($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @param $id
|
||||
* @return UserStorageResource
|
||||
*/
|
||||
public function storage($id)
|
||||
{
|
||||
return new UserStorageResource(
|
||||
User::findOrFail($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function invoices($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
|
||||
return new InvoiceCollection(
|
||||
$this->stripe->getUserInvoices($user)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user subscription details
|
||||
*
|
||||
* @param $id
|
||||
* @return UserSubscription
|
||||
*/
|
||||
public function subscription($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
|
||||
if (! $user->stripeId() || ! $user->subscription('main')) {
|
||||
return response('User doesn\'t have any subscription.', 404);
|
||||
}
|
||||
|
||||
return new UserSubscription(
|
||||
User::find($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all users
|
||||
*
|
||||
* @return UsersCollection
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return new UsersCollection(
|
||||
User::sortable(['created_at', 'DESC'])->paginate('20')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change user role
|
||||
*
|
||||
* @param ChangeRoleRequest $request
|
||||
* @param $id
|
||||
* @return UserResource
|
||||
*/
|
||||
public function change_role(ChangeRoleRequest $request, $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
// Demo preview
|
||||
if (env('APP_DEMO') && $id == 1) {
|
||||
return new UserResource($user);
|
||||
}
|
||||
|
||||
// Update user role
|
||||
$user->role = $request->input('attributes.role');
|
||||
$user->save();
|
||||
|
||||
return new UserResource($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change user storage capacity
|
||||
*
|
||||
* @param ChangeStorageCapacityRequest $request
|
||||
* @param $id
|
||||
* @return UserStorageResource
|
||||
*/
|
||||
public function change_storage_capacity(ChangeStorageCapacityRequest $request, $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$user->settings()->update($request->input('attributes'));
|
||||
|
||||
return new UserStorageResource($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send user password reset link
|
||||
*
|
||||
* @param $id
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function send_password_reset_email($id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
// Demo preview
|
||||
if (env('APP_DEMO')) {
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
// Get password token
|
||||
$token = Password::getRepository()->create($user);
|
||||
|
||||
// Send user email
|
||||
$user->sendPasswordResetNotification($token);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new user by admin
|
||||
*
|
||||
* @param CreateUserByAdmin $request
|
||||
* @return UserResource
|
||||
*/
|
||||
public function create_user(CreateUserByAdmin $request)
|
||||
{
|
||||
// Store avatar
|
||||
if ($request->hasFile('avatar')) {
|
||||
$avatar = store_avatar($request->file('avatar'), 'avatars');
|
||||
}
|
||||
|
||||
// Create user
|
||||
$user = User::forceCreate([
|
||||
'avatar' => $request->hasFile('avatar') ? $avatar : null,
|
||||
'name' => $request->name,
|
||||
'role' => $request->role,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
// Create settings
|
||||
UserSettings::forceCreate([
|
||||
'user_id' => $user->id,
|
||||
'storage_capacity' => $request->storage_capacity,
|
||||
]);
|
||||
|
||||
return new UserResource($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user with all user data
|
||||
*
|
||||
* @param DeleteUserRequest $request
|
||||
* @param $id
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete_user(DeleteUserRequest $request, $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
if ($user->subscribed('main')) {
|
||||
abort(202, 'You can\'t delete this account while user have active subscription.');
|
||||
}
|
||||
|
||||
// Demo preview
|
||||
if (env('APP_DEMO')) {
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
// Check for self deleted account
|
||||
if ($user->id === Auth::id()) {
|
||||
abort(406, 'You can\'t delete your account');
|
||||
}
|
||||
|
||||
// Validate user name
|
||||
if ($user->name !== $request->input('data.name')) abort(403);
|
||||
|
||||
$shares = Share::where('user_id', $user->id)->get();
|
||||
|
||||
$files = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user->id)
|
||||
->get();
|
||||
$folders = FileManagerFolder::withTrashed()
|
||||
->where('user_id', $user->id)
|
||||
->get();
|
||||
|
||||
// Remove all files and thumbnails
|
||||
$files->each(function ($file) {
|
||||
|
||||
// Delete file
|
||||
Storage::delete('/file-manager/' . $file->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if (!is_null($file->thumbnail)) {
|
||||
Storage::delete('/file-manager/' . $file->getRawOriginal('thumbnail'));
|
||||
}
|
||||
|
||||
// Delete file permanently
|
||||
$file->forceDelete();
|
||||
});
|
||||
|
||||
// Remove avatar
|
||||
if ($user->avatar) {
|
||||
Storage::delete('/avatars/' . $user->avatar);
|
||||
}
|
||||
|
||||
// Remove folders & shares
|
||||
$folders->each->forceDelete();
|
||||
$shares->each->forceDelete();
|
||||
|
||||
// Remove favourites
|
||||
$user->settings->delete();
|
||||
$user->favourite_folders()->sync([]);
|
||||
|
||||
// Delete user
|
||||
$user->delete();
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,52 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Content;
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Requests\PublicPages\SendMessageRequest;
|
||||
use App\Http\Resources\PageResource;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Mail\SendSupportForm;
|
||||
use App\Page;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use Artisan;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Response;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Schema;
|
||||
|
||||
class AppFunctionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* List of allowed settings to get from public request
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $whitelist = [
|
||||
'section_features',
|
||||
'footer_content',
|
||||
'get_started_description',
|
||||
'get_started_title',
|
||||
'pricing_description',
|
||||
'pricing_title',
|
||||
'feature_description_3',
|
||||
'feature_title_3',
|
||||
'feature_description_2',
|
||||
'feature_title_2',
|
||||
'feature_description_1',
|
||||
'feature_title_1',
|
||||
'features_description',
|
||||
'features_title',
|
||||
'header_description',
|
||||
'header_title',
|
||||
'section_get_started',
|
||||
'section_pricing_content',
|
||||
'section_feature_boxes',
|
||||
'allow_homepage',
|
||||
];
|
||||
|
||||
/**
|
||||
* Show index page
|
||||
*
|
||||
@@ -15,30 +55,195 @@ class AppFunctionsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view("index");
|
||||
try {
|
||||
// Try to connect to database
|
||||
\DB::getPdo();
|
||||
|
||||
// Check settings table
|
||||
$settings_table = Schema::hasTable('settings');
|
||||
$users_table = Schema::hasTable('users');
|
||||
|
||||
// If settings table don't exist, then run migrations
|
||||
if ($users_table && !$settings_table) {
|
||||
Artisan::call('migrate', [
|
||||
'--force' => true
|
||||
]);
|
||||
}
|
||||
|
||||
// Get settings
|
||||
$upgraded = Setting::where('name', 'latest_upgrade')->first();
|
||||
|
||||
// Get connection string
|
||||
if ($upgraded && $upgraded->value !== '1.7') {
|
||||
$connection = 'quiet-update';
|
||||
} else if (!$upgraded) {
|
||||
$connection = 'quiet-update';
|
||||
} else {
|
||||
$connection = $this->get_setup_status();
|
||||
}
|
||||
|
||||
// Get all settings
|
||||
$settings = Setting::all();
|
||||
|
||||
// Get legal pages
|
||||
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])
|
||||
->get(['visibility', 'title', 'slug']);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$connection = 'setup-database';
|
||||
$settings = null;
|
||||
}
|
||||
|
||||
return view("index")
|
||||
->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null)
|
||||
->with('legal', isset($legal) ? $legal : null)
|
||||
->with('installation', $connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
* Get og site for web crawlers
|
||||
*
|
||||
* @param $filename
|
||||
* @param $token
|
||||
*/
|
||||
public function og_site($token)
|
||||
{
|
||||
// Get all settings
|
||||
$settings = Setting::all();
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Get user
|
||||
$user = User::findOrFail($shared->user_id);
|
||||
|
||||
// Handle single file
|
||||
if ($shared->type === 'file') {
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('unique_id', $shared->item_id)
|
||||
->first();
|
||||
|
||||
if ($file->thumbnail) {
|
||||
$file->setPublicUrl($token);
|
||||
}
|
||||
|
||||
$metadata = [
|
||||
'is_protected' => $shared->protected,
|
||||
'url' => url('/shared', ['token' => $token]),
|
||||
'user' => $user->name,
|
||||
'name' => $file->name,
|
||||
'size' => $file->filesize,
|
||||
'thumbnail' => $file->thumbnail ? $file->thumbnail : null,
|
||||
];
|
||||
}
|
||||
|
||||
// Handle single file
|
||||
if ($shared->type === 'folder') {
|
||||
|
||||
// Get file record
|
||||
$folder = FileManagerFolder::where('user_id', $shared->user_id)
|
||||
->where('unique_id', $shared->item_id)
|
||||
->first();
|
||||
|
||||
$metadata = [
|
||||
'is_protected' => $shared->protected,
|
||||
'url' => url('/shared', ['token' => $token]),
|
||||
'user' => $user->name,
|
||||
'name' => $folder->name,
|
||||
'size' => $folder->items,
|
||||
'thumbnail' => null,
|
||||
];
|
||||
}
|
||||
|
||||
// Return view
|
||||
return view("og-view")
|
||||
->with('settings', json_decode($settings->pluck('value', 'name')->toJson()))
|
||||
->with('metadata', $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if setup wizard was passed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_setup_status(): string
|
||||
{
|
||||
$setup_success = get_setting('setup_wizard_success');
|
||||
|
||||
$connection = boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contact message from pages
|
||||
*
|
||||
* @param SendMessageRequest $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function contact_form(SendMessageRequest $request)
|
||||
{
|
||||
// Get receiver email
|
||||
$receiver = Setting::where('name', 'contact_email')->first();
|
||||
|
||||
// Send message
|
||||
Mail::to($receiver->value)->send(new SendSupportForm($request->all()));
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single page content
|
||||
*
|
||||
* @param $slug
|
||||
* @return PageResource
|
||||
*/
|
||||
public function get_page($slug)
|
||||
{
|
||||
return new PageResource(
|
||||
Page::where('slug', $slug)->first()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected settings from public route
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_avatar($basename)
|
||||
public function get_settings(Request $request)
|
||||
{
|
||||
// Get file path
|
||||
$path = storage_path() . '/app/avatars/' . $basename;
|
||||
$column = $request->get('column');
|
||||
|
||||
// Check if file exist
|
||||
if (!File::exists($path)) abort(404);
|
||||
if (strpos($column, '|') !== false) {
|
||||
|
||||
$file = File::get($path);
|
||||
$type = File::mimeType($path);
|
||||
$columns = collect(explode('|', $column));
|
||||
|
||||
// Create response
|
||||
$response = Response::make($file, 200);
|
||||
$response->header("Content-Type", $type);
|
||||
$columns->each(function ($column) {
|
||||
if (!in_array($column, $this->whitelist)) abort(401);
|
||||
});
|
||||
|
||||
return $response;
|
||||
return Setting::whereIn('name', $columns)->pluck('value', 'name');
|
||||
}
|
||||
|
||||
if (!in_array($column, $this->whitelist)) abort(401);
|
||||
|
||||
return Setting::where('name', $column)->pluck('value', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear application cache
|
||||
*/
|
||||
public function flush_cache()
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\ClientProfile;
|
||||
use App\Models\User\UserAttribute;
|
||||
use App\Models\User\UserNotificationSetting;
|
||||
use App\ProviderProfile;
|
||||
use App\Http\Requests\Auth\CheckAccountRequest;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use App\UserSettings;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
@@ -26,25 +21,21 @@ class AuthController extends Controller
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function check_account(Request $request) {
|
||||
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'email' => ['required', 'string', 'email'],
|
||||
]);
|
||||
|
||||
public function check_account(CheckAccountRequest $request)
|
||||
{
|
||||
// Get User
|
||||
$user = User::where('email', $request->input('email'))->select(['name', 'avatar'])->first();
|
||||
|
||||
// Return user info
|
||||
if ($user) return [
|
||||
'name' => $user->name,
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
];
|
||||
|
||||
// Abort with 404, user not found
|
||||
return abort('404', 'We can\'t find a user with that e-mail address.');
|
||||
return abort('404', __('vuefilemanager.user_not_fount'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Login user
|
||||
*
|
||||
@@ -53,17 +44,16 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$response = Route::dispatch(self::make_request($request));
|
||||
$response = Route::dispatch(self::make_login_request($request));
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
|
||||
$data = json_decode($response->content(), true);
|
||||
|
||||
return response('Login Successfull!', 200)->cookie('token', $data['access_token'], 43200);
|
||||
} else {
|
||||
|
||||
return $response;
|
||||
return response('Login Successfull!', 200)->cookie('access_token', $data['access_token'], 43200);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,34 +64,41 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
$settings = Setting::whereIn('name', ['storage_default', 'registration'])->pluck('value', 'name');
|
||||
|
||||
// Check if account registration is enabled
|
||||
if (! config('vuefilemanager.registration') ) abort(401);
|
||||
if (! intval($settings['registration'])) abort(401);
|
||||
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
]);
|
||||
|
||||
// Create user
|
||||
User::create([
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
$response = Route::dispatch(self::make_request($request));
|
||||
// Create settings
|
||||
UserSettings::forceCreate([
|
||||
'user_id' => $user->id,
|
||||
'storage_capacity' => $settings['storage_default'],
|
||||
]);
|
||||
|
||||
$response = Route::dispatch(self::make_login_request($request));
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
|
||||
$data = json_decode($response->content(), true);
|
||||
|
||||
return response('Register Successfull!', 200)->cookie('token', $data['access_token'], 43200);
|
||||
} else {
|
||||
|
||||
return $response;
|
||||
return response('Register Successfull!', 200)->cookie('access_token', $data['access_token'], 43200);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +108,12 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return response('Logout successfull', 204)
|
||||
->cookie('access_token', '', -1);
|
||||
}
|
||||
|
||||
// Get user tokens and remove it
|
||||
auth()->user()->tokens()->each(function ($token) {
|
||||
|
||||
@@ -118,17 +121,17 @@ class AuthController extends Controller
|
||||
$token->delete();
|
||||
});
|
||||
|
||||
return response('Logout successfull', 200)->cookie('token', '', -1);
|
||||
return response('Logout successful', 204)
|
||||
->cookie('access_token', '', -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make request for get user token
|
||||
* Make login request for get access token
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $provider
|
||||
* @return Request
|
||||
*/
|
||||
private static function make_request(Request $request)
|
||||
private static function make_login_request($request)
|
||||
{
|
||||
$request->request->add([
|
||||
'grant_type' => 'password',
|
||||
@@ -136,7 +139,7 @@ class AuthController extends Controller
|
||||
'client_secret' => config('services.passport.client_secret'),
|
||||
'username' => $request->email,
|
||||
'password' => $request->password,
|
||||
'scope' => '',
|
||||
'scope' => 'master',
|
||||
]);
|
||||
|
||||
return Request::create(url('/oauth/token'), 'POST', $request->all());
|
||||
|
||||
44
app/Http/Controllers/DeployController.php
Normal file
44
app/Http/Controllers/DeployController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\UnauthorizedException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class DeployController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get web hook payload and verify request
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function github(Request $request) {
|
||||
|
||||
if (($signature = $request->headers->get('X-Hub-Signature')) == null) {
|
||||
throw new BadRequestHttpException('Header not set');
|
||||
}
|
||||
|
||||
$signature_parts = explode('=', $signature);
|
||||
|
||||
if (count($signature_parts) != 2) {
|
||||
throw new BadRequestHttpException('signature has invalid format');
|
||||
}
|
||||
|
||||
$known_signature = hash_hmac('sha1', $request->getContent(), config('app.deploy_secret'));
|
||||
|
||||
if (! hash_equals($known_signature, $signature_parts[1])) {
|
||||
throw new UnauthorizedException('Could not verify request signature ' . $signature_parts[1]);
|
||||
}
|
||||
|
||||
// Run deploying
|
||||
Artisan::call('deploy:production');
|
||||
|
||||
Log::info('The GitHub webhook was accepted');
|
||||
|
||||
return response('The GitHub webhook was accepted', 202);
|
||||
}
|
||||
}
|
||||
299
app/Http/Controllers/FileAccessController.php
Normal file
299
app/Http/Controllers/FileAccessController.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Tools\Editor;
|
||||
use App\Http\Tools\Guardian;
|
||||
use App\Share;
|
||||
use App\User;
|
||||
use App\Zip;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Http\Request;
|
||||
use App\FileManagerFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Madnest\Madzipper\Facades\Madzipper;
|
||||
use Response;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class FileAccessController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get avatar
|
||||
*
|
||||
* @param $basename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_avatar($basename)
|
||||
{
|
||||
// Get file path
|
||||
$path = '/avatars/' . $basename;
|
||||
|
||||
// Check if file exist
|
||||
if (!Storage::exists($path)) abort(404);
|
||||
|
||||
// Return avatar
|
||||
return Storage::download($path, $basename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system image
|
||||
*
|
||||
* @param $basename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_system_image($basename)
|
||||
{
|
||||
// Get file path
|
||||
$path = '/system/' . $basename;
|
||||
|
||||
// Check if file exist
|
||||
if (!Storage::exists($path)) abort(404);
|
||||
|
||||
// Return avatar
|
||||
return Storage::download($path, $basename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_file(Request $request, $filename)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check user permission
|
||||
if (!$request->user()->tokenCan('master')) {
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check access to file
|
||||
$this->check_file_access($shared, $file);
|
||||
}
|
||||
|
||||
// Store user download size
|
||||
$request->user()->record_download((int)$file->getRawOriginal('filesize'));
|
||||
|
||||
return $this->download_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generated zip for user
|
||||
*
|
||||
* @param $id
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
public function get_zip($id)
|
||||
{
|
||||
$zip = Zip::where('id', $id)
|
||||
->where('user_id', Auth::id())
|
||||
->first();
|
||||
|
||||
$zip_path = 'zip/' . $zip->basename;
|
||||
|
||||
$header = [
|
||||
"Content-Type" => 'application/zip',
|
||||
"Content-Length" => Storage::disk('local')->size($zip_path),
|
||||
"Accept-Ranges" => "bytes",
|
||||
"Content-Range" => "bytes 0-600/" . Storage::disk('local')->size($zip_path),
|
||||
"Content-Disposition" => "attachment; filename=" . $zip->basename,
|
||||
];
|
||||
|
||||
return Storage::disk('local')->download($zip_path, $zip->basename, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generated zip for guest
|
||||
*
|
||||
* @param $id
|
||||
* @param $token
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
public function get_zip_public($id, $token)
|
||||
{
|
||||
$zip = Zip::where('id', $id)
|
||||
->where('shared_token', $token)
|
||||
->first();
|
||||
|
||||
$zip_path = 'zip/' . $zip->basename;
|
||||
|
||||
$header = [
|
||||
"Content-Type" => 'application/zip',
|
||||
"Content-Length" => Storage::disk('local')->size($zip_path),
|
||||
"Accept-Ranges" => "bytes",
|
||||
"Content-Range" => "bytes 0-600/" . Storage::disk('local')->size($zip_path),
|
||||
"Content-Disposition" => "attachment; filename=" . $zip->basename,
|
||||
];
|
||||
|
||||
return Storage::disk('local')->download($zip_path, $zip->basename, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file public
|
||||
*
|
||||
* @param $filename
|
||||
* @param $token
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_file_public($filename, $token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Abort if shared is protected
|
||||
if ((int)$shared->protected) {
|
||||
abort(403, "Sorry, you don't have permission");
|
||||
}
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->check_file_access($shared, $file);
|
||||
|
||||
// Store user download size
|
||||
User::find($shared->user_id)->record_download((int)$file->getRawOriginal('filesize'));
|
||||
|
||||
return $this->download_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image thumbnail
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_thumbnail(Request $request, $filename)
|
||||
{
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $request->user()->id)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check user permission
|
||||
if (!$request->user()->tokenCan('master')) {
|
||||
$this->check_file_access($request, $file);
|
||||
}
|
||||
|
||||
return $this->thumbnail_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public image thumbnail
|
||||
*
|
||||
* @param $filename
|
||||
* @param $token
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_thumbnail_public($filename, $token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Abort if thumbnail is protected
|
||||
if ((int)$shared->protected) {
|
||||
abort(403, "Sorry, you don't have permission");
|
||||
}
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->check_file_access($shared, $file);
|
||||
|
||||
return $this->thumbnail_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check user file access
|
||||
*
|
||||
* @param $shared
|
||||
* @param $file
|
||||
*/
|
||||
protected function check_file_access($shared, $file): void
|
||||
{
|
||||
// Check by parent folder permission
|
||||
if ($shared->type === 'folder') {
|
||||
Guardian::check_item_access($file->folder_id, $shared);
|
||||
}
|
||||
|
||||
// Check by single file permission
|
||||
if ($shared->type === 'file') {
|
||||
if ($shared->item_id !== $file->unique_id) abort(403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call and download file
|
||||
*
|
||||
* @param $file
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
private function download_file($file)
|
||||
{
|
||||
$file_pretty_name = get_pretty_name($file->basename, $file->name, $file->mimetype);
|
||||
|
||||
// Get file path
|
||||
$path = '/file-manager/' . $file->basename;
|
||||
|
||||
// Check if file exist
|
||||
if (!Storage::exists($path)) abort(404);
|
||||
|
||||
$headers = [
|
||||
"Accept-Ranges" => "bytes",
|
||||
"Content-Type" => Storage::mimeType($path),
|
||||
"Content-Length" => Storage::size($path),
|
||||
"Content-Range" => "bytes 0-600/" . Storage::size($path),
|
||||
"Content-Disposition" => "attachment; filename=" . $file_pretty_name,
|
||||
];
|
||||
|
||||
return response()->download(storage_path('/app/file-manager/') . $file->basename, $file_pretty_name, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
private function thumbnail_file($file)
|
||||
{
|
||||
// Get file path
|
||||
$path = '/file-manager/' . $file->getRawOriginal('thumbnail');
|
||||
|
||||
// Check if file exist
|
||||
if (!Storage::exists($path)) abort(404);
|
||||
|
||||
// Return image thumbnail
|
||||
return Storage::download($path, $file->getRawOriginal('thumbnail'));
|
||||
}
|
||||
}
|
||||
221
app/Http/Controllers/FileBrowser/BrowseController.php
Normal file
221
app/Http/Controllers/FileBrowser/BrowseController.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FileBrowser;
|
||||
|
||||
use App\Http\Requests\FileBrowser\SearchRequest;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use App\FileManagerFolder;
|
||||
use App\FileManagerFile;
|
||||
use App\Share;
|
||||
|
||||
class BrowseController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Get trashed files
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function trash()
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folders and files
|
||||
$folders_trashed = FileManagerFolder::onlyTrashed()
|
||||
->with(['trashed_folders', 'parent'])
|
||||
->where('user_id', $user_id)
|
||||
->get(['parent_id', 'unique_id', 'name']);
|
||||
|
||||
$folders = FileManagerFolder::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('unique_id', filter_folders_ids($folders_trashed))
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Get files trashed
|
||||
$files_trashed = FileManagerFile::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->whereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'unique_id'))))
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files_trashed])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user shared items
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function shared()
|
||||
{
|
||||
// Get user
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get shared folders and files
|
||||
$folder_ids = Share::where('user_id', $user_id)
|
||||
->where('type', 'folder')
|
||||
->pluck('item_id');
|
||||
|
||||
$file_ids = Share::where('user_id', $user_id)
|
||||
->where('type', '!=', 'folder')
|
||||
->pluck('item_id');
|
||||
|
||||
// Get folders and files
|
||||
$folders = FileManagerFolder::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('unique_id', $folder_ids)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('unique_id', $file_ids)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest user uploads
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function latest() {
|
||||
|
||||
// Get User
|
||||
$user = User::with(['latest_uploads' => function($query) {
|
||||
$query->sortable(['created_at' => 'desc']);
|
||||
}])
|
||||
->where('id', Auth::id())
|
||||
->first();
|
||||
|
||||
return $user->latest_uploads->makeHidden(['user_id', 'basename']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant uploads
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function participant_uploads() {
|
||||
|
||||
// Get User
|
||||
$uploads = FileManagerFile::with(['parent'])
|
||||
->where('user_id', Auth::id())
|
||||
->whereUserScope('editor')
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
return $uploads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory with files
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $unique_id
|
||||
* @return Collection
|
||||
*/
|
||||
public function folder(Request $request, $unique_id)
|
||||
{
|
||||
// Get user
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folder trash items
|
||||
if ($request->query('trash')) {
|
||||
|
||||
// Get folders and files
|
||||
$folders = FileManagerFolder::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('user_id', $user_id)
|
||||
->where('parent_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('user_id', $user_id)
|
||||
->where('folder_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
// Get folders and files
|
||||
$folders = FileManagerFolder::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->where('parent_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->where('folder_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user folder tree
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function navigation_tree() {
|
||||
|
||||
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('parent_id', 0)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'unique_id', 'name']);
|
||||
|
||||
return [
|
||||
[
|
||||
'unique_id' => 0,
|
||||
'name' => __('vuefilemanager.home'),
|
||||
'location' => 'base',
|
||||
'folders' => $folders,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search files
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function search(SearchRequest $request)
|
||||
{
|
||||
// Get user
|
||||
$user_id = Auth::id();
|
||||
$query = remove_accents($request->input('query'));
|
||||
|
||||
// Search files id db
|
||||
$searched_files = FileManagerFile::search($query)
|
||||
->where('user_id', $user_id)
|
||||
->get();
|
||||
$searched_folders = FileManagerFolder::search($query)
|
||||
->where('user_id', $user_id)
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$searched_folders, $searched_files])->collapse();
|
||||
}
|
||||
}
|
||||
572
app/Http/Controllers/FileFunctions/EditItemsController.php
Normal file
572
app/Http/Controllers/FileFunctions/EditItemsController.php
Normal file
@@ -0,0 +1,572 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FileFunctions;
|
||||
|
||||
use App\Http\Requests\FileFunctions\CreateFolderRequest;
|
||||
use App\Http\Requests\FileFunctions\DeleteItemRequest;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
use App\Http\Requests\FileFunctions\MoveItemRequest;
|
||||
use App\Http\Requests\FileFunctions\UploadRequest;
|
||||
use App\Http\Tools\Demo;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Tools\Guardian;
|
||||
use App\Http\Tools\Editor;
|
||||
use App\FileManagerFolder;
|
||||
use App\FileManagerFile;
|
||||
use Exception;
|
||||
|
||||
|
||||
class EditItemsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create new folder for authenticated master|editor user
|
||||
*
|
||||
* @param CreateFolderRequest $request
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function user_create_folder(CreateFolderRequest $request)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::create_folder($request);
|
||||
}
|
||||
|
||||
// Check permission to create folder for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($request->parent_id, $shared);
|
||||
}
|
||||
|
||||
// Create new folder
|
||||
return Editor::create_folder($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new folder for guest user with edit permission
|
||||
*
|
||||
* @param CreateFolderRequest $request
|
||||
* @param $token
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function guest_create_folder(CreateFolderRequest $request, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
if (is_demo($shared->user_id)) {
|
||||
return Demo::create_folder($request);
|
||||
}
|
||||
|
||||
// Check shared permission
|
||||
if (!is_editor($shared)) abort(403);
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($request->parent_id, $shared);
|
||||
|
||||
// Create folder
|
||||
return Editor::create_folder($request, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item for authenticated master|editor user
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $unique_id
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function user_rename_item(RenameItemRequest $request, $unique_id)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::rename_item($request, $unique_id);
|
||||
}
|
||||
|
||||
// Check permission to rename item for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Get file|folder item
|
||||
$item = get_item($request->type, $unique_id, Auth::id());
|
||||
|
||||
// Check access to requested directory
|
||||
if ($request->type === 'folder') {
|
||||
Guardian::check_item_access($item->unique_id, $shared);
|
||||
} else {
|
||||
Guardian::check_item_access($item->folder_id, $shared);
|
||||
}
|
||||
}
|
||||
|
||||
// If request have a change folder icon values set the folder icon
|
||||
if ($request->type === 'folder' && $request->filled('folder_icon')) {
|
||||
|
||||
Editor::set_folder_icon($request->folder_icon, $unique_id);
|
||||
}
|
||||
|
||||
// Rename Item
|
||||
return Editor::rename_item($request, $unique_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item for guest user with edit permission
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $unique_id
|
||||
* @param $token
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function guest_rename_item(RenameItemRequest $request, $unique_id, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Demo preview
|
||||
if (is_demo($shared->user_id)) {
|
||||
return Demo::rename_item($request, $unique_id);
|
||||
}
|
||||
|
||||
// Check shared permission
|
||||
if (!is_editor($shared)) abort(403);
|
||||
|
||||
// Get file|folder item
|
||||
$item = get_item($request->type, $unique_id, $shared->user_id);
|
||||
|
||||
// Check access to requested item
|
||||
if ($request->type === 'folder') {
|
||||
Guardian::check_item_access($item->unique_id, $shared);
|
||||
} else {
|
||||
Guardian::check_item_access($item->folder_id, $shared);
|
||||
}
|
||||
|
||||
// If request have a change folder icon values set the folder icon
|
||||
if ($request->type === 'folder' && $request->filled('folder_icon')) {
|
||||
|
||||
Editor::set_folder_icon($request->folder_icon, $unique_id, $shared);
|
||||
}
|
||||
|
||||
// Rename item
|
||||
$item = Editor::rename_item($request, $unique_id, $shared);
|
||||
|
||||
// Set public url
|
||||
if ($item->type !== 'folder') {
|
||||
$item->setPublicUrl($token);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete item for authenticated master|editor user
|
||||
*
|
||||
* @param DeleteItemRequest $request
|
||||
* @param $unique_id
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function user_delete_item(DeleteItemRequest $request)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
foreach ($request->input('data') as $file) {
|
||||
$unique_id = $file['unique_id'];
|
||||
|
||||
// Check permission to delete item for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// Prevent force delete for non-master users
|
||||
if ($file['force_delete']) abort('401');
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Get file|folder item
|
||||
$item = get_item($file['type'], $unique_id, Auth::id());
|
||||
|
||||
// Check access to requested directory
|
||||
if ($file['type'] === 'folder') {
|
||||
Guardian::check_item_access($item->unique_id, $shared);
|
||||
} else {
|
||||
Guardian::check_item_access($item->folder_id, $shared);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete item
|
||||
Editor::delete_item($file, $unique_id);
|
||||
}
|
||||
|
||||
return response(null, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete item for guest user with edit permission
|
||||
*
|
||||
* @param DeleteItemRequest $request
|
||||
* @param $unique_id
|
||||
* @param $token
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function guest_delete_item(DeleteItemRequest $request, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Demo preview
|
||||
if (is_demo($shared->user_id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Check shared permission
|
||||
if (!is_editor($shared)) abort(403);
|
||||
|
||||
foreach ($request->input('data') as $file) {
|
||||
$unique_id = $file['unique_id'];
|
||||
|
||||
// Get file|folder item
|
||||
$item = get_item($file['type'], $unique_id, $shared->user_id);
|
||||
|
||||
// Check access to requested item
|
||||
if ($file['type'] === 'folder') {
|
||||
Guardian::check_item_access($item->unique_id, $shared);
|
||||
} else {
|
||||
Guardian::check_item_access($item->folder_id, $shared);
|
||||
}
|
||||
|
||||
// Delete item
|
||||
Editor::delete_item($file, $unique_id, $shared);
|
||||
}
|
||||
// Return response
|
||||
return response(null, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload file for authenticated master|editor user
|
||||
*
|
||||
* @param UploadRequest $request
|
||||
* @return FileManagerFile|Model
|
||||
* @throws Exception
|
||||
*/
|
||||
public function user_upload(UploadRequest $request)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::upload($request);
|
||||
}
|
||||
|
||||
// Check permission to upload for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($request->parent_id, $shared);
|
||||
}
|
||||
|
||||
// Return new uploaded file
|
||||
return Editor::upload($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file for guest user with edit permission
|
||||
*
|
||||
* @param UploadRequest $request
|
||||
* @param $token
|
||||
* @return FileManagerFile|Model
|
||||
* @throws Exception
|
||||
*/
|
||||
public function guest_upload(UploadRequest $request, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Demo preview
|
||||
if (is_demo($shared->user_id)) {
|
||||
return Demo::upload($request);
|
||||
}
|
||||
|
||||
// Check shared permission
|
||||
if (!is_editor($shared)) abort(403);
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($request->parent_id, $shared);
|
||||
|
||||
// Return new uploaded file
|
||||
$new_file = Editor::upload($request, $shared);
|
||||
|
||||
// Set public access url
|
||||
$new_file->setPublicUrl($token);
|
||||
|
||||
return $new_file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User download folder via zip
|
||||
*
|
||||
* @param $unique_id
|
||||
* @return string
|
||||
*/
|
||||
public function user_zip_folder(Request $request,$unique_id)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Check permission to download for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($unique_id, $shared);
|
||||
}
|
||||
|
||||
// Get folder
|
||||
$folder = FileManagerFolder::whereUserId($user_id)
|
||||
->where('unique_id', $unique_id);
|
||||
|
||||
if (! $folder->exists()) {
|
||||
abort(404, 'Requested folder doesn\'t exists.');
|
||||
}
|
||||
|
||||
$zip = Editor::zip_folder($unique_id);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip', $zip->id),
|
||||
'name' => $zip->basename,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guest download folder via zip
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $unique_id
|
||||
* @param $token
|
||||
* @return string
|
||||
*/
|
||||
public function guest_zip_folder($unique_id, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Check access to requested folder
|
||||
Guardian::check_item_access($unique_id, $shared);
|
||||
|
||||
// Get folder
|
||||
$folder = FileManagerFolder::whereUserId($shared->user_id)
|
||||
->where('unique_id', $unique_id);
|
||||
|
||||
|
||||
if (! $folder->exists()) {
|
||||
abort(404, 'Requested folder doesn\'t exists.');
|
||||
}
|
||||
|
||||
$zip = Editor::zip_folder($unique_id, $shared);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip_public', [
|
||||
'id' => $zip->id,
|
||||
'token' => $shared->token,
|
||||
]),
|
||||
'name' => $zip->basename,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* User download multiple files via zip
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function user_zip_multiple_files(Request $request)
|
||||
{
|
||||
// Check permission to upload for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
$file_parent_folders = FileManagerFile::whereUserId(Auth::id())
|
||||
->whereIn('unique_id', $request->input('files'))
|
||||
->get()
|
||||
->pluck('folder_id')
|
||||
->toArray();
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($file_parent_folders, $shared);
|
||||
}
|
||||
|
||||
// Get requested files
|
||||
$files = FileManagerFile::whereUserId(Auth::id())
|
||||
->whereIn('unique_id', $request->input('files'))
|
||||
->get();
|
||||
|
||||
$zip = Editor::zip_files($files);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip', $zip->id),
|
||||
'name' => $zip->basename,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guest download multiple files via zip
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $token
|
||||
* @return string
|
||||
*/
|
||||
public function guest_zip_multiple_files(Request $request, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
$file_parent_folders = FileManagerFile::whereUserId($shared->user_id)
|
||||
->whereIn('unique_id', $request->input('files'))
|
||||
->get()
|
||||
->pluck('folder_id')
|
||||
->toArray();
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($file_parent_folders, $shared);
|
||||
|
||||
// Get requested files
|
||||
$files = FileManagerFile::whereUserId($shared->user_id)
|
||||
->whereIn('unique_id', $request->input('files'))
|
||||
->get();
|
||||
|
||||
$zip = Editor::zip_files($files, $shared);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip_public', [
|
||||
'id' => $zip->id,
|
||||
'token' => $shared->token,
|
||||
]),
|
||||
'name' => $zip->basename,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move item for authenticated master|editor user
|
||||
*
|
||||
* @param MoveItemRequest $request
|
||||
* @param $unique_id
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function user_move(MoveItemRequest $request)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
$to_unique_id = $request->input('to_unique_id');
|
||||
|
||||
// Check permission to upload for authenticated editor
|
||||
if ($request->user()->tokenCan('editor')) {
|
||||
// check if shared_token cookie exist
|
||||
if (!$request->hasCookie('shared_token')) abort('401');
|
||||
|
||||
// Get shared token
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check access to requested directory
|
||||
Guardian::check_item_access($to_unique_id, $shared);
|
||||
}
|
||||
|
||||
// Move item
|
||||
Editor::move($request, $to_unique_id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move item for guest user with edit permission
|
||||
*
|
||||
* @param MoveItemRequest $request
|
||||
* @param $unique_id
|
||||
* @param $token
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function guest_move(MoveItemRequest $request, $token)
|
||||
{
|
||||
// Get shared record
|
||||
$shared = get_shared($token);
|
||||
|
||||
//Unique id of Folder where move
|
||||
$to_unique_id = $request->input('to_unique_id');
|
||||
|
||||
// Demo preview
|
||||
if (is_demo(Auth::id())) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Check shared permission
|
||||
if (!is_editor($shared)) abort(403);
|
||||
|
||||
foreach ($request->input('items') as $item) {
|
||||
|
||||
$unique_id = $item['unique_id'];
|
||||
$moving_unique_id = $unique_id;
|
||||
|
||||
|
||||
if ($item['type'] !== 'folder') {
|
||||
$file = FileManagerFile::where('unique_id', $unique_id)
|
||||
->where('user_id', $shared->user_id)
|
||||
->firstOrFail();
|
||||
|
||||
$moving_unique_id = $file->folder_id;
|
||||
}
|
||||
|
||||
// Check access to requested item
|
||||
Guardian::check_item_access([
|
||||
$to_unique_id, $moving_unique_id
|
||||
], $shared);
|
||||
}
|
||||
|
||||
// Move item
|
||||
Editor::move($request, $to_unique_id, $shared);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
72
app/Http/Controllers/FileFunctions/FavouriteController.php
Normal file
72
app/Http/Controllers/FileFunctions/FavouriteController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FileFunctions;
|
||||
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Tools\Demo;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FavouriteController extends Controller
|
||||
{
|
||||
/**
|
||||
* Add folder to user favourites
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->input('folders'), [
|
||||
'*.unique_id' => 'required|integer',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
foreach($request->input('folders') as $item) {
|
||||
|
||||
// Get user & folder
|
||||
$user = Auth::user();
|
||||
$folder = FileManagerFolder::where('unique_id', $item['unique_id'])->first();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::favourites($user);
|
||||
}
|
||||
|
||||
// Check ownership
|
||||
if ($folder->user_id !== $user->id) abort(403);
|
||||
|
||||
// Add folder to user favourites
|
||||
$user->favourite_folders()->syncWithoutDetaching($item['unique_id']);
|
||||
|
||||
}
|
||||
// Return updated favourites
|
||||
return $user->favourite_folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folder from user favourites
|
||||
*
|
||||
* @param $unique_id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($unique_id)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::favourites($user);
|
||||
}
|
||||
|
||||
// Remove folder from user favourites
|
||||
$user->favourite_folders()->detach($unique_id);
|
||||
|
||||
// Return updated favourites
|
||||
return $user->favourite_folders;
|
||||
}
|
||||
}
|
||||
159
app/Http/Controllers/FileFunctions/ShareController.php
Normal file
159
app/Http/Controllers/FileFunctions/ShareController.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FileFunctions;
|
||||
|
||||
use App\Http\Requests\Share\CreateShareRequest;
|
||||
use App\Http\Requests\Share\UpdateShareRequest;
|
||||
use App\Http\Resources\ShareResource;
|
||||
use App\Notifications\SharedSendViaEmail;
|
||||
use App\Zip;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Share;
|
||||
use Validator;
|
||||
|
||||
class ShareController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get shared record
|
||||
*
|
||||
* @return ShareResource
|
||||
*/
|
||||
public function show($token)
|
||||
{
|
||||
// Get record
|
||||
$shared = Share::where(DB::raw('BINARY `token`'), $token)
|
||||
->firstOrFail();
|
||||
|
||||
return new ShareResource($shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file share link
|
||||
*
|
||||
* @param CreateShareRequest $request
|
||||
* @return ShareResource
|
||||
*/
|
||||
public function store(CreateShareRequest $request)
|
||||
{
|
||||
do {
|
||||
// Generate unique token
|
||||
$token = Str::random(16);
|
||||
|
||||
} while (Share::where(DB::raw('BINARY `token`'), $token)->exists());
|
||||
|
||||
// Create shared options
|
||||
$options = [
|
||||
'password' => $request->has('password') ? Hash::make($request->password) : null,
|
||||
'type' => $request->type === 'folder' ? 'folder' : 'file',
|
||||
'protected' => $request->isPassword,
|
||||
'permission' => $request->permission,
|
||||
'item_id' => $request->unique_id,
|
||||
'expire_in' => $request->expiration,
|
||||
'user_id' => Auth::id(),
|
||||
'token' => $token,
|
||||
];
|
||||
|
||||
// Return created shared record
|
||||
$share = new ShareResource(Share::create($options));
|
||||
|
||||
// Send shared link via email
|
||||
if ($request->has('emails')) {
|
||||
|
||||
foreach ($request->emails as $email) {
|
||||
Notification::route('mail', $email)->notify(new SharedSendViaEmail($token));
|
||||
}
|
||||
}
|
||||
|
||||
return $share;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sharing
|
||||
*
|
||||
* @param UpdateShareRequest $request
|
||||
* @param $token
|
||||
* @return ShareResource
|
||||
*/
|
||||
public function update(UpdateShareRequest $request, $token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where('token', $token)
|
||||
->where('user_id', Auth::id())
|
||||
->firstOrFail();
|
||||
|
||||
// Update sharing record
|
||||
$shared->update([
|
||||
'permission' => $request->permission,
|
||||
'protected' => $request->protected,
|
||||
'expire_in' => $request->expiration,
|
||||
'password' => $request->password ? Hash::make($request->password) : $shared->password,
|
||||
]);
|
||||
|
||||
// Return shared record
|
||||
return new ShareResource($shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sharing item
|
||||
*
|
||||
* @param $token
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
foreach ($request->input('tokens') as $token) {
|
||||
|
||||
// Get sharing record
|
||||
Share::where('token', $token)
|
||||
->where('user_id', Auth::id())
|
||||
->firstOrFail()
|
||||
->delete();
|
||||
|
||||
// Get zip record
|
||||
$zip = Zip::where('shared_token', $token)
|
||||
->where('user_id', Auth::id())
|
||||
->first();
|
||||
|
||||
if ($zip) {
|
||||
$zip->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send shared link via email to recipients
|
||||
*
|
||||
* @param $token
|
||||
* @param $request
|
||||
*/
|
||||
public function shared_send_via_email(Request $request, $token)
|
||||
{
|
||||
// Make validation of array of emails
|
||||
$validator = Validator::make($request->all(), [
|
||||
'emails.*' => 'required|email',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad email input');
|
||||
|
||||
// Send shared link via email
|
||||
if($request->has('emails')) {
|
||||
foreach ($request->emails as $email) {
|
||||
Notification::route('mail', $email)->notify(new SharedSendViaEmail($token));
|
||||
}
|
||||
}
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
118
app/Http/Controllers/FileFunctions/TrashController.php
Normal file
118
app/Http/Controllers/FileFunctions/TrashController.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FileFunctions;
|
||||
|
||||
use App\Http\Tools\Demo;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\FileManagerFolder;
|
||||
use App\FileManagerFile;
|
||||
|
||||
class TrashController extends Controller
|
||||
{
|
||||
/**
|
||||
* Empty user trash
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
if (is_demo($user_id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Get files and folders
|
||||
$folders = FileManagerFolder::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
$files = FileManagerFile::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
|
||||
// Force delete folder
|
||||
$folders->each->forceDelete();
|
||||
|
||||
// Force delete files
|
||||
foreach ($files as $file) {
|
||||
|
||||
// Delete file
|
||||
Storage::delete('/file-manager/' . $file->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if ($file->thumbnail) Storage::delete('/file-manager/' . $file->getRawOriginal('thumbnail'));
|
||||
|
||||
// Delete file permanently
|
||||
$file->forceDelete();
|
||||
}
|
||||
|
||||
// Return response
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore item from trash
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $unique_id
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function restore(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->input('data'), [
|
||||
'*.type' => 'required|string',
|
||||
'*.unique_id' => 'integer',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
if (is_demo($user_id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
foreach($request->input('data') as $restore_item) {
|
||||
|
||||
// Get folder
|
||||
if ($restore_item['type'] === 'folder') {
|
||||
|
||||
// Get folder
|
||||
$item = FileManagerFolder::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('unique_id', $restore_item['unique_id'])
|
||||
->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->parent_id = 0;
|
||||
$item->save();
|
||||
}
|
||||
} else {
|
||||
|
||||
// Get item
|
||||
$item = FileManagerFile::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('unique_id', $restore_item['unique_id'])
|
||||
->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->folder_id = 0;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Restore Item
|
||||
$item->restore();
|
||||
}
|
||||
|
||||
// Return response
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
@@ -1,620 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App\FileManagerFolder;
|
||||
use App\FileManagerFile;
|
||||
use Response;
|
||||
|
||||
|
||||
class FileManagerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get trashed files
|
||||
*
|
||||
* @param Request $request
|
||||
* @return FileManagerFile[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
|
||||
*/
|
||||
public function trash()
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folders and files
|
||||
$folders_trashed = FileManagerFolder::onlyTrashed()
|
||||
->with(['trashed_folders'])
|
||||
->where('user_id', $user_id)
|
||||
->get(['parent_id', 'unique_id', 'name']);
|
||||
|
||||
$folders = FileManagerFolder::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('unique_id', filter_folders_ids($folders_trashed))
|
||||
->get();
|
||||
|
||||
// Get files trashed
|
||||
$files_trashed = FileManagerFile::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->whereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'unique_id'))))
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files_trashed])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory with files
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function folder(Request $request, $unique_id)
|
||||
{
|
||||
// Get user
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folder trash items
|
||||
if ($request->query('trash')) {
|
||||
|
||||
// Get folders and files
|
||||
$folders = FileManagerFolder::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->with('parent')
|
||||
->where('parent_id', $unique_id)
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->with('parent')
|
||||
->where('folder_id', $unique_id)
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
// Get folders and files
|
||||
$folders = FileManagerFolder::with('parent')
|
||||
->where('user_id', $user_id)
|
||||
->where('parent_id', $unique_id)
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::with('parent')
|
||||
->where('user_id', $user_id)
|
||||
->where('folder_id', $unique_id)
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search files
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'query' => 'required|string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Search files id db
|
||||
$searched_files = FileManagerFile::search($request->input('query'))->where('user_id', $user_id)->get();
|
||||
$searched_folders = FileManagerFolder::search($request->input('query'))->where('user_id', $user_id)->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$searched_folders, $searched_files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new folder
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function create_folder(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'parent_id' => 'required|integer',
|
||||
'name' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get parent_id from request
|
||||
$parent_id = $request->parent_id === 0 ? 0 : $request->parent_id;
|
||||
|
||||
// Create folder
|
||||
$folder = FileManagerFolder::create([
|
||||
'user_id' => Auth::id(),
|
||||
'parent_id' => $parent_id,
|
||||
'name' => $request->has('name') ? $request->input('name') : 'New Folder',
|
||||
'type' => 'folder',
|
||||
'unique_id' => $this->get_unique_id(),
|
||||
]);
|
||||
|
||||
// Return new folder
|
||||
return $folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item name
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function rename_item(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'unique_id' => 'required|integer',
|
||||
'name' => 'required|string',
|
||||
'type' => 'required|string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Update folder name
|
||||
if ($request->type === 'folder') {
|
||||
|
||||
$item = FileManagerFolder::where('unique_id', $request->unique_id)
|
||||
->where('user_id', $user_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->name = $request->name;
|
||||
$item->save();
|
||||
|
||||
} else {
|
||||
|
||||
$item = FileManagerFile::where('unique_id', $request->unique_id)
|
||||
->where('user_id', $user_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->name = $request->name;
|
||||
$item->save();
|
||||
}
|
||||
|
||||
// Return updated item
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete item
|
||||
*
|
||||
* @param Request $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete_item(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'unique_id' => 'required|integer',
|
||||
'type' => 'required|string',
|
||||
'force_delete' => 'required|boolean',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user id
|
||||
$user = Auth::user();
|
||||
|
||||
// Delete folder
|
||||
if ($request->type === 'folder') {
|
||||
|
||||
$item = FileManagerFolder::withTrashed()
|
||||
->with('folders')
|
||||
->where('user_id', $user->id)
|
||||
->where('unique_id', $request->unique_id)
|
||||
->first();
|
||||
|
||||
// Remove folder from user favourites
|
||||
$user->favourites()->detach($request->unique_id);
|
||||
|
||||
foreach ($item->files as $file) {
|
||||
|
||||
if ($request->force_delete) {
|
||||
|
||||
// Delete file
|
||||
Storage::disk('local')->delete('/file-manager/' . $file->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if (!is_null($file->thumbnail)) Storage::disk('local')->delete('/file-manager/' . $file->getOriginal('thumbnail'));
|
||||
|
||||
// Delete file permanently
|
||||
$file->forceDelete();
|
||||
} else {
|
||||
|
||||
// Delete file from visibility
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete record
|
||||
if ($request->force_delete) {
|
||||
|
||||
$item->forceDelete();
|
||||
} else {
|
||||
|
||||
$item->delete();
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->type === 'file' || $request->type === 'image') {
|
||||
|
||||
$item = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user->id)
|
||||
->where('unique_id', $request->unique_id)
|
||||
->first();
|
||||
|
||||
if ($request->force_delete) {
|
||||
|
||||
// Delete file
|
||||
Storage::disk('local')->delete('/file-manager/' . $item->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if (!is_null($item->thumbnail)) Storage::disk('local')->delete('/file-manager/' . $item->thumbnail);
|
||||
|
||||
// Delete file permanently
|
||||
$item->forceDelete();
|
||||
} else {
|
||||
|
||||
// Delete file from visibility
|
||||
$item->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty user trash
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function empty_trash()
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get files and folders
|
||||
$folders = FileManagerFolder::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
$files = FileManagerFile::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
|
||||
// Force delete every item
|
||||
$folders->each->forceDelete();
|
||||
$files->each->forceDelete();
|
||||
|
||||
// Return response
|
||||
return response('Done!', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore item from trash
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function restore_item(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'unique_id' => 'required|integer',
|
||||
'type' => 'required|string',
|
||||
'to_home' => 'boolean',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folder
|
||||
if ($request->type === 'folder') {
|
||||
|
||||
// Get folder
|
||||
$item = FileManagerFolder::onlyTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->parent_id = 0;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Get file
|
||||
if ($request->type === 'file' || $request->type === 'image') {
|
||||
|
||||
// Get item
|
||||
$item = FileManagerFile::onlyTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->folder_id = 0;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Restore Item
|
||||
$item->restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Item
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function delete_items(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'items' => 'required|json',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
foreach ($request->input('items') as $file) {
|
||||
|
||||
if ($file['type'] === 'file' || $file['type'] === 'image') {
|
||||
|
||||
$item = FileManagerFile::where('unique_id', $file['unique_id'])->first();
|
||||
|
||||
} else {
|
||||
|
||||
$item = FileManagerFolder::where('unique_id', $file['unique_id'])->first();
|
||||
}
|
||||
|
||||
// Delete file
|
||||
Storage::disk('local')->delete('/file-manager/' . $item->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if (!is_null($item->thumbnail)) {
|
||||
Storage::disk('local')->delete('/file-manager/' . $item->thumbnail);
|
||||
}
|
||||
|
||||
// Permanently delete file
|
||||
$item->forceDelete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload items
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function upload_item(Request $request)
|
||||
{
|
||||
// Check if user can upload
|
||||
if (config('vuefilemanager.limit_storage_by_capacity') && user_storage_percentage() >= 100)
|
||||
abort(423, 'You exceed your storage limit!');
|
||||
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'parent_id' => 'required|integer',
|
||||
'file' => 'required|file',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get parent_id from request
|
||||
$folder_id = $request->parent_id === 0 ? 0 : $request->parent_id;
|
||||
$file = $request->file('file');
|
||||
|
||||
// File
|
||||
$filename = Str::random() . '-' . str_replace(' ', '', $file->getClientOriginalName());
|
||||
$filetype = 'file';
|
||||
$thumbnail = null;
|
||||
$filesize = $file->getSize();
|
||||
$directory = 'file-manager';
|
||||
|
||||
// create directory if not exist
|
||||
if (!Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
|
||||
// Store to disk
|
||||
Storage::disk('local')->putFileAs($directory, $file, $filename, 'public');
|
||||
|
||||
// Create image thumbnail
|
||||
if (substr($file->getMimeType(), 0, 5) == 'image') {
|
||||
|
||||
$filetype = 'image';
|
||||
$thumbnail = 'thumbnail-' . $filename;
|
||||
|
||||
// Create intervention image
|
||||
$image = Image::make($file->getRealPath());
|
||||
|
||||
$image->resize(256, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
})->save(null, 90);
|
||||
|
||||
// Store thumbnail to s3
|
||||
Storage::disk('local')->put($directory . '/' . $thumbnail, $image);
|
||||
}
|
||||
|
||||
// Store file
|
||||
$new_file = FileManagerFile::create([
|
||||
'user_id' => Auth::id(),
|
||||
'name' => pathinfo($file->getClientOriginalName())['filename'],
|
||||
'basename' => $filename,
|
||||
'folder_id' => $folder_id,
|
||||
'mimetype' => $file->getClientOriginalExtension(),
|
||||
'filesize' => $filesize,
|
||||
'type' => $filetype,
|
||||
'thumbnail' => $thumbnail,
|
||||
'unique_id' => $this->get_unique_id(),
|
||||
]);
|
||||
|
||||
return $new_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move item
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function move_item(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'from_unique_id' => 'required|integer',
|
||||
'to_unique_id' => 'required|integer',
|
||||
'from_type' => 'required|string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
if ($request->from_type === 'folder') {
|
||||
|
||||
// Move folder
|
||||
$item = FileManagerFolder::where('user_id', $user_id)
|
||||
->where('unique_id', $request->from_unique_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->parent_id = $request->to_unique_id;
|
||||
|
||||
} else {
|
||||
|
||||
// Move file under new folder
|
||||
$item = FileManagerFile::where('user_id', $user_id)
|
||||
->where('unique_id', $request->from_unique_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->folder_id = $request->to_unique_id;
|
||||
}
|
||||
|
||||
$item->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file record
|
||||
*
|
||||
* @param $unique_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_file_detail($unique_id)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
return FileManagerFile::where('user_id', $user_id)->where('unique_id', $unique_id)->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_file($filename)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Get file path
|
||||
$path = storage_path() . '/app/file-manager/' . $file->basename;
|
||||
|
||||
// Check if file exist
|
||||
if (!File::exists($path)) abort(404);
|
||||
|
||||
$file = File::get($path);
|
||||
$type = File::mimeType($path);
|
||||
$size = File::size($path);
|
||||
|
||||
// Create response
|
||||
$response = Response::make($file, 200);
|
||||
$response->header("Content-Type", $type);
|
||||
$response->header("Content-Disposition", 'attachment; filename=' . $filename);
|
||||
$response->header("Content-Length", $size);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image thumbnail
|
||||
*
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_thumbnail($filename)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Get file path
|
||||
$path = storage_path() . '/app/file-manager/' . $file->getOriginal('thumbnail');
|
||||
|
||||
// Check if file exist
|
||||
if (!File::exists($path)) abort(404);
|
||||
|
||||
$file = File::get($path);
|
||||
$type = File::mimeType($path);
|
||||
|
||||
// Create response
|
||||
$response = Response::make($file, 200);
|
||||
$response->header("Content-Type", $type);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unique id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function get_unique_id(): int
|
||||
{
|
||||
// Get files and folders
|
||||
$folders = FileManagerFolder::withTrashed()->get();
|
||||
$files = FileManagerFile::withTrashed()->get();
|
||||
|
||||
// Get last ids
|
||||
$folders_unique = $folders->isEmpty() ? 0 : $folders->last()->unique_id;
|
||||
$files_unique = $files->isEmpty() ? 0 : $files->last()->unique_id;
|
||||
|
||||
// Count new unique id
|
||||
$unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1;
|
||||
|
||||
return $unique_id;
|
||||
}
|
||||
}
|
||||
48
app/Http/Controllers/General/PricingController.php
Normal file
48
app/Http/Controllers/General/PricingController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\General;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PricingCollection;
|
||||
use App\Services\StripeService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class PricingController extends Controller
|
||||
{
|
||||
/**
|
||||
* PlanController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active plans
|
||||
*
|
||||
* @return PricingCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (Cache::has('pricing')) {
|
||||
|
||||
// Get pricing from cache
|
||||
$pricing = Cache::get('pricing');
|
||||
} else {
|
||||
|
||||
// Store pricing to cache
|
||||
$pricing = Cache::rememberForever('pricing', function () {
|
||||
return $this->stripe->getActivePlans();
|
||||
});
|
||||
}
|
||||
|
||||
// Format pricing to collection
|
||||
$collection = new PricingCollection($pricing);
|
||||
|
||||
// Sort and return pricing
|
||||
return $collection->sortBy('product.metadata.capacity')
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
}
|
||||
575
app/Http/Controllers/General/SetupWizardController.php
Normal file
575
app/Http/Controllers/General/SetupWizardController.php
Normal file
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\General;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SetupWizard\CreateAdminRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreAppSetupRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreDatabaseCredentialsRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreEnvironmentSetupRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeBillingRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeCredentialsRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripePlansRequest;
|
||||
use App\Page;
|
||||
use App\Services\StripeService;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use App\UserSettings;
|
||||
use Artisan;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Schema;
|
||||
use Stripe;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SetupWizardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Inject Stripe Service
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Envato purchase code
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response|mixed
|
||||
*/
|
||||
public function verify_purchase_code(Request $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Verify purchase code
|
||||
$response = Http::get('https://verify.vuefilemanager.com/api/verify-code/' . $request->purchaseCode);
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return response('Purchase code is invalid.', 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up database credentials
|
||||
*
|
||||
* @param StoreDatabaseCredentialsRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function setup_database(StoreDatabaseCredentialsRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
try {
|
||||
// Set temporary database connection
|
||||
config(['database.connections.test.driver' => $request->connection]);
|
||||
config(['database.connections.test.host' => $request->host]);
|
||||
config(['database.connections.test.port' => $request->port]);
|
||||
config(['database.connections.test.database' => $request->name]);
|
||||
config(['database.connections.test.username' => $request->username]);
|
||||
config(['database.connections.test.password' => $request->password]);
|
||||
|
||||
// Test connection
|
||||
\DB::connection('test')->getPdo();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new HttpException(500, $e->getMessage());
|
||||
}
|
||||
|
||||
setEnvironmentValue([
|
||||
'DB_CONNECTION' => $request->connection,
|
||||
'DB_HOST' => $request->host,
|
||||
'DB_PORT' => $request->port,
|
||||
'DB_DATABASE' => $request->name,
|
||||
'DB_USERNAME' => $request->username,
|
||||
'DB_PASSWORD' => $request->password,
|
||||
]);
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('config:cache');
|
||||
|
||||
// Set up application
|
||||
$this->set_up_application();
|
||||
|
||||
// Store setup wizard progress
|
||||
Setting::create([
|
||||
'name' => 'setup_wizard_database',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store and test stripe credentials
|
||||
*
|
||||
* @param StoreStripeCredentialsRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_stripe_credentials(StoreStripeCredentialsRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Create stripe instance
|
||||
$stripe = Stripe::make($request->secret, '2020-03-02');
|
||||
|
||||
// Try to get stripe account details
|
||||
try {
|
||||
$stripe->account()->details();
|
||||
} catch (UnauthorizedException $e) {
|
||||
throw new HttpException(401, $e->getMessage());
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
});
|
||||
|
||||
// Set stripe credentials to .env
|
||||
setEnvironmentValue([
|
||||
'CASHIER_CURRENCY' => $request->currency,
|
||||
'STRIPE_KEY' => $request->key,
|
||||
'STRIPE_SECRET' => $request->secret,
|
||||
'STRIPE_WEBHOOK_SECRET' => $request->webhookSecret,
|
||||
]);
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('config:cache');
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Stripe billings
|
||||
*
|
||||
* @param StoreStripeBillingRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_stripe_billings(StoreStripeBillingRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
[
|
||||
'name' => 'billing_phone_number',
|
||||
'value' => $request->billing_phone_number,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_postal_code',
|
||||
'value' => $request->billing_postal_code,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_vat_number',
|
||||
'value' => $request->billing_vat_number,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_address',
|
||||
'value' => $request->billing_address,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_country',
|
||||
'value' => $request->billing_country,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_state',
|
||||
'value' => $request->billing_state,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_city',
|
||||
'value' => $request->billing_city,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_name',
|
||||
'value' => $request->billing_name,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
});
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('config:cache');
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Stripe subscription plan
|
||||
*
|
||||
* @param StoreStripePlansRequest $request
|
||||
*/
|
||||
public function store_stripe_plans(StoreStripePlansRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
foreach ($request->input('plans') as $plan) {
|
||||
$this->stripe->createPlan($plan);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store environment setup
|
||||
*
|
||||
* @param StoreEnvironmentSetupRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function store_environment_setup(StoreEnvironmentSetupRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
$storage_driver = $request->input('storage.driver');
|
||||
|
||||
if ($storage_driver === 'local') {
|
||||
|
||||
setEnvironmentValue([
|
||||
'FILESYSTEM_DRIVER' => 'local',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($storage_driver === 's3') {
|
||||
|
||||
setEnvironmentValue([
|
||||
'FILESYSTEM_DRIVER' => $request->input('storage.driver'),
|
||||
'AWS_ACCESS_KEY_ID' => $request->input('storage.key'),
|
||||
'AWS_SECRET_ACCESS_KEY' => $request->input('storage.secret'),
|
||||
'AWS_DEFAULT_REGION' => $request->input('storage.region'),
|
||||
'AWS_BUCKET' => $request->input('storage.bucket'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($storage_driver === 'spaces') {
|
||||
|
||||
setEnvironmentValue([
|
||||
'FILESYSTEM_DRIVER' => $request->input('storage.driver'),
|
||||
'DO_SPACES_KEY' => $request->input('storage.key'),
|
||||
'DO_SPACES_SECRET' => $request->input('storage.secret'),
|
||||
'DO_SPACES_ENDPOINT' => $request->input('storage.endpoint'),
|
||||
'DO_SPACES_REGION' => $request->input('storage.region'),
|
||||
'DO_SPACES_BUCKET' => $request->input('storage.bucket'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($storage_driver === 'wasabi') {
|
||||
|
||||
setEnvironmentValue([
|
||||
'FILESYSTEM_DRIVER' => $request->input('storage.driver'),
|
||||
'WASABI_KEY' => $request->input('storage.key'),
|
||||
'WASABI_SECRET' => $request->input('storage.secret'),
|
||||
'WASABI_ENDPOINT' => $request->input('storage.endpoint'),
|
||||
'WASABI_REGION' => $request->input('storage.region'),
|
||||
'WASABI_BUCKET' => $request->input('storage.bucket'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($storage_driver === 'backblaze') {
|
||||
|
||||
setEnvironmentValue([
|
||||
'FILESYSTEM_DRIVER' => $request->input('storage.driver'),
|
||||
'BACKBLAZE_KEY' => $request->input('storage.key'),
|
||||
'BACKBLAZE_SECRET' => $request->input('storage.secret'),
|
||||
'BACKBLAZE_ENDPOINT' => $request->input('storage.endpoint'),
|
||||
'BACKBLAZE_REGION' => $request->input('storage.region'),
|
||||
'BACKBLAZE_BUCKET' => $request->input('storage.bucket'),
|
||||
]);
|
||||
}
|
||||
|
||||
setEnvironmentValue([
|
||||
'MAIL_DRIVER' => $request->input('mail.driver'),
|
||||
'MAIL_HOST' => $request->input('mail.host'),
|
||||
'MAIL_PORT' => $request->input('mail.port'),
|
||||
'MAIL_USERNAME' => $request->input('mail.username'),
|
||||
'MAIL_PASSWORD' => $request->input('mail.password'),
|
||||
'MAIL_ENCRYPTION' => $request->input('mail.encryption'),
|
||||
]);
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('config:cache');
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store app settings
|
||||
* @param StoreAppSetupRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_app_settings(StoreAppSetupRequest $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Store Logo
|
||||
if ($request->hasFile('logo')) {
|
||||
$logo = store_system_image($request->file('logo'), 'system');
|
||||
}
|
||||
|
||||
// Store Logo horizontal
|
||||
if ($request->hasFile('logo_horizontal')) {
|
||||
$logo_horizontal = store_system_image($request->file('logo_horizontal'), 'system');
|
||||
}
|
||||
|
||||
// Store favicon
|
||||
if ($request->hasFile('favicon')) {
|
||||
$favicon = store_system_image($request->file('favicon'), 'system');
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => $request->title,
|
||||
],
|
||||
[
|
||||
'name' => 'app_description',
|
||||
'value' => $request->description,
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo',
|
||||
'value' => $request->hasFile('logo') ? $logo : null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo_horizontal',
|
||||
'value' => $request->hasFile('logo_horizontal') ? $logo_horizontal : null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_favicon',
|
||||
'value' => $request->hasFile('favicon') ? $favicon : null,
|
||||
],
|
||||
[
|
||||
'name' => 'google_analytics',
|
||||
'value' => $request->googleAnalytics,
|
||||
],
|
||||
[
|
||||
'name' => 'contact_email',
|
||||
'value' => $request->contactMail,
|
||||
],
|
||||
[
|
||||
'name' => 'registration',
|
||||
'value' => $request->userRegistration,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => $request->storageLimitation,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_default',
|
||||
'value' => $request->defaultStorage ? $request->defaultStorage : 5,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
});
|
||||
|
||||
setEnvironmentValue([
|
||||
'APP_NAME' => Str::camel($request->title),
|
||||
]);
|
||||
|
||||
return response('Done', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and login admin account
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function create_admin_account(Request $request)
|
||||
{
|
||||
// Check setup status
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'email' => 'required|string|email|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'name' => 'required|string',
|
||||
'purchase_code' => 'required|string',
|
||||
'license' => 'required|string',
|
||||
'avatar' => 'sometimes|file',
|
||||
]);
|
||||
|
||||
// Store avatar
|
||||
if ($request->hasFile('avatar')) {
|
||||
$avatar = store_avatar($request->file('avatar'), 'avatars');
|
||||
}
|
||||
|
||||
// Create user
|
||||
$user = User::forceCreate([
|
||||
'avatar' => $request->hasFile('avatar') ? $avatar : null,
|
||||
'name' => $request->name,
|
||||
'role' => 'admin',
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
// Get default storage capacity
|
||||
$storage_capacity = Setting::where('name', 'storage_default')->first();
|
||||
|
||||
// Create settings
|
||||
UserSettings::forceCreate([
|
||||
'user_id' => $user->id,
|
||||
'storage_capacity' => $storage_capacity->value,
|
||||
]);
|
||||
|
||||
// Store setup wizard progress
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
// Store License
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'license',
|
||||
'value' => $request->license,
|
||||
]);
|
||||
|
||||
// Store Purchase Code
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'purchase_code',
|
||||
'value' => $request->purchase_code,
|
||||
]);
|
||||
|
||||
// Create legal pages and index content
|
||||
$pages = collect(config('content.pages'));
|
||||
$content = $request->license === 'Extended' ? collect(config('content.content_extended')) : collect(config('content.content_regular'));
|
||||
|
||||
$content->each(function ($content) {
|
||||
Setting::updateOrCreate($content);
|
||||
});
|
||||
|
||||
$pages->each(function ($page) {
|
||||
Page::updateOrCreate($page);
|
||||
});
|
||||
|
||||
// Retrieve access token
|
||||
$response = Route::dispatch(self::make_login_request($request));
|
||||
|
||||
// Send access token to user if request is successful
|
||||
if ($response->isSuccessful()) {
|
||||
|
||||
$data = json_decode($response->content(), true);
|
||||
|
||||
return response('Admin was created', 200)->cookie('access_token', $data['access_token'], 43200);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate database and generate necessary things
|
||||
*/
|
||||
private function set_up_application()
|
||||
{
|
||||
// Generate app key
|
||||
Artisan::call('key:generate', [
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
// Migrate database
|
||||
Artisan::call('migrate:fresh', [
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
// Create Passport Keys
|
||||
Artisan::call('passport:keys', [
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
// Create Password grant client
|
||||
Artisan::call('passport:client', [
|
||||
'--password' => true,
|
||||
'--name' => 'vuefilemanager',
|
||||
]);
|
||||
|
||||
// Create Personal access client
|
||||
Artisan::call('passport:client', [
|
||||
'--personal' => true,
|
||||
'--name' => 'shared',
|
||||
]);
|
||||
|
||||
// Get generated client
|
||||
$client = \DB::table('oauth_clients')->where('name', '=', 'vuefilemanager')->first();
|
||||
|
||||
// Set passport client to .env
|
||||
setEnvironmentValue([
|
||||
'PASSPORT_CLIENT_ID' => $client->id,
|
||||
'PASSPORT_CLIENT_SECRET' => $client->secret,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make login request for get access token
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Request
|
||||
*/
|
||||
private static function make_login_request($request)
|
||||
{
|
||||
$request->request->add([
|
||||
'grant_type' => 'password',
|
||||
'client_id' => config('services.passport.client_id'),
|
||||
'client_secret' => config('services.passport.client_secret'),
|
||||
'username' => $request->email,
|
||||
'password' => $request->password,
|
||||
'scope' => 'master',
|
||||
]);
|
||||
|
||||
return Request::create(url('/oauth/token'), 'POST', $request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get setup wizard status
|
||||
*
|
||||
* @return |null
|
||||
*/
|
||||
private function get_setup_status()
|
||||
{
|
||||
try {
|
||||
// Check database connections
|
||||
DB::getPdo();
|
||||
|
||||
// Get setup_wizard status
|
||||
return Schema::hasTable('settings') ? Setting::where('name', 'setup_wizard_success')->first() : false;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
125
app/Http/Controllers/General/UpgradeAppController.php
Normal file
125
app/Http/Controllers/General/UpgradeAppController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\General;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Page;
|
||||
use App\Setting;
|
||||
use Artisan;
|
||||
use Illuminate\Http\Request;
|
||||
use Schema;
|
||||
|
||||
class UpgradeAppController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Start maintenance mode
|
||||
*/
|
||||
public function up() {
|
||||
$command = Artisan::call('up');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in production mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End maintenance mode
|
||||
*/
|
||||
public function down() {
|
||||
$command = Artisan::call('down');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in maintenance mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade database
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
/*
|
||||
* Upgrade user_settings & file_manager_folders table
|
||||
*
|
||||
* @since v1.8.1
|
||||
*/
|
||||
if (! Schema::hasColumn('user_settings', 'timezone') && ! Schema::hasColumn('file_manager_folders', 'icon_color')) {
|
||||
|
||||
$this->upgrade_database();
|
||||
|
||||
// Create legal pages and index content for regular license
|
||||
if (get_setting('license') === 'Regular') {
|
||||
|
||||
$pages = collect(config('content.pages'));
|
||||
$content = collect(config('content.content_regular'));
|
||||
|
||||
$content->each(function ($content) {
|
||||
Setting::updateOrCreate($content);
|
||||
});
|
||||
|
||||
$pages->each(function ($page) {
|
||||
Page::updateOrCreate($page);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Upgrade expire_in in shares table
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
if (! Schema::hasTable('traffic') && ! Schema::hasTable('zips') && ! Schema::hasTable('jobs')) {
|
||||
|
||||
$this->upgrade_database();
|
||||
}
|
||||
/*
|
||||
* Upgrade expire_in in shares table
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
if (! Schema::hasTable('traffic') && ! Schema::hasTable('zips') && ! Schema::hasTable('jobs')) {
|
||||
|
||||
$this->upgrade_database();
|
||||
}
|
||||
|
||||
/*
|
||||
* Upgrade expire_in in shares table
|
||||
*
|
||||
* @since v1.7.9
|
||||
*/
|
||||
if (! Schema::hasColumn('shares', 'expire_in')) {
|
||||
|
||||
$this->upgrade_database();
|
||||
}
|
||||
|
||||
/*
|
||||
* Upgrade expire_in in shares table
|
||||
*
|
||||
* @since v1.7.11
|
||||
*/
|
||||
if (! Schema::hasColumn('file_manager_files', 'metadata')) {
|
||||
|
||||
$this->upgrade_database();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|mixed
|
||||
*/
|
||||
private function upgrade_database()
|
||||
{
|
||||
$command = Artisan::call('migrate', [
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'Operation was successful.';
|
||||
}
|
||||
|
||||
if ($command === 1) {
|
||||
echo 'Operation failed.';
|
||||
}
|
||||
return $command;
|
||||
}
|
||||
}
|
||||
156
app/Http/Controllers/SettingController.php
Normal file
156
app/Http/Controllers/SettingController.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Setting;
|
||||
use Artisan;
|
||||
use Stripe;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get table content
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
$column = $request->get('column');
|
||||
|
||||
if (strpos($column, '|') !== false) {
|
||||
|
||||
$columns = explode('|', $column);
|
||||
|
||||
return Setting::whereIn('name', $columns)->pluck('value', 'name');
|
||||
}
|
||||
|
||||
return Setting::where('name', $column)->pluck('value', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Store image if exist
|
||||
if ($request->hasFile($request->name)) {
|
||||
|
||||
// Store image
|
||||
$image_path = store_system_image($request->file($request->name), 'system');
|
||||
|
||||
// Find and update image path
|
||||
Setting::updateOrCreate(['name' => $request->name], [
|
||||
'value' => $image_path
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
// Find and update variable
|
||||
Setting::updateOrCreate(['name' => $request->name], [
|
||||
'value' => $request->value
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new email credentials to .env file
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function set_email(Request $request)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
setEnvironmentValue([
|
||||
'MAIL_DRIVER' => $request->input('driver'),
|
||||
'MAIL_HOST' => $request->input('host'),
|
||||
'MAIL_PORT' => $request->input('port'),
|
||||
'MAIL_USERNAME' => $request->input('username'),
|
||||
'MAIL_PASSWORD' => $request->input('password'),
|
||||
'MAIL_ENCRYPTION' => $request->input('encryption'),
|
||||
]);
|
||||
|
||||
// Clear config cache
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure stripe additionally
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function set_stripe(Request $request)
|
||||
{
|
||||
// Get stripe status
|
||||
$is_stripe = get_setting('payments_configured');
|
||||
|
||||
// Check setup status
|
||||
if ($is_stripe) abort(401, 'Gone');
|
||||
|
||||
// Create stripe instance
|
||||
$stripe = Stripe::make($request->secret, '2020-03-02');
|
||||
|
||||
// Try to get stripe account details
|
||||
try {
|
||||
$stripe->account()->details();
|
||||
} catch (UnauthorizedException $e) {
|
||||
throw new HttpException(401, $e->getMessage());
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
});
|
||||
|
||||
// Set stripe credentials to .env
|
||||
setEnvironmentValue([
|
||||
'CASHIER_CURRENCY' => $request->currency,
|
||||
'STRIPE_KEY' => $request->key,
|
||||
'STRIPE_SECRET' => $request->secret,
|
||||
'STRIPE_WEBHOOK_SECRET' => $request->webhookSecret,
|
||||
]);
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
}
|
||||
418
app/Http/Controllers/Sharing/FileSharingController.php
Normal file
418
app/Http/Controllers/Sharing/FileSharingController.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Share\AuthenticateShareRequest;
|
||||
use App\Http\Resources\ShareResource;
|
||||
use App\Http\Tools\Guardian;
|
||||
use App\Setting;
|
||||
use http\Env\Response;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\FileManagerFolder;
|
||||
use App\FileManagerFile;
|
||||
use App\User;
|
||||
use App\Share;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileSharingController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show page index and delete access_token & shared_token cookie
|
||||
*
|
||||
* @return Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index($token)
|
||||
{
|
||||
// Get shared token
|
||||
$shared = Share::where(\DB::raw('BINARY `token`'), $token)
|
||||
->first();
|
||||
|
||||
if (! $shared) {
|
||||
return view("index");
|
||||
}
|
||||
|
||||
// Delete old access_token if exist
|
||||
Cookie::queue('shared_access_token', '', -1);
|
||||
|
||||
// Set cookies
|
||||
if ((int) $shared->protected) {
|
||||
|
||||
// Set shared token
|
||||
Cookie::queue('shared_token', $token, 43200);
|
||||
}
|
||||
|
||||
// Check if shared is image file and then show it
|
||||
if ($shared->type === 'file' && ! (int) $shared->protected) {
|
||||
|
||||
$image = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('type', 'image')
|
||||
->where('unique_id', $shared->item_id)
|
||||
->first();
|
||||
|
||||
if ($image) {
|
||||
|
||||
// Store user download size
|
||||
User::find($shared->user_id)->record_download((int) $image->getRawOriginal('filesize'));
|
||||
|
||||
return $this->show_image($image);
|
||||
}
|
||||
}
|
||||
|
||||
// Get all settings
|
||||
$settings = Setting::all();
|
||||
|
||||
// Return page index
|
||||
return view("index")
|
||||
->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image from storage and show it
|
||||
*
|
||||
* @param $file
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
private function show_image($file)
|
||||
{
|
||||
// Format pretty filename
|
||||
$file_pretty_name = $file->name . '.' . $file->mimetype;
|
||||
|
||||
// Get file path
|
||||
$path = '/file-manager/' . $file->basename;
|
||||
|
||||
// Check if file exist
|
||||
if (!Storage::exists($path)) abort(404);
|
||||
|
||||
$header = [
|
||||
"Content-Type" => Storage::mimeType($path),
|
||||
"Content-Length" => Storage::size($path),
|
||||
"Accept-Ranges" => "bytes",
|
||||
"Content-Range" => "bytes 0-600/" . Storage::size($path),
|
||||
];
|
||||
|
||||
// Get file
|
||||
return Storage::response($path, $file_pretty_name, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Password for protected item
|
||||
*
|
||||
* @param AuthenticateShareRequest $request
|
||||
* @param $token
|
||||
* @return array
|
||||
*/
|
||||
public function authenticate(AuthenticateShareRequest $request, $token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where(DB::raw('BINARY `token`'), $token)->firstOrFail();
|
||||
|
||||
// Check password
|
||||
if (!Hash::check($request->password, $shared->password)) {
|
||||
|
||||
abort(401, __('vuefilemanager.incorrect_password'));
|
||||
}
|
||||
|
||||
// Get owner of shared content
|
||||
$user = User::find($shared->user_id);
|
||||
|
||||
// Define scope
|
||||
$scope = !is_null($shared->permission) ? $shared->permission : 'visitor';
|
||||
|
||||
// Generate token for visitor/editor
|
||||
$access_token = $user->createToken('shared_access_token', [$scope])->accessToken;
|
||||
|
||||
// Return authorize token with shared options
|
||||
return response(new ShareResource($shared), 200)
|
||||
->cookie('shared_token', $shared->token, 43200)
|
||||
->cookie('shared_access_token', $access_token, 43200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse private folders
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $unique_id
|
||||
* @return Collection
|
||||
*/
|
||||
public function get_private_folders(Request $request, $unique_id)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where('token', $request->cookie('shared_token'))->firstOrFail();
|
||||
|
||||
// Check if user can get directory
|
||||
Guardian::check_item_access($unique_id, $shared);
|
||||
|
||||
// Get files and folders
|
||||
list($folders, $files) = $this->get_items($unique_id, $shared);
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse public folders
|
||||
*
|
||||
* @param $unique_id
|
||||
* @return Collection
|
||||
*/
|
||||
public function get_public_folders($unique_id, $token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where(DB::raw('BINARY `token`'), $token)->firstOrFail();
|
||||
|
||||
// Abort if folder is protected
|
||||
if ((int) $shared->protected) {
|
||||
abort(403, "Sorry, you don't have permission");
|
||||
}
|
||||
|
||||
// Check if user can get directory
|
||||
Guardian::check_item_access($unique_id, $shared);
|
||||
|
||||
// Get files and folders
|
||||
list($folders, $files) = $this->get_items($unique_id, $shared);
|
||||
|
||||
// Set thumbnail links for public files
|
||||
$files->map(function ($item) use ($token) {
|
||||
$item->setPublicUrl($token);
|
||||
});
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared public file record
|
||||
*
|
||||
* @param $token
|
||||
* @return mixed
|
||||
*/
|
||||
public function file_public($token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where(DB::raw('BINARY `token`'), $token)->firstOrFail();
|
||||
|
||||
// Abort if file is protected
|
||||
if ((int) $shared->protected) {
|
||||
abort(403, "Sorry, you don't have permission");
|
||||
}
|
||||
|
||||
// Get file
|
||||
$file = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('unique_id', $shared->item_id)
|
||||
->firstOrFail(['name', 'basename', 'thumbnail', 'type', 'filesize', 'mimetype']);
|
||||
|
||||
// Set urls
|
||||
$file->setPublicUrl($token);
|
||||
|
||||
// Return record
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared private file record
|
||||
*
|
||||
* @param $token
|
||||
* @return mixed
|
||||
*/
|
||||
public function file_private(Request $request)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where('token', $request->cookie('shared_token'))->firstOrFail();
|
||||
|
||||
// Return record
|
||||
return FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('unique_id', $shared->item_id)
|
||||
->firstOrFail(['name', 'basename', 'thumbnail', 'type', 'filesize', 'mimetype']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get navigation tree
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function get_private_navigation_tree(Request $request)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Check if user can get directory
|
||||
Guardian::check_item_access($shared->item_id, $shared);
|
||||
|
||||
// Get folders
|
||||
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('parent_id', $shared->item_id)
|
||||
->where('user_id', $shared->user_id)
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'unique_id', 'name']);
|
||||
|
||||
// Return folder tree
|
||||
return [
|
||||
[
|
||||
'unique_id' => $shared->item_id,
|
||||
'name' => __('vuefilemanager.home'),
|
||||
'location' => 'public',
|
||||
'folders' => $folders,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get navigation tree
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_public_navigation_tree($token)
|
||||
{
|
||||
// Get sharing record
|
||||
$shared = Share::where('token', $token)->firstOrFail();
|
||||
|
||||
// Check if user can get directory
|
||||
Guardian::check_item_access($shared->item_id, $shared);
|
||||
|
||||
// Get folders
|
||||
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('parent_id', $shared->item_id)
|
||||
->where('user_id', $shared->user_id)
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'unique_id', 'name']);
|
||||
|
||||
// Return folder tree
|
||||
return [
|
||||
[
|
||||
'unique_id' => $shared->item_id,
|
||||
'name' => __('vuefilemanager.home'),
|
||||
'location' => 'public',
|
||||
'folders' => $folders,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search private files
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $token
|
||||
* @return Collection
|
||||
*/
|
||||
public function search_private(Request $request)
|
||||
{
|
||||
// Get shared
|
||||
$shared = get_shared($request->cookie('shared_token'));
|
||||
|
||||
// Search files id db
|
||||
$searched_files = FileManagerFile::search($request->input('query'))
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
$searched_folders = FileManagerFolder::search($request->input('query'))
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
|
||||
// Get all children content
|
||||
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('user_id', $shared->user_id)
|
||||
->where('parent_id', $shared->item_id)
|
||||
->get();
|
||||
|
||||
// Get accessible folders
|
||||
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
||||
|
||||
// Filter files to only accessible files
|
||||
$files = $searched_files->filter(function ($file) use ($accessible_folder_ids) {
|
||||
return in_array($file->folder_id, $accessible_folder_ids);
|
||||
});
|
||||
|
||||
// Filter folders to only accessible folders
|
||||
$folders = $searched_folders->filter(function ($folder) use ($accessible_folder_ids) {
|
||||
return in_array($folder->unique_id, $accessible_folder_ids);
|
||||
});
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search public files
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $token
|
||||
* @return Collection
|
||||
*/
|
||||
public function search_public(Request $request, $token)
|
||||
{
|
||||
// Get shared
|
||||
$shared = get_shared($token);
|
||||
|
||||
// Abort if folder is protected
|
||||
if ((int) $shared->protected) {
|
||||
abort(403, "Sorry, you don't have permission");
|
||||
}
|
||||
|
||||
// Search files id db
|
||||
$searched_files = FileManagerFile::search($request->input('query'))
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
$searched_folders = FileManagerFolder::search($request->input('query'))
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
|
||||
// Get all children content
|
||||
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('user_id', $shared->user_id)
|
||||
->where('parent_id', $shared->item_id)
|
||||
->get();
|
||||
|
||||
// Get accessible folders
|
||||
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
||||
|
||||
// Filter files
|
||||
$files = $searched_files->filter(function ($file) use ($accessible_folder_ids, $token) {
|
||||
|
||||
// Set public urls
|
||||
$file->setPublicUrl($token);
|
||||
|
||||
// check if item is in accessible folders
|
||||
return in_array($file->folder_id, $accessible_folder_ids);
|
||||
});
|
||||
|
||||
// Filter folders
|
||||
$folders = $searched_folders->filter(function ($folder) use ($accessible_folder_ids) {
|
||||
|
||||
// check if item is in accessible folders
|
||||
return in_array($folder->unique_id, $accessible_folder_ids);
|
||||
});
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get folders and files
|
||||
*
|
||||
* @param $unique_id
|
||||
* @param $shared
|
||||
* @return array
|
||||
*/
|
||||
private function get_items($unique_id, $shared): array
|
||||
{
|
||||
$folders = FileManagerFolder::where('user_id', $shared->user_id)
|
||||
->where('parent_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = FileManagerFile::where('user_id', $shared->user_id)
|
||||
->where('folder_id', $unique_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
return [$folders, $files];
|
||||
}
|
||||
}
|
||||
159
app/Http/Controllers/User/AccountController.php
Normal file
159
app/Http/Controllers/User/AccountController.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\StorageDetailResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use App\Http\Tools\Demo;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use ByteUnits\Metric;
|
||||
use App\User;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all user data to frontend
|
||||
*
|
||||
* @return UserResource
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return new UserResource(
|
||||
Auth::user()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage details
|
||||
*
|
||||
* @return UserStorageResource
|
||||
*/
|
||||
public function storage()
|
||||
{
|
||||
return new UserStorageResource(
|
||||
Auth::user()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user invoices
|
||||
*
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function invoices() {
|
||||
return new InvoiceCollection(
|
||||
Auth::user()->invoices()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user profile
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update_profile(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'avatar' => 'file',
|
||||
'name' => 'string',
|
||||
'value' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Update data
|
||||
if ($request->hasFile('avatar')) {
|
||||
|
||||
// Update avatar
|
||||
$avatar = store_avatar($request->file('avatar'), 'avatars');
|
||||
|
||||
// Update data
|
||||
$user->update(['avatar' => $avatar]);
|
||||
|
||||
} else {
|
||||
|
||||
// Update text data
|
||||
$user->update(make_single_input($request));
|
||||
}
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user settings relationship
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update_user_settings(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'string',
|
||||
'value' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Update text data
|
||||
$user->settings->update(make_single_input($request));
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change user password
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function change_password(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
]);
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Change and store new password
|
||||
$user->password = Hash::make($request->input('password'));
|
||||
$user->save();
|
||||
|
||||
return response('Changed!', 204);
|
||||
}
|
||||
}
|
||||
172
app/Http/Controllers/User/PaymentMethodsController.php
Normal file
172
app/Http/Controllers/User/PaymentMethodsController.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Payments\RegisterNewPaymentMethodRequest;
|
||||
use App\Http\Resources\PaymentCardCollection;
|
||||
use App\Http\Resources\PaymentCardResource;
|
||||
use App\Http\Resources\PaymentDefaultCardResource;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Services\StripeService;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Cashier\PaymentMethod;
|
||||
|
||||
class PaymentMethodsController extends Controller
|
||||
{
|
||||
/**
|
||||
* PaymentMethodsController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user payment methods grouped by default and others
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->hasPaymentMethod()) {
|
||||
return abort(204, 'User don\'t have any payment methods');
|
||||
}
|
||||
|
||||
$slug_payment_methods = 'payment-methods-user-' . $user->id;
|
||||
$slug_default_payment_method = 'default-payment-methods-user-' . $user->id;
|
||||
|
||||
if (Cache::has($slug_payment_methods) && Cache::has($slug_default_payment_method)) {
|
||||
|
||||
$defaultPaymentMethod = Cache::get($slug_default_payment_method);
|
||||
$paymentMethodsMapped = Cache::get($slug_payment_methods);
|
||||
|
||||
} else {
|
||||
|
||||
// Get default payment method
|
||||
$defaultPaymentMethod = Cache::rememberForever($slug_default_payment_method, function () use ($user) {
|
||||
|
||||
$defaultPaymentMethodObject = $user->defaultPaymentMethod();
|
||||
|
||||
return $defaultPaymentMethodObject instanceof PaymentMethod
|
||||
? $defaultPaymentMethodObject->asStripePaymentMethod()
|
||||
: $defaultPaymentMethodObject;
|
||||
});
|
||||
|
||||
// filter payment methods without default payment
|
||||
$paymentMethodsMapped = Cache::rememberForever($slug_payment_methods, function () use ($defaultPaymentMethod, $user) {
|
||||
|
||||
$paymentMethods = $user->paymentMethods()->filter(function ($paymentMethod) use ($defaultPaymentMethod) {
|
||||
return $paymentMethod->id !== $defaultPaymentMethod->id;
|
||||
});
|
||||
|
||||
// Get payment methods
|
||||
return $paymentMethods->map(function ($paymentMethod) {
|
||||
return $paymentMethod->asStripePaymentMethod();
|
||||
})->values()->all();
|
||||
});
|
||||
}
|
||||
|
||||
if (!$user->card_brand || !$user->stripe_id || is_null($paymentMethodsMapped) && is_null($paymentMethodsMapped)) {
|
||||
return [
|
||||
'default' => null,
|
||||
'others' => [],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'default' => $defaultPaymentMethod instanceof PaymentMethod
|
||||
? new PaymentCardResource($defaultPaymentMethod)
|
||||
: new PaymentDefaultCardResource($defaultPaymentMethod),
|
||||
'others' => new PaymentCardCollection($paymentMethodsMapped),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update default payment method
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Update DefaultPayment Method
|
||||
$user->updateDefaultPaymentMethod($id);
|
||||
|
||||
// Sync default payment method
|
||||
$user->updateDefaultPaymentMethodFromStripe();
|
||||
|
||||
// Clear cached payment methods
|
||||
cache_forget_many([
|
||||
'payment-methods-user-' . $user->id,
|
||||
'default-payment-methods-user-' . $user->id
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new payment method for user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store(RegisterNewPaymentMethodRequest $request)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return response('Done', 201);
|
||||
}
|
||||
|
||||
// Register new payment method
|
||||
$this->stripe->registerNewPaymentMethod($request, $user);
|
||||
|
||||
return response('Done', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user payment method
|
||||
*
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Get payment method
|
||||
$paymentMethod = $user->findPaymentMethod($id);
|
||||
|
||||
// Delete payment method
|
||||
$paymentMethod->delete();
|
||||
|
||||
// Sync default payment method
|
||||
$user->updateDefaultPaymentMethodFromStripe();
|
||||
|
||||
// Clear cached payment methods
|
||||
cache_forget_many([
|
||||
'payment-methods-user-' . $user->id,
|
||||
'default-payment-methods-user-' . $user->id
|
||||
]);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
154
app/Http/Controllers/User/SubscriptionController.php
Normal file
154
app/Http/Controllers/User/SubscriptionController.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Subscription\StoreUpgradeAccountRequest;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Invoice;
|
||||
use App\Services\StripeService;
|
||||
use Auth;
|
||||
use Cartalyst\Stripe\Exception\CardErrorException;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Cashier\Exceptions\IncompletePayment;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SubscriptionController extends Controller
|
||||
{
|
||||
private $stripe;
|
||||
|
||||
/**
|
||||
* SubscriptionController constructor.
|
||||
* @param $payment
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate setup intent
|
||||
*
|
||||
* @return \Stripe\SetupIntent
|
||||
*/
|
||||
public function stripe_setup_intent()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
return $this->stripe->getSetupIntent($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user subscription detail
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (! $user->subscription('main')) {
|
||||
return abort(204, 'User don\'t have any subscription');
|
||||
}
|
||||
|
||||
$slug_user_subscription = 'subscription-user-' . $user->id;
|
||||
|
||||
if (Cache::has($slug_user_subscription)) {
|
||||
return Cache::get($slug_user_subscription);
|
||||
}
|
||||
|
||||
return Cache::rememberForever($slug_user_subscription, function () {
|
||||
return new UserSubscription(
|
||||
Auth::user()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade account to subscription
|
||||
*
|
||||
* @param StoreUpgradeAccountRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function upgrade(StoreUpgradeAccountRequest $request)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Forget user subscription
|
||||
Cache::forget('subscription-user-' . $user->id);
|
||||
|
||||
// Get requested plan
|
||||
$plan = $this->stripe->getPlan($request->input('plan.data.id'));
|
||||
|
||||
// Set user billing
|
||||
$user->setBilling($request->input('billing'));
|
||||
|
||||
// Update stripe customer billing info
|
||||
$this->stripe->updateCustomerDetails($user);
|
||||
|
||||
// Make subscription
|
||||
$this->stripe->createOrReplaceSubscription($request, $user);
|
||||
|
||||
// Update user storage limit
|
||||
$user->settings()->update([
|
||||
'storage_capacity' => $plan['product']['metadata']['capacity']
|
||||
]);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Subscription
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Cancel subscription
|
||||
$user->subscription('main')->cancel();
|
||||
|
||||
// Forget user subscription
|
||||
Cache::forget('subscription-user-' . $user->id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume Subscription
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Resume subscription
|
||||
$user->subscription('main')->resume();
|
||||
|
||||
// Forget user subscription
|
||||
Cache::forget('subscription-user-' . $user->id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use ByteUnits\Metric;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
|
||||
class UserAccountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all user data to frontend
|
||||
*
|
||||
* @return array|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get User
|
||||
$user = User::with(['favourites', 'latest_uploads'])->where('id', $user_id)->first();
|
||||
|
||||
return [
|
||||
'user' => $user->only(['name', 'email', 'avatar']),
|
||||
'favourites' => $user->favourites->makeHidden(['pivot']),
|
||||
'latest_uploads' => $user->latest_uploads->makeHidden(['user_id', 'basename']),
|
||||
|
||||
'storage' => [
|
||||
'used' => Metric::bytes($user->used_capacity)->format(),
|
||||
'capacity' => format_gigabytes(config('vuefilemanager.user_storage_capacity')),
|
||||
'percentage' => get_storage_fill_percentage($user->used_capacity, config('vuefilemanager.user_storage_capacity')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user profile
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update_profile(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'avatar' => 'file',
|
||||
'_method' => 'string',
|
||||
'name' => 'string',
|
||||
'value' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
if ($request->hasFile('avatar')) {
|
||||
|
||||
// Update avatar
|
||||
$avatar = store_avatar($request->file('avatar'), 'avatars');
|
||||
|
||||
// Update data
|
||||
$user->update(['avatar' => $avatar]);
|
||||
|
||||
} else {
|
||||
|
||||
// Update text data
|
||||
$user->update(make_single_input($request));
|
||||
}
|
||||
|
||||
return response('Saved!', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change user password
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function change_password(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
]);
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Change and store new password
|
||||
$user->password = Hash::make($request->input('password'));
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add folder to user favourites
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function add_to_favourites(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'unique_id' => 'required|integer',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Add folder to user favourites
|
||||
$user->favourites()->attach($request->unique_id);
|
||||
|
||||
// Return updated favourites
|
||||
return $user->favourites->makeHidden(['pivot']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folder from user favourites
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function remove_from_favourites(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'unique_id' => 'required|integer',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) abort(400, 'Bad input');
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Remove folder from user favourites
|
||||
$user->favourites()->detach($request->unique_id);
|
||||
|
||||
// Return updated favourites
|
||||
return $user->favourites->makeHidden(['pivot']);
|
||||
}
|
||||
}
|
||||
68
app/Http/Controllers/WebhookController.php
Normal file
68
app/Http/Controllers/WebhookController.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\StripeService;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
|
||||
|
||||
class WebhookController extends CashierController
|
||||
{
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a cancelled customer from a Stripe subscription.
|
||||
*
|
||||
* @param array $payload
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handleCustomerSubscriptionDeleted($payload)
|
||||
{
|
||||
if ($user = $this->getUserByStripeId($payload['data']['object']['customer'])) {
|
||||
$user->subscriptions->filter(function ($subscription) use ($payload) {
|
||||
return $subscription->stripe_id === $payload['data']['object']['id'];
|
||||
})->each(function ($subscription) {
|
||||
$subscription->markAsCancelled();
|
||||
});
|
||||
}
|
||||
|
||||
// Get user
|
||||
$user = User::where('stripe_id', $payload['data']['object']['customer'])->firstOrFail();
|
||||
|
||||
// Get default storage capacity
|
||||
$default_storage = Setting::where('name', 'storage_default')->first();
|
||||
|
||||
// Update storage capacity
|
||||
$user->settings()->update(['storage_capacity' => $default_storage->value]);
|
||||
|
||||
return $this->successMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Invoice Payment Succeeded
|
||||
*
|
||||
* @param $payload
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handleInvoicePaymentSucceeded($payload)
|
||||
{
|
||||
// Get user
|
||||
$user = User::where('stripe_id', $payload['data']['object']['customer'])->firstOrFail();
|
||||
|
||||
// Get requested plan
|
||||
$plan = $this->stripe->getPlan($user->subscription('main')->stripe_plan);
|
||||
|
||||
// Update user storage limit
|
||||
$user->settings()->update([
|
||||
'storage_capacity' => $plan['product']['metadata']['capacity']
|
||||
]);
|
||||
|
||||
return $this->successMethod();
|
||||
}
|
||||
}
|
||||
804
app/Http/Helpers/helpers.php
Normal file
804
app/Http/Helpers/helpers.php
Normal file
@@ -0,0 +1,804 @@
|
||||
<?php
|
||||
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\User;
|
||||
use App\Setting;
|
||||
use App\Share;
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
|
||||
/**
|
||||
* Obfuscate email
|
||||
*
|
||||
* @param $email
|
||||
* @return string
|
||||
*/
|
||||
function obfuscate_email($email)
|
||||
{
|
||||
$em = explode("@", $email);
|
||||
$name = implode('@', array_slice($em, 0, count($em) - 1));
|
||||
$len = floor(strlen($name) / 2);
|
||||
|
||||
return substr($name, 0, $len) . str_repeat('*', $len) . "@" . end($em);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single value from settings table
|
||||
*
|
||||
* @param $setting
|
||||
* @return |null
|
||||
*/
|
||||
function get_setting($setting)
|
||||
{
|
||||
$row = Setting::where('name', $setting)->first();
|
||||
|
||||
return $row ? $row->value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph from text
|
||||
*
|
||||
* @param $str
|
||||
* @return mixed|null|string|string[]
|
||||
*/
|
||||
function add_paragraphs($str)
|
||||
{
|
||||
// Trim whitespace
|
||||
if (($str = trim($str)) === '') return '';
|
||||
|
||||
// Standardize newlines
|
||||
$str = str_replace(array("\r\n", "\r"), "\n", $str);
|
||||
|
||||
// Trim whitespace on each line
|
||||
$str = preg_replace('~^[ \t]+~m', '', $str);
|
||||
$str = preg_replace('~[ \t]+$~m', '', $str);
|
||||
|
||||
// The following regexes only need to be executed if the string contains html
|
||||
if ($html_found = (strpos($str, '<') !== FALSE)) {
|
||||
// Elements that should not be surrounded by p tags
|
||||
$no_p = '(?:p|div|article|header|aside|hgroup|canvas|output|progress|section|figcaption|audio|video|nav|figure|footer|video|details|main|menu|summary|h[1-6r]|ul|ol|li|blockquote|d[dlt]|pre|t[dhr]|t(?:able|body|foot|head)|c(?:aption|olgroup)|form|s(?:elect|tyle)|a(?:ddress|rea)|ma(?:p|th))';
|
||||
|
||||
// Put at least two linebreaks before and after $no_p elements
|
||||
$str = preg_replace('~^<' . $no_p . '[^>]*+>~im', "\n$0", $str);
|
||||
$str = preg_replace('~</' . $no_p . '\s*+>$~im', "$0\n", $str);
|
||||
}
|
||||
|
||||
// Do the <p> magic!
|
||||
$str = '<p>' . trim($str) . '</p>';
|
||||
$str = preg_replace('~\n{2,}~', "</p>\n\n<p>", $str);
|
||||
|
||||
// The following regexes only need to be executed if the string contains html
|
||||
if ($html_found !== FALSE) {
|
||||
// Remove p tags around $no_p elements
|
||||
$str = preg_replace('~<p>(?=</?' . $no_p . '[^>]*+>)~i', '', $str);
|
||||
$str = preg_replace('~(</?' . $no_p . '[^>]*+>)</p>~i', '$1', $str);
|
||||
}
|
||||
|
||||
// Convert single linebreaks to <br />
|
||||
$str = preg_replace('~(?<!\n)\n(?!\n)~', "<br>\n", $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set environment value
|
||||
*
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
function setEnvironmentValue(array $values)
|
||||
{
|
||||
$envFile = app()->environmentFilePath();
|
||||
$str = file_get_contents($envFile);
|
||||
|
||||
if (count($values) > 0) {
|
||||
foreach ($values as $envKey => $envValue) {
|
||||
|
||||
$str .= "\n"; // In case the searched variable is in the last line without \n
|
||||
$keyPosition = strpos($str, "{$envKey}=");
|
||||
$endOfLinePosition = strpos($str, "\n", $keyPosition);
|
||||
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
|
||||
|
||||
// If key does not exist, add it
|
||||
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
|
||||
}
|
||||
}
|
||||
|
||||
$str = substr($str, 0, -1);
|
||||
if (!file_put_contents($envFile, $str)) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get invoice number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_invoice_number()
|
||||
{
|
||||
$invoices = \App\Invoice::all();
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
return Carbon::now()->year . '001';
|
||||
} else {
|
||||
return (int)$invoices->last()->order + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget many cache keys at once
|
||||
* @param $cache
|
||||
*/
|
||||
function cache_forget_many($cache)
|
||||
{
|
||||
foreach ($cache as $item) {
|
||||
\Illuminate\Support\Facades\Cache::forget($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app version from config
|
||||
*
|
||||
* @return \Illuminate\Config\Repository|mixed
|
||||
*/
|
||||
function get_storage()
|
||||
{
|
||||
return env('FILESYSTEM_DRIVER');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is running AWS s3 as storage
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_storage_driver($driver)
|
||||
{
|
||||
if (is_array($driver)) {
|
||||
return in_array(config('filesystems.default'), $driver);
|
||||
}
|
||||
|
||||
return config('filesystems.default') === $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app version from config
|
||||
*
|
||||
* @return \Illuminate\Config\Repository|mixed
|
||||
*/
|
||||
function get_version()
|
||||
{
|
||||
return config('vuefilemanager.version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is demo
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function is_demo($user_id)
|
||||
{
|
||||
return env('APP_DEMO', false) && $user_id === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get folder or file item
|
||||
*
|
||||
* @param $type
|
||||
* @param $unique_id
|
||||
* @param $user_id
|
||||
* @return \Illuminate\Database\Eloquent\Builder|Model
|
||||
*/
|
||||
function get_item($type, $unique_id, $user_id)
|
||||
{
|
||||
|
||||
if ($type === 'folder') {
|
||||
|
||||
// Return folder item
|
||||
return FileManagerFolder::where('unique_id', $unique_id)
|
||||
->where('user_id', $user_id)
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
// Return file item
|
||||
return FileManagerFile::where('unique_id', $unique_id)
|
||||
->where('user_id', $user_id)
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared token
|
||||
*
|
||||
* @param $token
|
||||
* @return \Illuminate\Database\Eloquent\Builder|Model
|
||||
*/
|
||||
function get_shared($token)
|
||||
{
|
||||
|
||||
return Share::where(DB::raw('BINARY `token`'), $token)
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if shared permission is editor
|
||||
*
|
||||
* @param $shared
|
||||
* @return bool
|
||||
*/
|
||||
function is_editor($shared)
|
||||
{
|
||||
|
||||
return $shared->permission === 'editor';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unique id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function get_unique_id(): int
|
||||
{
|
||||
// Get files and folders
|
||||
$folders = FileManagerFolder::withTrashed()->get();
|
||||
$files = FileManagerFile::withTrashed()->get();
|
||||
|
||||
// Get last ids
|
||||
$folders_unique = $folders->isEmpty() ? 0 : $folders->last()->unique_id;
|
||||
$files_unique = $files->isEmpty() ? 0 : $files->last()->unique_id;
|
||||
|
||||
// Count new unique id
|
||||
$unique_id = $folders_unique > $files_unique ? $folders_unique + 1 : $files_unique + 1;
|
||||
|
||||
return $unique_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store user avatar to storage
|
||||
*
|
||||
* @param $image
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
function store_avatar($image, $path)
|
||||
{
|
||||
// Get directory
|
||||
$path = check_directory($path);
|
||||
|
||||
// Store avatar
|
||||
$image_path = Str::random(8) . '-' . $image->getClientOriginalName();
|
||||
|
||||
// Create intervention image
|
||||
$img = Image::make($image->getRealPath());
|
||||
|
||||
// Generate thumbnail
|
||||
$img->fit('150', '150')->stream();
|
||||
|
||||
// Store thumbnail to disk
|
||||
Storage::put($path . '/' . $image_path, $img);
|
||||
|
||||
// Return path to image
|
||||
return $path . '/' . $image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store system image
|
||||
*
|
||||
* @param $image
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
function store_system_image($image, $path)
|
||||
{
|
||||
// Get directory
|
||||
$path = check_directory($path);
|
||||
|
||||
// Store avatar
|
||||
$image_path = Str::random(8) . '-' . str_replace(' ', '', $image->getClientOriginalName());
|
||||
|
||||
// Store image to disk
|
||||
Storage::putFileAs($path, $image, $image_path);
|
||||
|
||||
// Return path to image
|
||||
return $path . '/' . $image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directory exist, if no, then create it
|
||||
*
|
||||
* @param $directory
|
||||
* @return mixed
|
||||
*/
|
||||
function check_directory($directory)
|
||||
{
|
||||
if (!Storage::exists($directory)) {
|
||||
Storage::makeDirectory($directory);
|
||||
}
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make input from request
|
||||
*
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
function make_single_input($request)
|
||||
{
|
||||
// Create container
|
||||
$data = [];
|
||||
|
||||
// Add data to array
|
||||
$data[$request->name] = $request->value;
|
||||
|
||||
// Return input
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format integer to gigabytes
|
||||
*
|
||||
* @param $gigabytes
|
||||
* @return string
|
||||
*/
|
||||
function format_gigabytes($gigabytes)
|
||||
{
|
||||
if ($gigabytes >= 1000) {
|
||||
return Metric::gigabytes($gigabytes)->format('Tb/');
|
||||
} else {
|
||||
return Metric::gigabytes($gigabytes)->format('GB/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format string to formated megabytes string
|
||||
*
|
||||
* @param $megabytes
|
||||
* @return string
|
||||
*/
|
||||
function format_megabytes($megabytes)
|
||||
{
|
||||
if ($megabytes >= 1000) {
|
||||
return $megabytes / 1000 . 'GB';
|
||||
}
|
||||
|
||||
if ($megabytes >= 1000000) {
|
||||
return $megabytes / 1000000 . 'TB';
|
||||
}
|
||||
|
||||
return $megabytes . 'MB';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert megabytes to bytes
|
||||
*
|
||||
* @param $megabytes
|
||||
* @return int|string
|
||||
*/
|
||||
function format_bytes($megabytes)
|
||||
{
|
||||
return Metric::megabytes($megabytes)->numberOfBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage usage in percent
|
||||
*
|
||||
* @param $used
|
||||
* @param $capacity
|
||||
* @return string
|
||||
*/
|
||||
function get_storage_fill_percentage($used, $capacity)
|
||||
{
|
||||
// Format gigabytes to bytes
|
||||
$total = intval(Metric::gigabytes($capacity)->numberOfBytes());
|
||||
|
||||
// Count progress
|
||||
$progress = ($used * 100) / $total;
|
||||
|
||||
// Return in 2 decimal
|
||||
return number_format((float)$progress, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user capacity fill by percentage
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_storage_percentage($id, $additionals = null)
|
||||
{
|
||||
$user = \App\User::findOrFail($id);
|
||||
|
||||
$used = $user->used_capacity;
|
||||
|
||||
if ($additionals) {
|
||||
$used = $user->used_capacity + $additionals;
|
||||
}
|
||||
|
||||
return get_storage_fill_percentage($used, $user->settings->storage_capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all key values in recursive array
|
||||
*
|
||||
* @param array $array
|
||||
* @param $needle
|
||||
* @return array
|
||||
*/
|
||||
function recursiveFind(array $array, $needle)
|
||||
{
|
||||
$iterator = new RecursiveArrayIterator($array);
|
||||
$recursive = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||
$aHitList = array();
|
||||
foreach ($recursive as $key => $value) {
|
||||
if ($key === $needle) {
|
||||
array_push($aHitList, $value);
|
||||
}
|
||||
}
|
||||
return $aHitList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values which appears only once in array
|
||||
* @param $arr
|
||||
* @return array
|
||||
*/
|
||||
function appeared_once($arr)
|
||||
{
|
||||
$array_count_values = array_count_values($arr);
|
||||
|
||||
$single_time_comming_values_array = [];
|
||||
|
||||
foreach ($array_count_values as $key => $val) {
|
||||
|
||||
if ($val == 1) {
|
||||
$single_time_comming_values_array[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $single_time_comming_values_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $folders
|
||||
* @return array
|
||||
*/
|
||||
function filter_folders_ids($folders, $by_column = 'unique_id')
|
||||
{
|
||||
$folder_unique_ids = recursiveFind($folders->toArray(), $by_column);
|
||||
|
||||
return appeared_once($folder_unique_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format localized date
|
||||
*
|
||||
* @param $date
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
function format_date($date, $format = '%d. %B. %Y, %H:%M')
|
||||
{
|
||||
$start = Carbon::parse($date);
|
||||
|
||||
return $start->formatLocalized($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file type from mimetype
|
||||
*
|
||||
* @param $file
|
||||
* @return string
|
||||
*/
|
||||
function get_file_type($file_mimetype)
|
||||
{
|
||||
// Get mimetype from file
|
||||
$mimetype = explode('/', $file_mimetype);
|
||||
|
||||
switch ($mimetype[0]) {
|
||||
case 'image':
|
||||
return 'image';
|
||||
break;
|
||||
case 'video':
|
||||
return 'video';
|
||||
break;
|
||||
case 'audio':
|
||||
return 'audio';
|
||||
break;
|
||||
default:
|
||||
return 'file';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get file type from mimetype
|
||||
*
|
||||
* @param $mimetype
|
||||
* @return mixed
|
||||
*/
|
||||
function get_file_type_from_mimetype($mimetype)
|
||||
{
|
||||
return explode('/', $mimetype)[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format pretty name file
|
||||
*
|
||||
* @param $basename
|
||||
* @param $name
|
||||
* @param $mimetype
|
||||
* @return string
|
||||
*/
|
||||
function get_pretty_name($basename, $name, $mimetype)
|
||||
{
|
||||
$file_extension = substr(strrchr($basename, '.'), 1);
|
||||
|
||||
if (strpos($name, $file_extension) !== false) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if ($file_extension) {
|
||||
return $name . '.' . $file_extension;
|
||||
}
|
||||
|
||||
return $name . '.' . $mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exif data from jpeg image
|
||||
*
|
||||
* @param $file
|
||||
* @return array
|
||||
*/
|
||||
function get_image_meta_data($file)
|
||||
{
|
||||
if (get_file_type_from_mimetype($file->getMimeType()) === 'jpeg') {
|
||||
|
||||
try {
|
||||
|
||||
// Try to get the exif data
|
||||
return mb_convert_encoding(Image::make($file->getRealPath())->exif(),'UTF8', 'UTF8');
|
||||
|
||||
} catch ( \Exception $e) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if app is in dev mode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_dev()
|
||||
{
|
||||
return env('APP_ENV') === 'local' ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @return bool
|
||||
*/
|
||||
function seems_utf8($str)
|
||||
{
|
||||
$length = strlen($str);
|
||||
for ($i=0; $i < $length; $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if ($c < 0x80) $n = 0; # 0bbbbbbb
|
||||
elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb
|
||||
elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb
|
||||
elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb
|
||||
elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb
|
||||
elseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b
|
||||
else return false; # Does not match any model
|
||||
for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
|
||||
if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all accent characters to ASCII characters.
|
||||
*
|
||||
* If there are no accent characters, then the string given is just returned.
|
||||
*
|
||||
* @param string $string Text that might have accent characters
|
||||
* @return string Filtered string with replaced "nice" characters.
|
||||
*/
|
||||
function remove_accents($string) {
|
||||
if ( !preg_match('/[\x80-\xff]/', $string) )
|
||||
return $string;
|
||||
|
||||
if (seems_utf8($string)) {
|
||||
$chars = array(
|
||||
// Decompositions for Latin-1 Supplement
|
||||
chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
|
||||
chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
|
||||
chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
|
||||
chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
|
||||
chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
|
||||
chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
|
||||
chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
|
||||
chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
|
||||
chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
|
||||
chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
|
||||
chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
|
||||
chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
|
||||
chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
|
||||
chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
|
||||
chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
|
||||
chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
|
||||
chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
|
||||
chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
|
||||
chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
|
||||
chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
|
||||
chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
|
||||
chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
|
||||
chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
|
||||
chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
|
||||
chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
|
||||
chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
|
||||
chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
|
||||
chr(195).chr(191) => 'y',
|
||||
// Decompositions for Latin Extended-A
|
||||
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
|
||||
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
|
||||
chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
|
||||
chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
|
||||
chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
|
||||
chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
|
||||
chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
|
||||
chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
|
||||
chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
|
||||
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
|
||||
chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
|
||||
chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
|
||||
chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
|
||||
chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
|
||||
chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
|
||||
chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
|
||||
chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
|
||||
chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
|
||||
chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
|
||||
chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
|
||||
chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
|
||||
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
|
||||
chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
|
||||
chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
|
||||
chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
|
||||
chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
|
||||
chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
|
||||
chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
|
||||
chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
|
||||
chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
|
||||
chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
|
||||
chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
|
||||
chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
|
||||
chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
|
||||
chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
|
||||
chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
|
||||
chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
|
||||
chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
|
||||
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
|
||||
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
|
||||
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
|
||||
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
|
||||
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
|
||||
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
|
||||
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
|
||||
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
|
||||
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
|
||||
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
|
||||
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
|
||||
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
|
||||
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
|
||||
chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
|
||||
chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
|
||||
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
|
||||
chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
|
||||
chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
|
||||
chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
|
||||
chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
|
||||
chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
|
||||
chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
|
||||
chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
|
||||
chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
|
||||
chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
|
||||
chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
|
||||
// Euro Sign
|
||||
chr(226).chr(130).chr(172) => 'E',
|
||||
// GBP (Pound) Sign
|
||||
chr(194).chr(163) => '');
|
||||
|
||||
$string = strtr($string, $chars);
|
||||
} else {
|
||||
// Assume ISO-8859-1 if not UTF-8
|
||||
$chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
|
||||
.chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
|
||||
.chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
|
||||
.chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
|
||||
.chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
|
||||
.chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
|
||||
.chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
|
||||
.chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
|
||||
.chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
|
||||
.chr(252).chr(253).chr(255);
|
||||
|
||||
$chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
|
||||
|
||||
$string = strtr($string, $chars['in'], $chars['out']);
|
||||
$double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
|
||||
$double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
|
||||
$string = str_replace($double_chars['in'], $double_chars['out'], $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
/**
|
||||
* Get all files from folder and get their folder location in VueFileManager directories
|
||||
*
|
||||
* @param $folders
|
||||
* @param null $files
|
||||
* @param array $path
|
||||
* @return array
|
||||
*/
|
||||
function get_files_for_zip($folders, $files, $path = [])
|
||||
{
|
||||
// Return file list
|
||||
if (!isset($folders->folders)) {
|
||||
return $files->unique()->values()->all();
|
||||
}
|
||||
|
||||
// Push file path
|
||||
array_push($path, $folders->name);
|
||||
|
||||
// Push file to collection
|
||||
$folders->files->each(function ($file) use ($files, $path) {
|
||||
$files->push([
|
||||
'name' => $file->name,
|
||||
'basename' => $file->basename,
|
||||
'folder_path' => implode('/', $path),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get all children folders and folders within
|
||||
if ($folders->folders->isNotEmpty()) {
|
||||
$folders->folders->map(function ($folder) use ($files, $path) {
|
||||
return get_files_for_zip($folder, $files, $path);
|
||||
});
|
||||
}
|
||||
|
||||
return get_files_for_zip($folders->folders->first(), $files, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set time by user timezone GMT
|
||||
*
|
||||
* @param $time
|
||||
* @return int
|
||||
*/
|
||||
function set_time_by_user_timezone($time)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if($user) {
|
||||
|
||||
// Get the value of timezone if user have some
|
||||
$time_zone = intval($user->settings->timezone * 60 ?? null);
|
||||
|
||||
return Carbon::parse($time)->addMinutes($time_zone ?? null);
|
||||
}
|
||||
|
||||
return Carbon::parse($time);
|
||||
|
||||
}
|
||||
23
app/Http/Helpers/subscription.php
Normal file
23
app/Http/Helpers/subscription.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check if current user subscribed plan is highest
|
||||
*
|
||||
* @param $id
|
||||
* @param $subscribed_capacity
|
||||
* @return int
|
||||
*/
|
||||
function is_highest_plan($plan)
|
||||
{
|
||||
$plans = app('rinvex.subscriptions.plan')->all();
|
||||
|
||||
$unsubscribed = $plans->filter(function ($item) use ($plan) {
|
||||
return $item->id !== $plan->id;
|
||||
});
|
||||
|
||||
$capacities = $unsubscribed->map(function ($item) {
|
||||
return $item->features->first()->value;
|
||||
});
|
||||
|
||||
return max(Arr::flatten($capacities)) < $plan->features->first()->value ? 1 : 0;
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\AdminCheck;
|
||||
use App\Http\Middleware\CookieAuth;
|
||||
use App\Http\Middleware\LastCheck;
|
||||
use App\Http\Middleware\SharedAuth;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
@@ -40,6 +43,7 @@ class Kernel extends HttpKernel
|
||||
],
|
||||
|
||||
'api' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
//'throttle:60,1',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
@@ -53,6 +57,9 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth.master' => CookieAuth::class,
|
||||
'auth.shared' => SharedAuth::class,
|
||||
'auth.admin' => AdminCheck::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
@@ -63,7 +70,8 @@ class Kernel extends HttpKernel
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'auth.cookie' => CookieAuth::class,
|
||||
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
|
||||
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -77,6 +85,7 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
CookieAuth::class,
|
||||
SharedAuth::class,
|
||||
\App\Http\Middleware\Authenticate::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
|
||||
40
app/Http/Mail/SendSupportForm.php
Normal file
40
app/Http/Mail/SendSupportForm.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendSupportForm extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$from = config('mail.from')['address'];
|
||||
|
||||
return $this->from($from)
|
||||
->replyTo($this->request['email'])
|
||||
->subject('New Contact Message from ' . $this->request['email'])
|
||||
->view('mails.contact-message')
|
||||
->with('request', $this->request);
|
||||
}
|
||||
}
|
||||
26
app/Http/Middleware/AdminCheck.php
Normal file
26
app/Http/Middleware/AdminCheck.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AdminCheck
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// Check if user have access to administration settings
|
||||
if ( ! Gate::allows('admin-settings')) {
|
||||
abort(403, 'You don\'t have access for this operation!');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ class CheckForMaintenanceMode extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'/service/upgrade-database',
|
||||
'/service/down',
|
||||
'/service/up',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CookieAuth
|
||||
{
|
||||
@@ -16,14 +17,12 @@ class CookieAuth
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->bearerToken()) {
|
||||
if ($request->hasCookie('token')) {
|
||||
if ($request->hasCookie('access_token')) {
|
||||
|
||||
$token = $request->cookie('token');
|
||||
$access_token = $request->cookie('access_token');
|
||||
|
||||
$request->headers->add(['Authorization' => 'Bearer ' . $token]);
|
||||
$request->headers->add(['Authorization' => 'Bearer ' . $access_token]);
|
||||
|
||||
} else {
|
||||
abort(401);
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
|
||||
29
app/Http/Middleware/SharedAuth.php
Normal file
29
app/Http/Middleware/SharedAuth.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class SharedAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->bearerToken()) {
|
||||
if ($request->hasCookie('shared_access_token')) {
|
||||
|
||||
$shared_access_token = $request->cookie('shared_access_token');
|
||||
|
||||
$request->headers->add(['Authorization' => 'Bearer ' . $shared_access_token]);
|
||||
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class VerifyCsrfToken extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'/deploy',
|
||||
'/stripe/*',
|
||||
];
|
||||
}
|
||||
|
||||
68
app/Http/Notifications/ConfirmPayment.php
Normal file
68
app/Http/Notifications/ConfirmPayment.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Laravel\Cashier\Payment;
|
||||
|
||||
class ConfirmPayment extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The PaymentIntent identifier.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $paymentId;
|
||||
|
||||
/**
|
||||
* The payment amount.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* Create a new payment confirmation notification.
|
||||
*
|
||||
* @param \Laravel\Cashier\Payment $payment
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Payment $payment)
|
||||
{
|
||||
$this->paymentId = $payment->id;
|
||||
$this->amount = $payment->amount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$url = route('cashier.payment', ['id' => $this->paymentId]);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('cashier.confirm_payment'))
|
||||
->greeting(__('cashier.confirm_amount', ['amount' => $this->amount]))
|
||||
->line(__('cashier.confirm_description'))
|
||||
->action(__('cashier.confirm_button'), $url);
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Admin/ChangeRoleRequest.php
Normal file
31
app/Http/Requests/Admin/ChangeRoleRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ChangeRoleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'attributes' => 'required|array',
|
||||
'attributes.role' => 'required|string'
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Admin/ChangeStorageCapacityRequest.php
Normal file
31
app/Http/Requests/Admin/ChangeStorageCapacityRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ChangeStorageCapacityRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'attributes' => 'required|array',
|
||||
'attributes.storage_capacity' => 'required|digits_between:1,9'
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/Admin/CreateUserByAdmin.php
Normal file
35
app/Http/Requests/Admin/CreateUserByAdmin.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateUserByAdmin extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'name' => 'required|string|max:255',
|
||||
'storage_capacity' => 'required|digits_between:1,9',
|
||||
'role' => 'required|string',
|
||||
'avatar' => 'sometimes|file',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Admin/DeleteUserRequest.php
Normal file
30
app/Http/Requests/Admin/DeleteUserRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DeleteUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'data.name' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Auth/CheckAccountRequest.php
Normal file
30
app/Http/Requests/Auth/CheckAccountRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CheckAccountRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required|string|email',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/FileBrowser/SearchRequest.php
Normal file
30
app/Http/Requests/FileBrowser/SearchRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileBrowser;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SearchRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'query' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/FileFunctions/CreateFolderRequest.php
Normal file
32
app/Http/Requests/FileFunctions/CreateFolderRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CreateFolderRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'parent_id' => 'required|integer',
|
||||
'name' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/FileFunctions/DeleteItemRequest.php
Normal file
33
app/Http/Requests/FileFunctions/DeleteItemRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class DeleteItemRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'data[*].force_delete' => 'required|boolean',
|
||||
'data[*].type' => 'required|string',
|
||||
'data[*].unique_id' => 'required|integer'
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/FileFunctions/MoveItemRequest.php
Normal file
33
app/Http/Requests/FileFunctions/MoveItemRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MoveItemRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'to_unique_id' => 'required|integer',
|
||||
'items[*].type' => 'required|string',
|
||||
'items[*].unique_id' => 'required|integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/FileFunctions/RenameItemRequest.php
Normal file
32
app/Http/Requests/FileFunctions/RenameItemRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RenameItemRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'type' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/FileFunctions/UploadRequest.php
Normal file
33
app/Http/Requests/FileFunctions/UploadRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use App\Rules\MimetypeBlacklistValidation;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UploadRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'parent_id' => 'required|integer',
|
||||
'file' => ['required','file' , new MimetypeBlacklistValidation]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Payments;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RegisterNewPaymentMethodRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'token' => 'required|string',
|
||||
'default' => 'required|boolean'
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/PublicPages/SendMessageRequest.php
Normal file
31
app/Http/Requests/PublicPages/SendMessageRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PublicPages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SendMessageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required|email',
|
||||
'message' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/SetupWizard/StoreAppSetupRequest.php
Normal file
38
app/Http/Requests/SetupWizard/StoreAppSetupRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreAppSetupRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string',
|
||||
'description' => 'required|string',
|
||||
'logo' => 'sometimes|file',
|
||||
'favicon' => 'sometimes|file',
|
||||
'contactMail' => 'required|email',
|
||||
'googleAnalytics' => 'sometimes|string',
|
||||
'defaultStorage' => 'sometimes|digits_between:1,9',
|
||||
'userRegistration' => 'required|boolean',
|
||||
'storageLimitation' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreDatabaseCredentialsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'connection' => 'required|string',
|
||||
'host' => 'required|string',
|
||||
'port' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
'username' => 'required|string',
|
||||
'password' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreEnvironmentSetupRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'storage' => 'required|array',
|
||||
'storage.driver' => 'required|string',
|
||||
'storage.key' => 'sometimes|nullable|string',
|
||||
'storage.secret' => 'sometimes|nullable|string',
|
||||
'storage.endpoint' => 'sometimes|nullable|string',
|
||||
'storage.region' => 'sometimes|nullable|string',
|
||||
'storage.bucket' => 'sometimes|nullable|string',
|
||||
'mail' => 'required|array',
|
||||
'mail.driver' => 'required|string',
|
||||
'mail.host' => 'required|string',
|
||||
'mail.port' => 'required|string',
|
||||
'mail.username' => 'required|string',
|
||||
'mail.password' => 'required|string',
|
||||
'mail.encryption' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/SetupWizard/StoreStripeBillingRequest.php
Normal file
37
app/Http/Requests/SetupWizard/StoreStripeBillingRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripeBillingRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'billing_phone_number' => 'sometimes|nullable|string',
|
||||
'billing_postal_code' => 'required|string',
|
||||
'billing_vat_number' => 'required|string',
|
||||
'billing_address' => 'required|string',
|
||||
'billing_country' => 'required|string',
|
||||
'billing_state' => 'required|string',
|
||||
'billing_city' => 'required|string',
|
||||
'billing_name' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripeCredentialsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'currency' => 'required|string',
|
||||
'webhookSecret' => 'required|string',
|
||||
'secret' => 'required|string',
|
||||
'key' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/SetupWizard/StoreStripePlansRequest.php
Normal file
35
app/Http/Requests/SetupWizard/StoreStripePlansRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\SetupWizard;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripePlansRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'plans' => 'required|array',
|
||||
'plans.*.type' => 'required|string',
|
||||
'plans.*.attributes.name' => 'required|string',
|
||||
'plans.*.attributes.price' => 'required|string',
|
||||
'plans.*.attributes.description' => 'sometimes|nullable|string',
|
||||
'plans.*.attributes.capacity' => 'required|digits_between:1,9',
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/Http/Requests/Share/AuthenticateShareRequest.php
Normal file
20
app/Http/Requests/Share/AuthenticateShareRequest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Share;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AuthenticateShareRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'password' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/Share/CreateShareRequest.php
Normal file
37
app/Http/Requests/Share/CreateShareRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Share;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CreateShareRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'isPassword' => 'required|boolean',
|
||||
'unique_id' => 'required|integer',
|
||||
'type' => 'required|string',
|
||||
'expiration' => 'integer|nullable',
|
||||
'permission' => 'string',
|
||||
'password' => 'string',
|
||||
'emails.*' => 'email'
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Requests/Share/UpdateShareRequest.php
Normal file
34
app/Http/Requests/Share/UpdateShareRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Share;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UpdateShareRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'protected' => 'required|boolean',
|
||||
'permission' => 'nullable|string',
|
||||
'expiration' => 'integer|nullable',
|
||||
'password' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Subscription;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreUpgradeAccountRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// Billings
|
||||
'billing' => 'required|array',
|
||||
'billing.billing_address' => 'required|string',
|
||||
'billing.billing_city' => 'required|string',
|
||||
'billing.billing_country' => 'required|string',
|
||||
'billing.billing_name' => 'required|string',
|
||||
'billing.billing_phone_number' => 'required|string',
|
||||
'billing.billing_postal_code' => 'required|string',
|
||||
'billing.billing_state' => 'required|string',
|
||||
|
||||
// Payment
|
||||
'payment' => 'required|array',
|
||||
'payment.type' => 'required|string',
|
||||
'payment.meta' => 'required|sometimes|array',
|
||||
'payment.meta.pm' => 'required|sometimes|string',
|
||||
|
||||
// Plan
|
||||
'plan.data' => 'required|array',
|
||||
'plan.data.attributes' => 'required|array',
|
||||
'plan.data.attributes.capacity' => 'required|digits_between:1,9',
|
||||
'plan.data.attributes.capacity_formatted' => 'required|string',
|
||||
'plan.data.attributes.currency' => 'required|string',
|
||||
'plan.data.attributes.description' => 'sometimes|string|nullable',
|
||||
'plan.data.attributes.name' => 'required|string',
|
||||
'plan.data.attributes.price' => 'required|string',
|
||||
'plan.data.id' => 'required|string',
|
||||
'plan.data.type' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/GatewayCollection.php
Normal file
23
app/Http/Resources/GatewayCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class GatewayCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = GatewayResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/GatewayResource.php
Normal file
36
app/Http/Resources/GatewayResource.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class GatewayResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'gateways',
|
||||
'attributes' => [
|
||||
'status' => $this->status,
|
||||
'sandbox' => $this->sandbox,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'logo' => $this->logo,
|
||||
'client_id' => $this->client_id,
|
||||
'secret' => $this->secret,
|
||||
'webhook' => $this->webhook,
|
||||
'payment_processed' => $this->payment_processed,
|
||||
'optional' => $this->optional,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/InvoiceAdminCollection.php
Normal file
23
app/Http/Resources/InvoiceAdminCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class InvoiceAdminCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = InvoiceAdminResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
65
app/Http/Resources/InvoiceAdminResource.php
Normal file
65
app/Http/Resources/InvoiceAdminResource.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Laravel\Cashier\Cashier;
|
||||
|
||||
class InvoiceAdminResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$user = User::where('stripe_id', $this['customer'])->first();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this['id'],
|
||||
'type' => 'invoices',
|
||||
'attributes' => [
|
||||
'customer' => $this['customer'],
|
||||
'total' => Cashier::formatAmount($this['total']),
|
||||
'currency' => $this['currency'],
|
||||
'created_at_formatted' => format_date($this['created']),
|
||||
'created_at' => $this['created'],
|
||||
'order' => $this['number'],
|
||||
'user_id' => $user ? $user->id : null,
|
||||
'client' => [
|
||||
'billing_address' => $this['customer_address'],
|
||||
'billing_name' => $this['customer_name'],
|
||||
'billing_phone_number' => $this['customer_phone'],
|
||||
],
|
||||
'bag' => [
|
||||
'amount' => $this['lines']['data'][0]['amount'],
|
||||
'currency' => $this['lines']['data'][0]['currency'],
|
||||
'type' => $this['lines']['data'][0]['type'],
|
||||
'description' => $this['lines']['data'][0]['description'],
|
||||
],
|
||||
'seller' => null,
|
||||
]
|
||||
],
|
||||
$this->mergeWhen($user, function () use ($user) {
|
||||
return [
|
||||
'relationships' => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'id' => (string)$user->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/InvoiceCollection.php
Normal file
23
app/Http/Resources/InvoiceCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class InvoiceCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = InvoiceResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
80
app/Http/Resources/InvoiceResource.php
Normal file
80
app/Http/Resources/InvoiceResource.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$user = User::where('stripe_id', $this->customer)->first();
|
||||
$invoice_items = [];
|
||||
$invoice_subscriptions = [];
|
||||
|
||||
// Format bag
|
||||
foreach ($this->invoiceItems() as $item) {
|
||||
array_push($invoice_items, [
|
||||
'amount' => $item->total(),
|
||||
'description' => $item->description,
|
||||
'currency' => $item->currency,
|
||||
'type' => $item->type,
|
||||
]);
|
||||
}
|
||||
|
||||
// Format bag
|
||||
foreach ($this->subscriptions() as $item) {
|
||||
array_push($invoice_subscriptions, [
|
||||
'amount' => $item->total(),
|
||||
'description' => $item->description,
|
||||
'currency' => $item->currency,
|
||||
'type' => $item->type,
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => 'invoices',
|
||||
'attributes' => [
|
||||
'customer' => $this->customer,
|
||||
'total' => $this->total(),
|
||||
'currency' => $this->currency,
|
||||
'created_at_formatted' => format_date($this->date(), '%d. %B. %Y'),
|
||||
'created_at' => $this->created,
|
||||
'order' => $this->number,
|
||||
'user_id' => $user ? $user->id : null,
|
||||
'client' => [
|
||||
'billing_address' => $this->customer_address,
|
||||
'billing_name' => $this->customer_name,
|
||||
'billing_phone_number' => $this->customer_phone,
|
||||
],
|
||||
'seller' => null,
|
||||
'invoice_items' => $invoice_items,
|
||||
'invoice_subscriptions' => $invoice_subscriptions,
|
||||
]
|
||||
],
|
||||
$this->mergeWhen($user, [
|
||||
'relationships' => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'id' => (string)$user->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/PageCollection.php
Normal file
23
app/Http/Resources/PageCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PageCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = PageResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/PageResource.php
Normal file
31
app/Http/Resources/PageResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => 'pages',
|
||||
'attributes' => [
|
||||
'visibility' => $this->visibility,
|
||||
'title' => $this->title,
|
||||
'slug' => $this->slug,
|
||||
'content' => $this->content,
|
||||
'content_formatted' => add_paragraphs($this->content),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/PaymentCardCollection.php
Normal file
23
app/Http/Resources/PaymentCardCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PaymentCardCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = PaymentCardResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/PaymentCardResource.php
Normal file
35
app/Http/Resources/PaymentCardResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PaymentCardResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this['id'],
|
||||
'type' => 'payment_method',
|
||||
'attributes' => [
|
||||
'provider' => 'stripe',
|
||||
'card_id' => $this['id'],
|
||||
'brand' => strtolower($this['card']['brand']),
|
||||
'last4' => $this['card']['last4'],
|
||||
'exp_month' => $this['card']['exp_month'],
|
||||
'exp_year' => $this['card']['exp_year'],
|
||||
'created_at' => format_date($this['created_at'], '%d. %B. %Y'),
|
||||
'status' => 'active',
|
||||
'default' => 0,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/PaymentDefaultCardResource.php
Normal file
35
app/Http/Resources/PaymentDefaultCardResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PaymentDefaultCardResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this['id'],
|
||||
'type' => 'payment_method',
|
||||
'attributes' => [
|
||||
'provider' => 'stripe',
|
||||
'card_id' => $this['id'],
|
||||
'brand' => isset($this['brand']) ? strtolower($this['brand']) : strtolower($this['card']['brand']),
|
||||
'last4' => isset($this['last4']) ? $this['last4'] : $this['card']['last4'],
|
||||
'exp_month' => isset($this['exp_month']) ? $this['exp_month'] : $this['card']['exp_month'],
|
||||
'exp_year' => isset($this['exp_year']) ? $this['exp_year'] : $this['card']['exp_year'],
|
||||
'created_at' => format_date($this['created_at'], '%d. %B. %Y'),
|
||||
'status' => 'active',
|
||||
'default' => 0,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/PlanCollection.php
Normal file
23
app/Http/Resources/PlanCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PlanCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = PlanResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
41
app/Http/Resources/PlanResource.php
Normal file
41
app/Http/Resources/PlanResource.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Laravel\Cashier\Cashier;
|
||||
use Laravel\Cashier\Subscription;
|
||||
|
||||
class PlanResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// Get subscribers
|
||||
$subscriber_count = Subscription::where('stripe_plan', $this['plan']['id'])->where('stripe_status', 'active')->get();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this['plan']['id'],
|
||||
'type' => 'plans',
|
||||
'attributes' => [
|
||||
'subscribers' => $subscriber_count->count(),
|
||||
'status' => $this['plan']['active'] ? 1 : 0,
|
||||
'name' => $this['product']['name'],
|
||||
'description' => $this['product']['description'],
|
||||
'price' => $this['plan']['amount'],
|
||||
'price_formatted' => Cashier::formatAmount($this['plan']['amount']),
|
||||
'capacity_formatted' => format_gigabytes($this['product']['metadata']['capacity']),
|
||||
'capacity' => (int) $this['product']['metadata']['capacity'],
|
||||
'created_at_formatted' => format_date($this['plan']['created']),
|
||||
'created_at' => $this['plan']['created'],
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/PricingCollection.php
Normal file
23
app/Http/Resources/PricingCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PricingCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = PricingResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
68
app/Http/Resources/PricingResource.php
Normal file
68
app/Http/Resources/PricingResource.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Laravel\Cashier\Cashier;
|
||||
|
||||
class PricingResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this['plan']['id'],
|
||||
'type' => 'plans',
|
||||
'attributes' => [
|
||||
'name' => $this['product']['name'],
|
||||
'description' => $this['product']['description'],
|
||||
'price' => Cashier::formatAmount($this['plan']['amount']),
|
||||
'capacity_formatted' => format_gigabytes($this['product']['metadata']['capacity']),
|
||||
'capacity' => (int)$this['product']['metadata']['capacity'],
|
||||
'currency' => config('cashier.currency'),
|
||||
'tax_rates' => $this->get_tax_rates(),
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plan tax rates
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_tax_rates(): array
|
||||
{
|
||||
$stripe = resolve('App\Services\StripeService');
|
||||
|
||||
$rates_puplic = [];
|
||||
|
||||
// Get tax rates
|
||||
$rates = $stripe->getTaxRates();
|
||||
|
||||
foreach ($rates as $rate) {
|
||||
|
||||
// Continue when is not active
|
||||
if (!$rate['active']) continue;
|
||||
|
||||
// Calculate tax
|
||||
$tax = $this['plan']['amount'] * ($rate['percentage'] / 100);
|
||||
|
||||
array_push($rates_puplic, [
|
||||
'id' => $rate['id'],
|
||||
'active' => $rate['active'],
|
||||
'jurisdiction' => $rate['jurisdiction'],
|
||||
'percentage' => $rate['percentage'],
|
||||
'plan_price_formatted' => Cashier::formatAmount(round($this['plan']['amount'] + $tax)),
|
||||
]);
|
||||
}
|
||||
|
||||
return $rates_puplic;
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/ShareResource.php
Normal file
35
app/Http/Resources/ShareResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ShareResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'shares',
|
||||
'attributes' => [
|
||||
'permission' => $this->permission,
|
||||
'protected' => (int) $this->protected,
|
||||
'item_id' => (int) $this->item_id,
|
||||
'expire_in' => (int) $this->expire_in,
|
||||
'token' => $this->token,
|
||||
'link' => $this->link,
|
||||
'type' => $this->type,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
92
app/Http/Resources/UserResource.php
Normal file
92
app/Http/Resources/UserResource.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Services\StripeService;
|
||||
use App\User;
|
||||
use Cartalyst\Stripe\Api\PaymentMethods;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'storage_capacity' => $this->settings->storage_capacity,
|
||||
'subscription' => $this->subscribed('main'),
|
||||
'incomplete_payment' => $this->hasIncompletePayment('main') ? route('cashier.payment', $this->subscription('main')->latestPayment()->id) : null,
|
||||
'stripe_customer' => is_null($this->stripe_id) ? false : true,
|
||||
'name' => $this->name,
|
||||
'email' => env('APP_DEMO') ? obfuscate_email($this->email) : $this->email,
|
||||
'avatar' => $this->avatar,
|
||||
'role' => $this->role,
|
||||
'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'),
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]
|
||||
],
|
||||
'relationships' => [
|
||||
'settings' => [
|
||||
'data' => [
|
||||
'id' => (string)$this->settings->id,
|
||||
'type' => 'settings',
|
||||
'attributes' => [
|
||||
'billing_name' => $this->settings->billing_name,
|
||||
'billing_address' => $this->settings->billing_address,
|
||||
'billing_state' => $this->settings->billing_state,
|
||||
'billing_city' => $this->settings->billing_city,
|
||||
'billing_postal_code' => $this->settings->billing_postal_code,
|
||||
'billing_country' => $this->settings->billing_country,
|
||||
'billing_phone_number' => $this->settings->billing_phone_number,
|
||||
]
|
||||
]
|
||||
],
|
||||
'storage' => [
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'type' => 'storage',
|
||||
'attributes' => $this->storage
|
||||
]
|
||||
],
|
||||
'favourites' => [
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'type' => 'folders_favourite',
|
||||
'attributes' => [
|
||||
'folders' => $this->favourite_folders->makeHidden(['pivot'])
|
||||
],
|
||||
],
|
||||
],
|
||||
'tree' => [
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'type' => 'folders_tree',
|
||||
'attributes' => [
|
||||
'folders' => $this->folder_tree
|
||||
],
|
||||
],
|
||||
],
|
||||
'timezone' => [
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'type' => 'timezone',
|
||||
'attributes' => [
|
||||
'timezone' =>$this->settings->timezone
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
89
app/Http/Resources/UserStorageResource.php
Normal file
89
app/Http/Resources/UserStorageResource.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\FileManagerFile;
|
||||
use ByteUnits\Metric;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserStorageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$document_mimetypes = [
|
||||
'pdf', 'numbers', 'xlsx', 'xls', 'txt', 'md', 'rtf', 'pptx', 'ppt', 'odt', 'ods', 'odp', 'epub', 'docx', 'doc', 'csv', 'pages'
|
||||
];
|
||||
|
||||
// Get all images
|
||||
$images = FileManagerFile::where('user_id', $this->id)
|
||||
->where('type', 'image')->get()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
// Get all audios
|
||||
$audios = FileManagerFile::where('user_id', $this->id)
|
||||
->where('type', 'audio')->get()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
// Get all videos
|
||||
$videos = FileManagerFile::where('user_id', $this->id)
|
||||
->where('type', 'video')->get()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
// Get all documents
|
||||
$documents = FileManagerFile::where('user_id', $this->id)
|
||||
->whereIn('mimetype', $document_mimetypes)->get()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
// Get all other files
|
||||
$others = FileManagerFile::where('user_id', $this->id)
|
||||
->whereNotIn('mimetype', $document_mimetypes)
|
||||
->whereNotIn('type', ['audio', 'video', 'image'])
|
||||
->get()->map(function ($item) {
|
||||
return (int)$item->getRawOriginal('filesize');
|
||||
})->sum();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'storage',
|
||||
'attributes' => [
|
||||
'used' => Metric::bytes($this->used_capacity)->format(),
|
||||
'capacity' => format_gigabytes($this->settings->storage_capacity),
|
||||
'percentage' => (float)get_storage_fill_percentage($this->used_capacity, $this->settings->storage_capacity),
|
||||
],
|
||||
'meta' => [
|
||||
'images' => [
|
||||
'used' => Metric::bytes($images)->format(),
|
||||
'percentage' => (float)get_storage_fill_percentage($images, $this->settings->storage_capacity),
|
||||
],
|
||||
'audios' => [
|
||||
'used' => Metric::bytes($audios)->format(),
|
||||
'percentage' => (float)get_storage_fill_percentage($audios, $this->settings->storage_capacity),
|
||||
],
|
||||
'videos' => [
|
||||
'used' => Metric::bytes($videos)->format(),
|
||||
'percentage' => (float)get_storage_fill_percentage($videos, $this->settings->storage_capacity),
|
||||
],
|
||||
'documents' => [
|
||||
'used' => Metric::bytes($documents)->format(),
|
||||
'percentage' => (float)get_storage_fill_percentage($documents, $this->settings->storage_capacity),
|
||||
],
|
||||
'others' => [
|
||||
'used' => Metric::bytes($others)->format(),
|
||||
'percentage' => (float)get_storage_fill_percentage($others, $this->settings->storage_capacity),
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
48
app/Http/Resources/UserSubscription.php
Normal file
48
app/Http/Resources/UserSubscription.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserSubscription extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$stripe = resolve('App\Services\StripeService');
|
||||
|
||||
$active_subscription = $this->subscription('main')->asStripeSubscription();
|
||||
|
||||
// Get subscription details
|
||||
$subscription = $stripe->getPlan($this->subscription('main')->stripe_plan);
|
||||
|
||||
// Retrieve the timestamp from Stripe
|
||||
$current_period_end = $active_subscription["current_period_end"];
|
||||
$current_period_start = $active_subscription["current_period_start"];
|
||||
$canceled_at = $active_subscription["canceled_at"];
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $subscription['plan']['id'],
|
||||
'type' => 'subscription',
|
||||
'attributes' => [
|
||||
'incomplete' => $this->subscription('main')->incomplete(),
|
||||
'active' => $this->subscription('main')->active(),
|
||||
'canceled' => $this->subscription('main')->cancelled(),
|
||||
'name' => $subscription['product']['name'],
|
||||
'capacity' => (int)$subscription['product']['metadata']['capacity'],
|
||||
'capacity_formatted' => format_gigabytes($subscription['product']['metadata']['capacity']),
|
||||
'slug' => $subscription['plan']['id'],
|
||||
'canceled_at' => format_date($canceled_at, '%d. %B. %Y'),
|
||||
'created_at' => format_date($current_period_start, '%d. %B. %Y'),
|
||||
'ends_at' => format_date($current_period_end, '%d. %B. %Y'),
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/UsersCollection.php
Normal file
23
app/Http/Resources/UsersCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class UsersCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = UserResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
143
app/Http/Tools/Demo.php
Normal file
143
app/Http/Tools/Demo.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Tools;
|
||||
|
||||
use App;
|
||||
use App\Share;
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
use App\User;
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
|
||||
|
||||
class Demo
|
||||
{
|
||||
/**
|
||||
* Create new directory
|
||||
*
|
||||
* @param $request
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function create_folder($request)
|
||||
{
|
||||
// Get variables
|
||||
$user_scope = $request->user() ? $request->user()->token()->scopes[0] : 'editor';
|
||||
$name = $request->has('name') ? $request->input('name') : 'New Folder';
|
||||
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'id' => random_int(1000, 9999),
|
||||
'parent_id' => random_int(1000, 9999),
|
||||
'name' => $name,
|
||||
'type' => 'folder',
|
||||
'unique_id' => random_int(1000, 9999),
|
||||
'user_scope' => $user_scope,
|
||||
'items' => '0',
|
||||
'updated_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'created_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item name
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $unique_id
|
||||
* @return mixed
|
||||
*/
|
||||
public static function rename_item($request, $unique_id)
|
||||
{
|
||||
// Get item
|
||||
if ($request->type === 'folder') {
|
||||
|
||||
$item = FileManagerFolder::where('unique_id', $unique_id)
|
||||
->where('user_id', 1)
|
||||
->first();
|
||||
|
||||
} else {
|
||||
|
||||
$item = FileManagerFile::where('unique_id', $unique_id)
|
||||
->where('user_id', 1)
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($item) {
|
||||
$item->name = $request->name;
|
||||
|
||||
return $item;
|
||||
|
||||
} else {
|
||||
|
||||
return [
|
||||
'unique_id' => $request->unique_id,
|
||||
'name' => $request->name,
|
||||
'type' => $request->type,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload file
|
||||
*
|
||||
* @param $request
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function upload($request)
|
||||
{
|
||||
// Get user data
|
||||
$user_scope = $request->user() ? $request->user()->token()->scopes[0] : 'editor';
|
||||
|
||||
// File
|
||||
$file = $request->file('file');
|
||||
$filename = Str::random() . '-' . str_replace(' ', '', $file->getClientOriginalName());
|
||||
$thumbnail = null;
|
||||
$filesize = $file->getSize();
|
||||
$filetype = get_file_type($file->getMimeType());
|
||||
|
||||
return [
|
||||
'id' => random_int(1000, 9999),
|
||||
'unique_id' => random_int(1000, 9999),
|
||||
'folder_id' => $request->parent_id,
|
||||
'thumbnail' => 'data:' . $request->file('file')->getMimeType() . ';base64, ' . base64_encode(file_get_contents($request->file('file'))),
|
||||
'name' => $file->getClientOriginalName(),
|
||||
'basename' => $filename,
|
||||
'mimetype' => $file->getClientOriginalExtension(),
|
||||
'filesize' => Metric::bytes($filesize)->format(),
|
||||
'type' => $filetype,
|
||||
'file_url' => 'https://vuefilemanager.hi5ve.digital/assets/vue-file-manager-preview.jpg',
|
||||
'user_scope' => $user_scope,
|
||||
'created_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'updated_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 204 status
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public static function response_204() {
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 204 status
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public static function favourites($user) {
|
||||
|
||||
return $user->favourite_folders->makeHidden(['pivot']);
|
||||
}
|
||||
}
|
||||
702
app/Http/Tools/Editor.php
Normal file
702
app/Http/Tools/Editor.php
Normal file
@@ -0,0 +1,702 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Tools;
|
||||
|
||||
use App;
|
||||
use App\Share;
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
use App\User;
|
||||
use App\Zip;
|
||||
use Aws\Exception\MultipartUploadException;
|
||||
use Aws\S3\MultipartUploader;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use Madnest\Madzipper\Facades\Madzipper;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
|
||||
class Editor
|
||||
{
|
||||
/**
|
||||
* Store folder icon
|
||||
*
|
||||
* @param $folder_icon
|
||||
* @param $unique_id
|
||||
* @param $shared
|
||||
*/
|
||||
public static function set_folder_icon ($folder_icon, $unique_id, $shared = null)
|
||||
{
|
||||
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
|
||||
|
||||
// Get folder
|
||||
$folder = FileManagerFolder::where('user_id', $user_id)
|
||||
->where('unique_id', $unique_id)
|
||||
->first();
|
||||
|
||||
// If request have emoji set folder icon emoji
|
||||
if(isset($folder_icon['emoji'])) {
|
||||
$folder->icon_emoji = $folder_icon['emoji'];
|
||||
$folder->icon_color = null;
|
||||
}
|
||||
|
||||
// If request have color set folder icon color
|
||||
if(isset($folder_icon['color'])) {
|
||||
$folder->icon_emoji = null;
|
||||
$folder->icon_color = $folder_icon['color'];
|
||||
}
|
||||
|
||||
// Save changes
|
||||
$folder->save();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Zip requested folder
|
||||
*
|
||||
* @param $unique_id
|
||||
* @param $shared
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public static function zip_folder($unique_id, $shared = null)
|
||||
{
|
||||
// Get folder
|
||||
$requested_folder = FileManagerFolder::with(['folders.files', 'files'])
|
||||
->where('unique_id', $unique_id)
|
||||
->where('user_id', Auth::id() ?? $shared->user_id)
|
||||
->with('folders')
|
||||
->first();
|
||||
|
||||
$files = get_files_for_zip($requested_folder, collect([]));
|
||||
|
||||
// Local storage instance
|
||||
$disk_local = Storage::disk('local');
|
||||
|
||||
// Create zip directory
|
||||
if (!$disk_local->exists('zip')) {
|
||||
$disk_local->makeDirectory('zip');
|
||||
}
|
||||
|
||||
// Move file to local storage
|
||||
if (!is_storage_driver('local')) {
|
||||
|
||||
// Create temp directory
|
||||
if (!$disk_local->exists('temp')) {
|
||||
$disk_local->makeDirectory('temp');
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
try {
|
||||
$disk_local->put('temp/' . $file['basename'], Storage::get('file-manager/' . $file['basename']));
|
||||
} catch (FileNotFoundException $e) {
|
||||
throw new HttpException(404, 'File not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get zip path
|
||||
$zip_name = Str::random(16) . '-' . Str::slug($requested_folder->name) . '.zip';
|
||||
$zip_path = 'zip/' . $zip_name;
|
||||
|
||||
// Create zip
|
||||
$zip = Madzipper::make(storage_path() . '/app/' . $zip_path);
|
||||
|
||||
// Get files folder on local storage drive
|
||||
$files_folder = is_storage_driver('local') ? 'file-manager' : 'temp';
|
||||
|
||||
// Add files to zip
|
||||
foreach ($files as $file) {
|
||||
$zip->folder($file['folder_path'])->addString($file['name'], File::get(storage_path() . '/app/' . $files_folder . '/' . $file['basename']));
|
||||
}
|
||||
|
||||
// Close zip
|
||||
$zip->close();
|
||||
|
||||
// Delete temporary files
|
||||
if (!is_storage_driver('local')) {
|
||||
|
||||
foreach ($files as $file) {
|
||||
$disk_local->delete('temp/' . $file['basename']);
|
||||
}
|
||||
}
|
||||
|
||||
// Store zip record
|
||||
return Zip::create([
|
||||
'user_id' => $shared->user_id ?? Auth::id(),
|
||||
'shared_token' => $shared->token ?? null,
|
||||
'basename' => $zip_name,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zip selected files, store it in /zip folder and retrieve zip record
|
||||
*
|
||||
* @param $files
|
||||
* @param null $shared
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public static function zip_files($files, $shared = null)
|
||||
{
|
||||
// Local storage instance
|
||||
$disk_local = Storage::disk('local');
|
||||
|
||||
// Create zip directory
|
||||
if (!$disk_local->exists('zip')) {
|
||||
$disk_local->makeDirectory('zip');
|
||||
}
|
||||
|
||||
// Move file to local storage from external storage service
|
||||
if (!is_storage_driver('local')) {
|
||||
|
||||
// Create temp directory
|
||||
if (!$disk_local->exists('temp')) {
|
||||
$disk_local->makeDirectory('temp');
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
try {
|
||||
$disk_local->put('temp/' . $file['basename'], Storage::get('file-manager/' . $file['basename']));
|
||||
} catch (FileNotFoundException $e) {
|
||||
throw new HttpException(404, 'File not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get zip path
|
||||
$zip_name = Str::random(16) . '.zip';
|
||||
$zip_path = 'zip/' . $zip_name;
|
||||
|
||||
// Create zip
|
||||
$zip = Madzipper::make(storage_path() . '/app/' . $zip_path);
|
||||
|
||||
// Get files folder on local storage drive
|
||||
$files_directory = is_storage_driver('local') ? 'file-manager' : 'temp';
|
||||
|
||||
// Add files to zip
|
||||
$files->each(function ($file) use ($zip, $files_directory) {
|
||||
$zip->addString($file['name'] . '.' . $file['mimetype'], File::get(storage_path() . '/app/' . $files_directory . '/' . $file['basename']));
|
||||
});
|
||||
|
||||
// Close zip
|
||||
$zip->close();
|
||||
|
||||
// Delete temporary files
|
||||
if (!is_storage_driver('local')) {
|
||||
|
||||
$files->each(function ($file) use ($disk_local) {
|
||||
$disk_local->delete('temp/' . $file['basename']);
|
||||
});
|
||||
}
|
||||
|
||||
// Store zip record
|
||||
return Zip::create([
|
||||
'user_id' => $shared->user_id ?? Auth::id(),
|
||||
'shared_token' => $shared->token ?? null,
|
||||
'basename' => $zip_name,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new directory
|
||||
*
|
||||
* @param $request
|
||||
* @param null $shared
|
||||
* @return FileManagerFolder|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public static function create_folder($request, $shared = null)
|
||||
{
|
||||
// Get variables
|
||||
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
|
||||
$name = $request->has('name') ? $request->input('name') : 'New Folder';
|
||||
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
|
||||
$unique_id = get_unique_id();
|
||||
|
||||
// Create folder
|
||||
$folder = FileManagerFolder::create([
|
||||
'parent_id' => $request->parent_id,
|
||||
'unique_id' => $unique_id,
|
||||
'user_scope' => $user_scope,
|
||||
'user_id' => $user_id,
|
||||
'type' => 'folder',
|
||||
'name' => $name,
|
||||
]);
|
||||
|
||||
// Return new folder
|
||||
return $folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item name
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $unique_id
|
||||
* @param null $shared
|
||||
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function rename_item($request, $unique_id, $shared = null)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
|
||||
|
||||
// Get item
|
||||
$item = get_item($request->type, $unique_id, $user_id);
|
||||
|
||||
// Rename item
|
||||
$item->update([
|
||||
'name' => $request->name
|
||||
]);
|
||||
|
||||
// Return updated item
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file or folder
|
||||
*
|
||||
* @param $request
|
||||
* @param $unique_id
|
||||
* @param null $shared
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function delete_item($file, $unique_id, $shared = null)
|
||||
{
|
||||
// Get user id
|
||||
$user = is_null($shared) ? Auth::user() : User::findOrFail($shared->user_id);
|
||||
|
||||
// Delete folder
|
||||
if ($file['type'] === 'folder') {
|
||||
|
||||
// Get folder
|
||||
$folder = FileManagerFolder::withTrashed()
|
||||
->with(['folders'])
|
||||
->where('user_id', $user->id)
|
||||
->where('unique_id', $unique_id)
|
||||
->first();
|
||||
|
||||
// Get folder shared record
|
||||
$shared = Share::where('user_id', $user->id)
|
||||
->where('type', '=', 'folder')
|
||||
->where('item_id', $unique_id)
|
||||
->first();
|
||||
|
||||
// Delete folder shared record
|
||||
if ($shared) {
|
||||
$shared->delete();
|
||||
}
|
||||
|
||||
// Force delete children files
|
||||
if ($file['force_delete']) {
|
||||
|
||||
// Get children folder ids
|
||||
$child_folders = filter_folders_ids($folder->trashed_folders, 'unique_id');
|
||||
|
||||
// Get children files
|
||||
$files = FileManagerFile::onlyTrashed()
|
||||
->where('user_id', $user->id)
|
||||
->whereIn('folder_id', Arr::flatten([$unique_id, $child_folders]))
|
||||
->get();
|
||||
|
||||
// Remove all children files
|
||||
foreach ($files as $file) {
|
||||
|
||||
// Delete file
|
||||
Storage::delete('/file-manager/' . $file->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if (!is_null($file->thumbnail)) Storage::delete('/file-manager/' . $file->getRawOriginal('thumbnail'));
|
||||
|
||||
// Delete file permanently
|
||||
$file->forceDelete();
|
||||
}
|
||||
|
||||
// Delete folder record
|
||||
$folder->forceDelete();
|
||||
}
|
||||
|
||||
// Soft delete items
|
||||
if (!$file['force_delete']) {
|
||||
|
||||
// Remove folder from user favourites
|
||||
$user->favourite_folders()->detach($unique_id);
|
||||
|
||||
// Soft delete folder record
|
||||
$folder->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete item
|
||||
if ($file['type'] !== 'folder') {
|
||||
|
||||
// Get file
|
||||
$item = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user->id)
|
||||
->where('unique_id', $unique_id)
|
||||
->first();
|
||||
|
||||
// Get folder shared record
|
||||
$shared = Share::where('user_id', $user->id)
|
||||
->where('type', '=', 'file')
|
||||
->where('item_id', $unique_id)
|
||||
->first();
|
||||
|
||||
// Delete file shared record
|
||||
if ($shared) {
|
||||
$shared->delete();
|
||||
}
|
||||
|
||||
// Force delete file
|
||||
if ($file['force_delete']) {
|
||||
|
||||
// Delete file
|
||||
Storage::delete('/file-manager/' . $item->basename);
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if ($item->thumbnail) Storage::delete('/file-manager/' . $item->getRawOriginal('thumbnail'));
|
||||
|
||||
// Delete file permanently
|
||||
$item->forceDelete();
|
||||
}
|
||||
|
||||
// Soft delete file
|
||||
if (!$file['force_delete']) {
|
||||
|
||||
// Soft delete file
|
||||
$item->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move folder or file to new location
|
||||
*
|
||||
* @param $request
|
||||
* @param $unique_id
|
||||
* @param null $shared
|
||||
*/
|
||||
public static function move($request, $to_unique_id, $shared = null)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
|
||||
|
||||
foreach ($request->input('items') as $item) {
|
||||
$unique_id = $item['unique_id'];
|
||||
|
||||
if ($item['type'] === 'folder') {
|
||||
|
||||
// Move folder
|
||||
$item = FileManagerFolder::where('user_id', $user_id)
|
||||
->where('unique_id', $unique_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->update([
|
||||
'parent_id' => $to_unique_id
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
||||
// Move file under new folder
|
||||
$item = FileManagerFile::where('user_id', $user_id)
|
||||
->where('unique_id', $unique_id)
|
||||
->firstOrFail();
|
||||
|
||||
$item->update([
|
||||
'folder_id' => $to_unique_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload file
|
||||
*
|
||||
* @param $request
|
||||
* @param null $shared
|
||||
* @return FileManagerFile|\Illuminate\Database\Eloquent\Model
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function upload($request, $shared = null)
|
||||
{
|
||||
// Get parent_id from request
|
||||
$file = $request->file('file');
|
||||
|
||||
// Check or create directories
|
||||
self::check_directories(['chunks', 'file-manager']);
|
||||
|
||||
// File name
|
||||
$user_file_name = basename('chunks/' . substr($file->getClientOriginalName(), 17), '.part');
|
||||
$disk_file_name = basename('chunks/' . $file->getClientOriginalName(), '.part');
|
||||
$temp_filename = $file->getClientOriginalName();
|
||||
|
||||
// File Path
|
||||
$file_path = config('filesystems.disks.local.root') . '/chunks/' . $temp_filename;
|
||||
|
||||
// Generate file
|
||||
File::append($file_path, $file->get());
|
||||
|
||||
// Size of file
|
||||
$file_size = File::size($file_path);
|
||||
|
||||
// Size of limit
|
||||
$limit = get_setting('upload_limit');
|
||||
|
||||
// File size handling
|
||||
if( $limit && $file_size > format_bytes($limit)) abort(413);
|
||||
|
||||
// If last then process file
|
||||
if ($request->boolean('is_last')) {
|
||||
|
||||
$metadata = get_image_meta_data($file);
|
||||
|
||||
$disk_local = Storage::disk('local');
|
||||
$unique_id = get_unique_id();
|
||||
|
||||
// Get user data
|
||||
$user_scope = is_null($shared) ? $request->user()->token()->scopes[0] : 'editor';
|
||||
$user_id = is_null($shared) ? Auth::id() : $shared->user_id;
|
||||
|
||||
// File Info
|
||||
$file_size = $disk_local->size('chunks/' . $temp_filename);
|
||||
$file_mimetype = $disk_local->mimeType('chunks/' . $temp_filename);
|
||||
|
||||
// Check if user has enough space to upload file
|
||||
self::check_user_storage_capacity($user_id, $file_size, $temp_filename);
|
||||
|
||||
// Create thumbnail
|
||||
$thumbnail = self::get_image_thumbnail('chunks/' . $temp_filename, $disk_file_name);
|
||||
|
||||
// Move finished file from chunk to file-manager directory
|
||||
$disk_local->move('chunks/' . $temp_filename, 'file-manager/' . $disk_file_name);
|
||||
|
||||
// Move files to external storage
|
||||
if (!is_storage_driver(['local'])) {
|
||||
|
||||
// Clear failed uploads if exists
|
||||
self::clear_failed_files();
|
||||
|
||||
// Move file to external storage service
|
||||
self::move_to_external_storage($disk_file_name, $thumbnail);
|
||||
}
|
||||
|
||||
// Store file
|
||||
$options = [
|
||||
'mimetype' => get_file_type_from_mimetype($file_mimetype),
|
||||
'type' => get_file_type($file_mimetype),
|
||||
'folder_id' => $request->parent_id,
|
||||
'metadata' => $metadata,
|
||||
'name' => $user_file_name,
|
||||
'unique_id' => $unique_id,
|
||||
'basename' => $disk_file_name,
|
||||
'user_scope' => $user_scope,
|
||||
'thumbnail' => $thumbnail,
|
||||
'filesize' => $file_size,
|
||||
'user_id' => $user_id,
|
||||
];
|
||||
|
||||
// Store user upload size
|
||||
if ($request->user()) {
|
||||
|
||||
// If upload a loged user
|
||||
$request->user()->record_upload($file_size);
|
||||
|
||||
} else {
|
||||
|
||||
// If upload guest
|
||||
User::find($shared->user_id)->record_upload($file_size);
|
||||
|
||||
}
|
||||
|
||||
// Return new file
|
||||
return FileManagerFile::create($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear failed files
|
||||
*/
|
||||
private static function clear_failed_files()
|
||||
{
|
||||
$local_disk = Storage::disk('local');
|
||||
|
||||
// Get all files from storage
|
||||
$files = collect([
|
||||
$local_disk->allFiles('file-manager'),
|
||||
$local_disk->allFiles('chunks')
|
||||
])->collapse();
|
||||
|
||||
$files->each(function ($file) use ($local_disk) {
|
||||
|
||||
// Get the file's last modification time.
|
||||
$last_modified = $local_disk->lastModified($file);
|
||||
|
||||
// Get diffInHours
|
||||
$diff = Carbon::parse($last_modified)->diffInHours(Carbon::now());
|
||||
|
||||
// Delete if file is in local storage more than 24 hours
|
||||
if ($diff > 24) {
|
||||
|
||||
Log::info('Failed file or chunk ' . $file . ' deleted.');
|
||||
|
||||
// Delete file from local storage
|
||||
$local_disk->delete($file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Move file to external storage if is set
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string|null $thumbnail
|
||||
*/
|
||||
private static function move_to_external_storage(string $filename, ?string $thumbnail): void
|
||||
{
|
||||
$disk_local = Storage::disk('local');
|
||||
|
||||
foreach ([$filename, $thumbnail] as $file) {
|
||||
|
||||
// Check if file exist
|
||||
if (!$file) continue;
|
||||
|
||||
// Get file size
|
||||
$filesize = $disk_local->size('file-manager/' . $file);
|
||||
|
||||
// If file is bigger than 5.2MB then run multipart upload
|
||||
if ($filesize > 5242880) {
|
||||
|
||||
// Get driver
|
||||
$driver = \Storage::getDriver();
|
||||
|
||||
// Get adapter
|
||||
$adapter = $driver->getAdapter();
|
||||
|
||||
// Get client
|
||||
$client = $adapter->getClient();
|
||||
|
||||
// Prepare the upload parameters.
|
||||
$uploader = new MultipartUploader($client, config('filesystems.disks.local.root') . '/file-manager/' . $file, [
|
||||
'bucket' => $adapter->getBucket(),
|
||||
'key' => 'file-manager/' . $file
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
// Upload content
|
||||
$uploader->upload();
|
||||
|
||||
} catch (MultipartUploadException $e) {
|
||||
|
||||
// Write error log
|
||||
Log::error($e->getMessage());
|
||||
|
||||
// Delete file after error
|
||||
$disk_local->delete('file-manager/' . $file);
|
||||
|
||||
throw new HttpException(409, $e->getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Stream file object to s3
|
||||
Storage::putFileAs('file-manager', config('filesystems.disks.local.root') . '/file-manager/' . $file, $file, 'private');
|
||||
}
|
||||
|
||||
// Delete file after upload
|
||||
$disk_local->delete('file-manager/' . $file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directories 'chunks' and 'file-manager exist', if no, then create
|
||||
*
|
||||
* @param $directories
|
||||
*/
|
||||
private static function check_directories($directories): void
|
||||
{
|
||||
foreach ($directories as $directory) {
|
||||
|
||||
if (!Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
|
||||
if (!is_storage_driver(['local'])) {
|
||||
if (!Storage::exists($directory)) {
|
||||
Storage::makeDirectory($directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create thumbnail for images
|
||||
*
|
||||
* @param string $file_path
|
||||
* @param string $filename
|
||||
* @param $file
|
||||
* @return string|null
|
||||
*/
|
||||
private static function get_image_thumbnail(string $file_path, string $filename)
|
||||
{
|
||||
$local_disk = Storage::disk('local');
|
||||
|
||||
// Create thumbnail from image
|
||||
if (in_array($local_disk->mimeType($file_path), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
|
||||
|
||||
// Get thumbnail name
|
||||
$thumbnail = 'thumbnail-' . $filename;
|
||||
|
||||
// Create intervention image
|
||||
$image = Image::make(config('filesystems.disks.local.root') . '/' . $file_path)->orientate();
|
||||
|
||||
// Resize image
|
||||
$image->resize(512, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
})->stream();
|
||||
|
||||
// Store thumbnail to disk
|
||||
$local_disk->put('file-manager/' . $thumbnail, $image);
|
||||
}
|
||||
|
||||
// Return thumbnail as svg file
|
||||
if ($local_disk->mimeType($file_path) === 'image/svg+xml') {
|
||||
|
||||
$thumbnail = $filename;
|
||||
}
|
||||
|
||||
return $thumbnail ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has enough space to upload file
|
||||
*
|
||||
* @param $user_id
|
||||
* @param int $file_size
|
||||
* @param $temp_filename
|
||||
*/
|
||||
private static function check_user_storage_capacity($user_id, int $file_size, $temp_filename): void
|
||||
{
|
||||
// Get user storage percentage and get storage_limitation setting
|
||||
$user_storage_used = user_storage_percentage($user_id, $file_size);
|
||||
$storage_limitation = get_setting('storage_limitation');
|
||||
|
||||
// Check if user can upload
|
||||
if ($storage_limitation && $user_storage_used >= 100) {
|
||||
|
||||
// Delete file
|
||||
Storage::disk('local')->delete('chunks/' . $temp_filename);
|
||||
|
||||
// Abort uploading
|
||||
abort(423, 'You exceed your storage limit!');
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/Http/Tools/Guardian.php
Normal file
42
app/Http/Tools/Guardian.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Tools;
|
||||
|
||||
use App;
|
||||
use App\FileManagerFolder;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class Guardian
|
||||
{
|
||||
/**
|
||||
* Check access to requested directory
|
||||
*
|
||||
* @param integer|array $requested_id
|
||||
* @param string $shared Shared record detail
|
||||
*/
|
||||
public static function check_item_access($requested_id, $shared)
|
||||
{
|
||||
// Get all children folders
|
||||
$foldersIds = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('user_id', $shared->user_id)
|
||||
->where('parent_id', $shared->item_id)
|
||||
->get();
|
||||
|
||||
// Get all authorized parent folders by shared folder as root of tree
|
||||
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
||||
|
||||
// Check user access
|
||||
if ( is_array($requested_id) ) {
|
||||
foreach ($requested_id as $id) {
|
||||
if (!in_array($id, $accessible_folder_ids))
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_array($requested_id)) {
|
||||
if (! in_array($requested_id, $accessible_folder_ids))
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user