mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 18:53:48 +00:00
Compare commits
916 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
571fec7949 | ||
|
|
f9b5595ab6 | ||
|
|
b358a614e2 | ||
|
|
7d9d2a9da9 | ||
|
|
c132601f06 | ||
|
|
0e4595c30f | ||
|
|
c323304f2e | ||
|
|
d9ee68db7c | ||
|
|
82019f4833 | ||
|
|
756e0c4ca3 | ||
|
|
c52c576f7c | ||
|
|
5215d7d38d | ||
|
|
dd271ea8cc | ||
|
|
6397ce9a67 | ||
|
|
8568a815a0 | ||
|
|
6fc29eac8e | ||
|
|
449724e78a | ||
|
|
e5de408ab0 | ||
|
|
1c057e9f86 | ||
|
|
f6f9199b87 | ||
|
|
cb99e105c0 | ||
|
|
24676e2392 | ||
|
|
c0da1b0b07 | ||
|
|
d7b8214406 | ||
|
|
3fc11b781b | ||
|
|
f2be4059cf | ||
|
|
081a69450a | ||
|
|
b50e0041e0 | ||
|
|
847221d385 | ||
|
|
1a63f3aa07 | ||
|
|
f29a93f77b | ||
|
|
f294c8f4a1 | ||
|
|
959beae9e9 | ||
|
|
524b5a94df | ||
|
|
05dc227650 | ||
|
|
350f130d98 | ||
|
|
99b4b030d2 | ||
|
|
8a2af11f6a | ||
|
|
26636dffab | ||
|
|
3dae2a72c9 | ||
|
|
38fadeec5e | ||
|
|
31954767b7 | ||
|
|
c760116cbf | ||
|
|
49131ddf97 | ||
|
|
fb7338c2bb | ||
|
|
d2391afb14 | ||
|
|
8e66900d8d | ||
|
|
1a77ccdb9d | ||
|
|
50a96d9051 | ||
|
|
7baf8f0ec9 | ||
|
|
8389f7a4d6 | ||
|
|
b74f93a271 | ||
|
|
ed9c80eb74 | ||
|
|
147f82e9a8 | ||
|
|
15a6ad6166 | ||
|
|
3fbf0ca093 | ||
|
|
2586e65cf9 | ||
|
|
b8731a108b | ||
|
|
2f238c90d9 | ||
|
|
6f9ae7ebfe | ||
|
|
983425b89a | ||
|
|
ca9ed1029e | ||
|
|
78aa1a0779 | ||
|
|
4ec2d1077f | ||
|
|
7cefc8dfa1 | ||
|
|
0000909ec0 | ||
|
|
61824a511c | ||
|
|
cb239fb3bc | ||
|
|
08099b9671 | ||
|
|
bb8a205b7e | ||
|
|
09dda32dfd | ||
|
|
790052804e | ||
|
|
e371b37016 | ||
|
|
05583f74af | ||
|
|
6cbffd08b2 | ||
|
|
66fe92653c | ||
|
|
b16b8b87cc | ||
|
|
2e233990a2 | ||
|
|
04a1f88abb | ||
|
|
8a1c20bf4a | ||
|
|
6dc34964d8 | ||
|
|
d8bbfcd4d2 | ||
|
|
26f23863c0 | ||
|
|
0eee956011 | ||
|
|
722eceb0c1 | ||
|
|
b4e6561134 | ||
|
|
3af8bff13b | ||
|
|
f5958dda57 | ||
|
|
e8ca132a8b | ||
|
|
a7a6ef9f0a | ||
|
|
688f234ae1 | ||
|
|
6e330046b3 | ||
|
|
438ddbb868 | ||
|
|
a6db642db7 | ||
|
|
1ea8f2ce60 | ||
|
|
bcd4209aca | ||
|
|
88ac70bc67 | ||
|
|
b31fb4f7d2 | ||
|
|
862fc68134 | ||
|
|
a04c2de84f | ||
|
|
6ac8089cd7 | ||
|
|
f29a2571df | ||
|
|
c0d1fa6965 | ||
|
|
499e4e8f7c | ||
|
|
5ea898d716 | ||
|
|
9857a30d2c | ||
|
|
ca255a7416 | ||
|
|
e9a1ad9f09 | ||
|
|
dccf006f1e | ||
|
|
a2e467b65d | ||
|
|
3d876835f6 | ||
|
|
5e0007764e | ||
|
|
21142c1171 | ||
|
|
50bdac62dc | ||
|
|
ac75cb5d0f | ||
|
|
73672bc023 | ||
|
|
070f8b4d40 | ||
|
|
f5f0663d07 | ||
|
|
8b3c6cfc27 | ||
|
|
f252a0ba23 | ||
|
|
3c8d6ac862 | ||
|
|
bd881da856 | ||
|
|
86b6844d62 | ||
|
|
da38580504 | ||
|
|
9fbd5fd472 | ||
|
|
69deafeda0 | ||
|
|
070a3aaba4 | ||
|
|
599b238ab4 | ||
|
|
bdfd92872e | ||
|
|
62820c8ddb | ||
|
|
c65414f0c4 | ||
|
|
7cc27938bf | ||
|
|
0332f8b1fb | ||
|
|
fbde515a40 | ||
|
|
cc4f9c0b89 | ||
|
|
8a784f4520 | ||
|
|
9793a55efd | ||
|
|
eb2a7323e9 | ||
|
|
d162018fcf | ||
|
|
23611defc1 | ||
|
|
434c45299c | ||
|
|
878bdb3ce7 | ||
|
|
fe0ed38157 | ||
|
|
6b43464e85 | ||
|
|
8c6e0321fd | ||
|
|
8f9bdc5918 | ||
|
|
25d9691a31 | ||
|
|
6052174b83 | ||
|
|
583d65a1da | ||
|
|
856d3b6aa1 | ||
|
|
33a65b1c77 | ||
|
|
4613c72412 | ||
|
|
04fa824d16 | ||
|
|
75e51c3f10 | ||
|
|
ca7944b17a | ||
|
|
ed6c968dae | ||
|
|
c923a40363 | ||
|
|
3c3e82758d | ||
|
|
5167ae520e | ||
|
|
aea4213ec2 | ||
|
|
31dd782bae | ||
|
|
120973ae00 | ||
|
|
1486ce63fa | ||
|
|
834b0ba5e0 | ||
|
|
19bce195b4 | ||
|
|
13ec1257e1 | ||
|
|
248825f2d1 | ||
|
|
b37edd298a | ||
|
|
1e4bbd10f3 | ||
|
|
bcf14595bf | ||
|
|
e7c4048258 | ||
|
|
f7135c9b27 | ||
|
|
5be490c8d5 | ||
|
|
7cf193abb7 | ||
|
|
644fbaede4 | ||
|
|
7d020b0bbc | ||
|
|
93e5a29d40 | ||
|
|
3ee8c255d5 | ||
|
|
7e50e221f2 | ||
|
|
6f6c987538 | ||
|
|
5dcf8df751 | ||
|
|
b895cbc9c0 | ||
|
|
321e62fb0a | ||
|
|
e9aca0a6c3 | ||
|
|
717dcb02ef | ||
|
|
9744780022 | ||
|
|
c47886fb8b | ||
|
|
e103e61617 | ||
|
|
e65ccf0680 | ||
|
|
85613dd846 | ||
|
|
b52fe0454b | ||
|
|
3645b3e8f7 | ||
|
|
01e94b97ba | ||
|
|
2e906daf58 | ||
|
|
e65e3e88d7 | ||
|
|
9a5f9fe49d | ||
|
|
16c47465e6 | ||
|
|
da55b3dd78 | ||
|
|
894cef5d66 | ||
|
|
90f91c47ce | ||
|
|
3774a05edd | ||
|
|
73861f814c | ||
|
|
5b70066900 | ||
|
|
4b0e4da013 | ||
|
|
eae212ac5d | ||
|
|
5a9583be5b | ||
|
|
aa585b60d5 | ||
|
|
8707a61144 | ||
|
|
597a600109 | ||
|
|
4dfc5bcc35 | ||
|
|
33d45408d2 | ||
|
|
90051cec91 | ||
|
|
dd0d10afda | ||
|
|
af571317ff | ||
|
|
80019b822d | ||
|
|
25a28c37c8 | ||
|
|
7e8511ab3f | ||
|
|
7cd29fce98 | ||
|
|
b0c81a692c | ||
|
|
b71072ddda | ||
|
|
79d3e2beac | ||
|
|
fc11a38457 | ||
|
|
be6ccecee6 | ||
|
|
66198a50e1 | ||
|
|
0910daa1a3 | ||
|
|
397b3228d0 | ||
|
|
2a02716a53 | ||
|
|
edafa1791b | ||
|
|
498f81b846 | ||
|
|
b105c9fc8f | ||
|
|
9105ce8bb1 | ||
|
|
6056e97463 | ||
|
|
639f24fdfd | ||
|
|
110f7b60d6 | ||
|
|
a7ba0719a5 | ||
|
|
213d6230ca | ||
|
|
eba8903792 | ||
|
|
56bbdc846c | ||
|
|
a2c606e1c7 | ||
|
|
3e61482a2c | ||
|
|
16b7575fca | ||
|
|
14efc4c29f | ||
|
|
bec2dd0e03 | ||
|
|
0bf81164e7 | ||
|
|
da49a7b051 | ||
|
|
469e0883d9 | ||
|
|
3e18dbd4f9 | ||
|
|
1568eab905 | ||
|
|
452da6c6b4 | ||
|
|
d5e371f8d6 | ||
|
|
b6290a0cad | ||
|
|
afd2270e0e | ||
|
|
58ecc33986 | ||
|
|
2598ba38db | ||
|
|
e78f1ce731 | ||
|
|
b00c8cdbed | ||
|
|
44a656e5d5 | ||
|
|
11c6690e50 | ||
|
|
fac75c7e71 | ||
|
|
30ae2c0a54 | ||
|
|
87b3625b27 | ||
|
|
bf9581173c | ||
|
|
57bab1a225 | ||
|
|
17ccf7b354 | ||
|
|
e40ddbec14 | ||
|
|
131ae8109f | ||
|
|
90c0466cd0 | ||
|
|
71147adb01 | ||
|
|
7cefcf8dab | ||
|
|
737adfa91a | ||
|
|
f531ffce11 | ||
|
|
13992deb41 | ||
|
|
20f8fe4b51 | ||
|
|
e0daa46b50 | ||
|
|
2ca4d4a02d | ||
|
|
399748b01a | ||
|
|
2f4df83b31 | ||
|
|
9ea78d103e | ||
|
|
790da00420 | ||
|
|
760d7a4687 | ||
|
|
37ab6408ba | ||
|
|
b3737c11ba | ||
|
|
4f667f7a94 | ||
|
|
377c471a6c | ||
|
|
b2d133e5a3 | ||
|
|
26085c475f | ||
|
|
7cf09494e5 | ||
|
|
5d0348e2d0 | ||
|
|
7772ef6b40 | ||
|
|
5130082111 | ||
|
|
a8fa3694be | ||
|
|
6ac6528243 | ||
|
|
ec51440c3a | ||
|
|
cdb395c77f | ||
|
|
ee4a2205f6 | ||
|
|
0f357ace50 | ||
|
|
4d5cd3d80f | ||
|
|
bb3f4d4bda | ||
|
|
6d5a43da72 | ||
|
|
d2a82aaa80 | ||
|
|
9fef371099 | ||
|
|
9e330da7a6 | ||
|
|
a3d4dfec3b | ||
|
|
254a00e18e | ||
|
|
ee1a8a6719 | ||
|
|
44fe96497c | ||
|
|
ac6b2b09e1 | ||
|
|
a18ceb1b4f | ||
|
|
88c134918e | ||
|
|
f2c44c3cfe | ||
|
|
ffe6de5b98 | ||
|
|
af79a28361 | ||
|
|
1bb3ca4fb5 | ||
|
|
4a114ec096 | ||
|
|
0e3c6e286e | ||
|
|
09d2032a70 | ||
|
|
1ffa569ea3 | ||
|
|
480f518ebc | ||
|
|
888d76fea0 | ||
|
|
47ce8c3eef | ||
|
|
4142f829be | ||
|
|
6f7b34dd0a | ||
|
|
c6b3995cc3 | ||
|
|
75042e0c42 | ||
|
|
9566a4a830 | ||
|
|
7521c588fc | ||
|
|
19925e398f | ||
|
|
c722c50ec3 | ||
|
|
4163c28e37 | ||
|
|
80f27d7448 | ||
|
|
97f13c0b62 | ||
|
|
4b97c674ba | ||
|
|
0d4b8403ba | ||
|
|
df5d5cb75f | ||
|
|
021e78e0c5 | ||
|
|
778a94e5ba | ||
|
|
0db55b51d2 | ||
|
|
45de6b557a | ||
|
|
5910bb1206 | ||
|
|
61635db3db | ||
|
|
3c01ce5ad3 | ||
|
|
80b24cd753 | ||
|
|
4999b23474 | ||
|
|
a90311593b | ||
|
|
cff7cd6b32 | ||
|
|
c8dedd44c4 | ||
|
|
2e9112d110 | ||
|
|
aa51484303 | ||
|
|
19a75d2fb1 | ||
|
|
f4b3f1f163 | ||
|
|
ed8ab2978f | ||
|
|
db9900fcfb | ||
|
|
ba7d6be249 | ||
|
|
816c8c3e07 | ||
|
|
c73e44ff01 | ||
|
|
fc18280842 | ||
|
|
1d52186f17 | ||
|
|
87e05d9521 | ||
|
|
ce477fdaf1 | ||
|
|
617f715774 | ||
|
|
2c69553582 | ||
|
|
f142919cd1 | ||
|
|
f0e9c80572 | ||
|
|
adbe35e8b5 | ||
|
|
f3783e6f98 | ||
|
|
1bb59854ea | ||
|
|
803cc089bd | ||
|
|
ba902a30b3 | ||
|
|
6b67f861c3 | ||
|
|
749bc4ae83 | ||
|
|
7e3bbe4008 | ||
|
|
cb272709a3 | ||
|
|
961a8900be | ||
|
|
732fc48aa4 | ||
|
|
07cc977684 | ||
|
|
380a588b0a | ||
|
|
9297eae1d7 | ||
|
|
419a1d8180 | ||
|
|
9cc9111d63 | ||
|
|
0364e73c60 | ||
|
|
bb469f2520 | ||
|
|
d0bd866354 | ||
|
|
c5e9d29362 | ||
|
|
71d0005193 | ||
|
|
95eb167622 | ||
|
|
5778de20f2 | ||
|
|
9c3c044623 | ||
|
|
deaac3717c | ||
|
|
353180491b | ||
|
|
b022cde9e0 | ||
|
|
b837cc1906 | ||
|
|
89a6c51672 | ||
|
|
bb2094016b | ||
|
|
3e8acd9b4b | ||
|
|
db57bde4fc | ||
|
|
8ef5444136 | ||
|
|
af5181d4d7 | ||
|
|
6075a1b7c8 | ||
|
|
266f9d8a0a | ||
|
|
ed90173ec9 | ||
|
|
ff4af2978d | ||
|
|
5e37e10a0c | ||
|
|
cc526f8d95 | ||
|
|
8de3e80c4f | ||
|
|
2c7cb67e7c | ||
|
|
9606d0e7db | ||
|
|
8be86183fa | ||
|
|
1126a45524 | ||
|
|
8a4ffd03c6 | ||
|
|
8d85aad601 | ||
|
|
1045423692 | ||
|
|
aecdf56304 | ||
|
|
e164d1021c | ||
|
|
33fa77cd73 | ||
|
|
891ca7260b | ||
|
|
9f1174b547 | ||
|
|
1f615c54af | ||
|
|
6b909c2380 | ||
|
|
5660fcd4dc | ||
|
|
da7aee2790 | ||
|
|
dd4fab8e7c | ||
|
|
88540bd2a6 | ||
|
|
355b016f22 | ||
|
|
485dddec68 | ||
|
|
4c947a0e4d | ||
|
|
842abcb6b1 | ||
|
|
b87f8b68d4 | ||
|
|
ce08240355 | ||
|
|
e514994b08 | ||
|
|
779b7fc8ba | ||
|
|
5844e66b7f | ||
|
|
2782dc879b | ||
|
|
80f38d47ed | ||
|
|
350b3cb6b3 | ||
|
|
b544aa875f | ||
|
|
9c7d7a336b | ||
|
|
9b91fe3d59 | ||
|
|
d4df26bf35 | ||
|
|
7e4bd191d7 | ||
|
|
0add1eaf7f | ||
|
|
69b72d24a9 | ||
|
|
b1c15bb6a7 | ||
|
|
b38f04533c | ||
|
|
cd9d1d91bd | ||
|
|
7f21755f5a | ||
|
|
f95b3acbd2 | ||
|
|
0748f8face | ||
|
|
617ba2a6a8 | ||
|
|
4e098286a6 | ||
|
|
1536af7a5b | ||
|
|
33d6d1cd60 | ||
|
|
63ba4d3a1d | ||
|
|
4ab716bf9c | ||
|
|
594a4acc94 | ||
|
|
42d243e2fe | ||
|
|
9583c22b72 | ||
|
|
b66d47bf2b | ||
|
|
bcba0fd057 | ||
|
|
1784ff84c8 | ||
|
|
2007279a69 | ||
|
|
d8b279479a | ||
|
|
bb2e349a31 | ||
|
|
674290edfc | ||
|
|
486d8de378 | ||
|
|
b82f34ed4d | ||
|
|
81dc7d7ed7 | ||
|
|
a2d3bdd67b | ||
|
|
fdef2de99d | ||
|
|
f55472442f | ||
|
|
3328fdebb0 | ||
|
|
97ade6c238 | ||
|
|
5225673163 | ||
|
|
27675d7f38 | ||
|
|
92962aac17 | ||
|
|
f38b265ba7 | ||
|
|
6736afaefb | ||
|
|
dfb809acee | ||
|
|
5227a5fb99 | ||
|
|
fe728479d0 | ||
|
|
b7e1be7518 | ||
|
|
1359b78d21 | ||
|
|
920ee19651 | ||
|
|
7dd4e65d77 | ||
|
|
fd02fbfe08 | ||
|
|
00e515e995 | ||
|
|
55ba82442a | ||
|
|
7a963cf5b3 | ||
|
|
2f332197e6 | ||
|
|
ac38d35ae1 | ||
|
|
af1a8e6333 | ||
|
|
18518106ca | ||
|
|
92e02d8b57 | ||
|
|
b42d480c91 | ||
|
|
c8a9f18265 | ||
|
|
56b7f30d47 | ||
|
|
725a34b7d0 | ||
|
|
595bce60eb | ||
|
|
bf6cd34cf6 | ||
|
|
b8790a964b | ||
|
|
9a1a9ee206 | ||
|
|
05f850ab2c | ||
|
|
c2868c051d | ||
|
|
28b39a79e6 | ||
|
|
2dbd9dd62d | ||
|
|
9dbce7a73a | ||
|
|
8ac5c8fd38 | ||
|
|
2a105877f3 | ||
|
|
28efba5773 | ||
|
|
60f02622da | ||
|
|
7eee7deba5 | ||
|
|
ba0b2bd3b9 | ||
|
|
86090b5870 | ||
|
|
39681bc48a | ||
|
|
96e1bdd99f | ||
|
|
eebeee6948 | ||
|
|
67cf7a6ced | ||
|
|
7be02edead | ||
|
|
d65c27091c | ||
|
|
6c3630085e | ||
|
|
f6dbb5e71e | ||
|
|
29fce75d35 | ||
|
|
a80e4364ae | ||
|
|
bfb3888555 | ||
|
|
5e408267ee | ||
|
|
a4725df5f7 | ||
|
|
dee562c56e | ||
|
|
e1016502a1 | ||
|
|
541924448b | ||
|
|
18b97866f2 | ||
|
|
6f2278b908 | ||
|
|
bdd8d63162 | ||
|
|
8ca7881c5e | ||
|
|
8d04a94dbc | ||
|
|
d92bb50a03 | ||
|
|
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 | ||
|
|
a8457cf261 | ||
|
|
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 |
77
.env.example
77
.env.example
@@ -1,10 +1,17 @@
|
||||
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
|
||||
LOG_CHANNEL=daily
|
||||
|
||||
SCOUT_DRIVER=tntsearch
|
||||
SCOUT_QUEUE=true
|
||||
|
||||
FILESYSTEM_DRIVER=
|
||||
CHUNK_SIZE=128
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
@@ -13,9 +20,11 @@ DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
DB_MYSQLDUMP_PATH=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
QUEUE_CONNECTION=database
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
@@ -23,24 +32,52 @@ 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}"
|
||||
|
||||
OSS_ACCESS_KEY_ID=
|
||||
OSS_SECRET_ACCESS_KEY=
|
||||
OSS_REGION=
|
||||
OSS_BUCKET=
|
||||
OSS_ENDPOINT=
|
||||
OSS_URL=
|
||||
|
||||
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=
|
||||
|
||||
APP_DEPLOY_SECRET=
|
||||
|
||||
CASHIER_LOGGER=stack
|
||||
CASHIER_CURRENCY=
|
||||
STRIPE_KEY=
|
||||
STRIPE_SECRET=
|
||||
STRIPE_WEBHOOK_SECRET=
|
||||
CASHIER_PAYMENT_NOTIFICATION=App\Notifications\ConfirmPayment
|
||||
|
||||
SANCTUM_STATEFUL_DOMAINS=localhost,localhost:8000,127.0.0.1,127.0.0.1:8000,::1
|
||||
58
.env.testing
Normal file
58
.env.testing
Normal file
@@ -0,0 +1,58 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:47yorkyoH3qCrKKO4eG6LpZUogoTC51qey5vYq/O3AM=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEMO=false
|
||||
|
||||
LOG_CHANNEL=daily
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_HOST=null
|
||||
DB_PORT=null
|
||||
DB_DATABASE=database/test.sqlite
|
||||
DB_USERNAME=null
|
||||
DB_PASSWORD=null
|
||||
|
||||
FILESYSTEM_DRIVER=local
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
SCOUT_DRIVER=tntsearch
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
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}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
CASHIER_LOGGER=stack
|
||||
CASHIER_CURRENCY=CZK
|
||||
STRIPE_KEY=pk_test_51HSO06BwlPpoyJNwCscZSl5kYHtck4ChaICquBQodULHWTQlQxpEpQ22rQAPY1B82k78dR2tquugI3qRv2HcFrx300pqiho4Dz
|
||||
STRIPE_SECRET=sk_test_51HSO06BwlPpoyJNwOCWiJafj5ebRF5dYQ0VpaQnHVWLZYYgj8jl3CX2K51Sf1cjDKxUzzGMVsg6e98i2GgtFSSfu00Q1uo6Knz
|
||||
STRIPE_WEBHOOK_SECRET=whsec_eKrDhqtpbMUXOKqrUHf78SrZxHHYOdrf
|
||||
CASHIER_PAYMENT_NOTIFICATION=App\Notifications\ConfirmPayment
|
||||
CASHIER_MODEL=App\Models\User
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,127.0.0.1:8000,::1
|
||||
28
.github/workflows/backend-code-style-fix.yml
vendored
Normal file
28
.github/workflows/backend-code-style-fix.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: Code Style Fix
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ oasis ]
|
||||
pull_request:
|
||||
branches: [ oasis ]
|
||||
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Run PHP CS Fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
with:
|
||||
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Fix backend code styling
|
||||
35
.github/workflows/build.yml
vendored
Normal file
35
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Frontend Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ oasis ]
|
||||
pull_request:
|
||||
branches: [ oasis ]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- run: npm run prod
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Application Build
|
||||
47
.github/workflows/unit-testing.yml
vendored
Normal file
47
.github/workflows/unit-testing.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Unit Testing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ oasis ]
|
||||
pull_request:
|
||||
branches: [ oasis ]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
php: [8.0]
|
||||
stability: [prefer-stable]
|
||||
|
||||
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: ctype, json, exif, dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
|
||||
coverage: none
|
||||
|
||||
- name: Setup problem matchers
|
||||
run: |
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||
|
||||
- uses: actions/labeler@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GTHB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
|
||||
|
||||
- name: Run tests
|
||||
run: vendor/bin/phpunit
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,12 +3,19 @@
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/*.index
|
||||
/storage/framework/cache/*
|
||||
/vendor
|
||||
/resources/babel.babel
|
||||
.idea
|
||||
.env
|
||||
.env.backup
|
||||
.env.testing
|
||||
.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]
|
||||
1
.php-cs-fixer.cache
Normal file
1
.php-cs-fixer.cache
Normal file
File diff suppressed because one or more lines are too long
73
.php-cs-fixer.dist.php
Normal file
73
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in([
|
||||
__DIR__ . '/app',
|
||||
__DIR__ . '/routes',
|
||||
__DIR__ . '/config',
|
||||
])
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short'
|
||||
],
|
||||
'ordered_imports' => [
|
||||
'sort_algorithm' => 'length'
|
||||
],
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => ['break', 'case', 'continue', 'declare', 'default', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from'],
|
||||
],
|
||||
'method_argument_space' => [
|
||||
'on_multiline' => 'ensure_fully_multiline',
|
||||
'keep_multiple_spaces_after_comma' => true,
|
||||
],
|
||||
'no_extra_blank_lines' => [
|
||||
'tokens' => ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait'],
|
||||
],
|
||||
'cast_spaces' => [
|
||||
'space' => 'single'
|
||||
],
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'single_space_after_construct' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
|
||||
'phpdoc_scalar' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'binary_operator_spaces' => ['operators' => ['=>' => 'align']],
|
||||
'single_trait_insert_per_statement' => false,
|
||||
'method_chaining_indentation' => true,
|
||||
'array_indentation' => true,
|
||||
'single_quote' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_empty_statement' => true,
|
||||
'standardize_increment' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_blank_lines_before_namespace' => true,
|
||||
'blank_line_after_namespace' => true,
|
||||
'fully_qualified_strict_types' => true,
|
||||
'single_line_throw' => true,
|
||||
'function_typehint_space' => true,
|
||||
'simplified_if_return' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_unneeded_curly_braces' => true,
|
||||
'no_empty_comment' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'constant_case' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'lowercase_static_reference' => true,
|
||||
])
|
||||
->setFinder($finder);
|
||||
1
.php_cs.cache
Normal file
1
.php_cs.cache
Normal file
File diff suppressed because one or more lines are too long
2234
.phpstorm.meta.php
Normal file
2234
.phpstorm.meta.php
Normal file
File diff suppressed because it is too large
Load Diff
298
README.md
298
README.md
@@ -1,50 +1,280 @@
|
||||
## VueFileManager - Make your own Private Cloud with VueFileManager client powered by Laravel and Vue
|
||||
For installation, please read [Online Documentation](https://vuefilemanager.hi5ve.digital/docs/).
|
||||

|
||||
[](https://github.com/MakingCG/vuefilemanager/actions/workflows/build.yml)
|
||||
[](https://github.com/MakingCG/vuefilemanager/actions/workflows/unit-testing.yml)
|
||||
|
||||
**Features:**
|
||||

|
||||
# Private Cloud Storage Build on Laravel & Vue.js
|
||||
|
||||
### Drag & Drop
|
||||
Reorder your files easily, just drag your folder or file and drop to another folder.
|
||||
## Contents
|
||||
|
||||
### List & Grid Preview
|
||||
You can change from two types of file and folder previews. Show your items in list or grid preview.
|
||||
- [Installation](#installation)
|
||||
- [Server Requirements](#server-requirements)
|
||||
- [Installation](#installation)
|
||||
- [PHP Configuration](#php-configuration)
|
||||
- [Chunk Upload](#chunk-upload)
|
||||
- [Nginx Configuration](#nginx-configuration)
|
||||
- [Apache Configuration](#apache-configuration)
|
||||
- [Upgrade Guide](#upgrade-guide)
|
||||
- [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)
|
||||
- [Others](#others)
|
||||
- [Changelog](#changelog)
|
||||
- [Support](#support)
|
||||
- [Security Vulnerabilities](#security-vulnerabilities)
|
||||
|
||||
### Background Uploading
|
||||
Your files is uploaded in the background, so nothing will stop you from working with the files.
|
||||
|
||||
### File & Folder searching
|
||||
Search your items quickly, from anywhere in the app you are.
|
||||
# Installation
|
||||
## Server Requirements
|
||||
|
||||
### Custom Context Menu
|
||||
Quick actions next to your file on your right click.
|
||||
|
||||
### File Details
|
||||
Get preview of your files quickli in right panel next to your files.
|
||||
**For running app make sure you have installed:**
|
||||
|
||||
### Improved Mobile User Experience
|
||||
Need to quickly upload or get your files on your smartphone? It’s not problem.
|
||||
- PHP >= 7.3 version
|
||||
- MySQL 5.6+
|
||||
- Nginx or Apache
|
||||
|
||||
### Laravel PHP Framework
|
||||
You don't have to create your own API for VueFileManager. You can use our pre-build backend in Laravel PHP Framework.
|
||||
**These PHP Extensions are require:**
|
||||
|
||||
### Vue.js
|
||||
Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web. We ❤️ Vue.
|
||||
- GD
|
||||
- BCMath
|
||||
- PDO
|
||||
- SQLite
|
||||
- Ctype
|
||||
- Fileinfo
|
||||
- JSON
|
||||
- Mbstring
|
||||
- OpenSSL
|
||||
- Tokenizer
|
||||
- XML
|
||||
- Exif
|
||||
|
||||
### Online Documentation
|
||||
Don’t worry, we will explain all things you should know to successfully start your VueFileManager instance.
|
||||
## Installation
|
||||
|
||||
### Night Mode
|
||||
We add native support for dark mode. Now, it’s easy for your eyes to work with your files at night.
|
||||
#### 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.
|
||||
|
||||
### User Login & Registration
|
||||
Let user create their own account with own storage. All these accounts is protected by user login.
|
||||
#### 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.
|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
#### 3. Check your .env file
|
||||
Make sure `.env` file was uploaded. This type of file can be hidden in default.
|
||||
|
||||
#### 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.
|
||||
|
||||
## 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>
|
||||
```
|
||||
|
||||
## 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!
|
||||
|
||||
|
||||
# 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`.
|
||||
|
||||
## 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.
|
||||
|
||||
# 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)
|
||||
|
||||
## 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 this project, please send an e-mail to [peterpapp@makingcg.com](peterpapp@makingcg.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
### Integrated Trash
|
||||
Did you delete something by accident or do you want your deleted files back? Restore your files from trash.
|
||||
|
||||
### Navigation Sidebar
|
||||
Navigate through your files easily. Add you favourites folder or look on your latest uploads.
|
||||
|
||||
### Storage Limits
|
||||
Set storage limits to your user account to sure, you never exceed your storage limits.
|
||||
19182
_ide_helper.php
Normal file
19182
_ide_helper.php
Normal file
File diff suppressed because it is too large
Load Diff
61
app/Actions/Fortify/CreateNewUser.php
Normal file
61
app/Actions/Fortify/CreateNewUser.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use App\Models\UserSettings;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and create a newly registered user.
|
||||
*
|
||||
* @param array $input
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
public function create(array $input)
|
||||
{
|
||||
$settings = Setting::whereIn('name', ['storage_default', 'registration'])
|
||||
->pluck('value', 'name');
|
||||
|
||||
// Check if account registration is enabled
|
||||
if (! intval($settings['registration'])) {
|
||||
abort(401);
|
||||
}
|
||||
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class),
|
||||
],
|
||||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
$user = User::create([
|
||||
'email' => $input['email'],
|
||||
'password' => bcrypt($input['password']),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'name' => $input['name'],
|
||||
'storage_capacity' => $settings['storage_default'],
|
||||
]);
|
||||
|
||||
UserSettings::reguard();
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
17
app/Actions/Fortify/PasswordValidationRules.php
Normal file
17
app/Actions/Fortify/PasswordValidationRules.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use Laravel\Fortify\Rules\Password;
|
||||
|
||||
trait PasswordValidationRules
|
||||
{
|
||||
/**
|
||||
* Get the validation rules used to validate passwords.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function passwordRules()
|
||||
{
|
||||
return ['required', 'string', new Password, 'confirmed'];
|
||||
}
|
||||
}
|
||||
28
app/Actions/Fortify/ResetUserPassword.php
Normal file
28
app/Actions/Fortify/ResetUserPassword.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
||||
|
||||
class ResetUserPassword implements ResetsUserPasswords
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and reset the user's forgotten password.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function reset($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
$user->forceFill([
|
||||
'password' => bcrypt($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
35
app/Actions/Fortify/UpdateUserPassword.php
Normal file
35
app/Actions/Fortify/UpdateUserPassword.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
|
||||
|
||||
class UpdateUserPassword implements UpdatesUserPasswords
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and update the user's password.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function update($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'current_password' => ['required', 'string'],
|
||||
'password' => $this->passwordRules(),
|
||||
])->after(function ($validator) use ($user, $input) {
|
||||
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
|
||||
$validator->errors()->add('current_password', __('The provided password does not match your current password.'));
|
||||
}
|
||||
})->validateWithBag('updatePassword');
|
||||
|
||||
$user->forceFill([
|
||||
'password' => bcrypt($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
60
app/Actions/Fortify/UpdateUserProfileInformation.php
Normal file
60
app/Actions/Fortify/UpdateUserProfileInformation.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
||||
|
||||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
||||
{
|
||||
/**
|
||||
* Validate and update the given user's profile information.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function update($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique('users')->ignore($user->id),
|
||||
],
|
||||
])->validateWithBag('updateProfileInformation');
|
||||
|
||||
if ($input['email'] !== $user->email &&
|
||||
$user instanceof MustVerifyEmail) {
|
||||
$this->updateVerifiedUser($user, $input);
|
||||
} else {
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given verified user's profile information.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
protected function updateVerifiedUser($user, array $input)
|
||||
{
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'email_verified_at' => null,
|
||||
])->save();
|
||||
|
||||
$user->sendEmailVerificationNotification();
|
||||
}
|
||||
}
|
||||
889
app/Console/Commands/SetupDevEnvironment.php
Normal file
889
app/Console/Commands/SetupDevEnvironment.php
Normal file
@@ -0,0 +1,889 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Services\SetupService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
|
||||
class SetupDevEnvironment extends Command
|
||||
{
|
||||
use WithFaker;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'setup:dev';
|
||||
protected $license = 'Extended';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Set up development environment with demo data';
|
||||
|
||||
private $setup;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setUpFaker();
|
||||
$this->setup = resolve(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* return @void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Setting up development environment');
|
||||
|
||||
$this->info('Creating system directories...');
|
||||
$this->setup->create_directories();
|
||||
|
||||
$this->info('Migrating Databases...');
|
||||
$this->migrate_and_generate();
|
||||
|
||||
$this->info('Storing default settings and content...');
|
||||
$this->store_default_settings();
|
||||
$this->setup->seed_default_pages();
|
||||
$this->setup->seed_default_settings($this->license);
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->info('Creating default admin...');
|
||||
$this->create_admin();
|
||||
|
||||
$this->info('Creating demo users...');
|
||||
$this->create_demo_users();
|
||||
|
||||
$this->info('Creating default admin content...');
|
||||
$this->create_admin_default_content();
|
||||
$this->create_share_records();
|
||||
|
||||
$this->info('Clearing application cache...');
|
||||
$this->clear_cache();
|
||||
|
||||
$this->info('Dispatching jobs...');
|
||||
$this->call('queue:work', [
|
||||
'--stop-when-empty' => true,
|
||||
]);
|
||||
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default admin account
|
||||
*/
|
||||
private function create_admin(): void
|
||||
{
|
||||
$user = User::forceCreate([
|
||||
'role' => 'admin',
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'password' => bcrypt('vuefilemanager'),
|
||||
]);
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'avatar' => 'avatars/avatar-01.png',
|
||||
'storage_capacity' => 5,
|
||||
'name' => 'Jane Doe',
|
||||
'address' => $this->faker->address,
|
||||
'state' => $this->faker->state,
|
||||
'city' => $this->faker->city,
|
||||
'postal_code' => $this->faker->postcode,
|
||||
'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']),
|
||||
'phone_number' => $this->faker->phoneNumber,
|
||||
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
||||
]);
|
||||
|
||||
Storage::putFileAs('avatars', storage_path('demo/avatars/avatar-01.png'), 'avatar-01.png', 'private');
|
||||
|
||||
// Show user credentials
|
||||
$this->info('Default admin account created. Email: howdy@hi5ve.digital and Password: vuefilemanager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default admin account
|
||||
*/
|
||||
private function create_demo_users(): void
|
||||
{
|
||||
collect([
|
||||
[
|
||||
'avatar' => 'avatar-02.png',
|
||||
],
|
||||
[
|
||||
'avatar' => 'avatar-03.png',
|
||||
],
|
||||
])->each(function ($user) {
|
||||
$newbie = User::forceCreate([
|
||||
'role' => 'user',
|
||||
'email' => $this->faker->email,
|
||||
'password' => bcrypt('vuefilemanager'),
|
||||
]);
|
||||
|
||||
$newbie
|
||||
->settings()
|
||||
->create([
|
||||
'avatar' => "avatars/{$user['avatar']}",
|
||||
'storage_capacity' => 5,
|
||||
'name' => $this->faker->name,
|
||||
'address' => $this->faker->address,
|
||||
'state' => $this->faker->state,
|
||||
'city' => $this->faker->city,
|
||||
'postal_code' => $this->faker->postcode,
|
||||
'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']),
|
||||
'phone_number' => $this->faker->phoneNumber,
|
||||
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
||||
]);
|
||||
|
||||
Storage::putFileAs('avatars', storage_path("demo/avatars/{$user['avatar']}"), $user['avatar'], 'private');
|
||||
|
||||
$this->info("Generated user with email: $newbie->email and Password: vuefilemanager");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default admin content
|
||||
*/
|
||||
private function create_admin_default_content(): void
|
||||
{
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
// 1.
|
||||
$shared_folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Shared Folder',
|
||||
'emoji' => [
|
||||
'codes' => '1F680',
|
||||
'char' => '🚀',
|
||||
'name' => 'rocket',
|
||||
'category' => 'Travel & Places (transport-air)',
|
||||
'group' => 'Travel & Places',
|
||||
'subgroup' => 'transport-air',
|
||||
],
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
'type' => 'folder',
|
||||
'item_id' => $shared_folder->id,
|
||||
'user_id' => $user->id,
|
||||
'permission' => 'editor',
|
||||
'is_protected' => false,
|
||||
'password' => null,
|
||||
'expire_in' => null,
|
||||
]);
|
||||
|
||||
$peters_files = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $shared_folder->id,
|
||||
'author' => 'visitor',
|
||||
'name' => "Peter's Files",
|
||||
]);
|
||||
|
||||
// 2.
|
||||
$random_pics = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Random Pics',
|
||||
'emoji' => [
|
||||
'codes' => '1F4F7',
|
||||
'char' => '📷',
|
||||
'name' => 'camera',
|
||||
'category' => 'Objects (light & video)',
|
||||
'group' => 'Objects',
|
||||
'subgroup' => 'light & video',
|
||||
],
|
||||
'created_at' => now()->subMinutes(1),
|
||||
]);
|
||||
|
||||
$nature = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $random_pics->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Nature',
|
||||
'emoji' => [
|
||||
'codes' => '26F0',
|
||||
'char' => '⛰',
|
||||
'name' => 'mountain',
|
||||
'category' => 'Travel & Places (place-geographic)',
|
||||
'group' => 'Travel & Places',
|
||||
'subgroup' => 'place-geographic',
|
||||
],
|
||||
]);
|
||||
|
||||
$apartments = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $random_pics->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Apartments',
|
||||
'emoji' => [
|
||||
'codes' => '1F3E0',
|
||||
'char' => '🏠',
|
||||
'name' => 'house',
|
||||
'category' => 'Travel & Places (place-building)',
|
||||
'group' => 'Travel & Places',
|
||||
'subgroup' => 'place-building',
|
||||
],
|
||||
]);
|
||||
|
||||
// 3.
|
||||
$playable_media = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Playable Media',
|
||||
'created_at' => now()->subMinutes(2),
|
||||
]);
|
||||
|
||||
$video = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $playable_media->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Video',
|
||||
]);
|
||||
|
||||
$audio = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $playable_media->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Audio',
|
||||
]);
|
||||
|
||||
// 4.
|
||||
$multi_level = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Multi Level Folder',
|
||||
'created_at' => now()->subMinutes(3),
|
||||
]);
|
||||
|
||||
$first_level = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $multi_level->id,
|
||||
'author' => 'user',
|
||||
'name' => 'First Level',
|
||||
]);
|
||||
|
||||
$second_level = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $first_level->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Second Level',
|
||||
]);
|
||||
|
||||
$third_level = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $second_level->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Third Level',
|
||||
]);
|
||||
|
||||
// 5.
|
||||
$documents = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Documents',
|
||||
'created_at' => now()->subMinutes(4),
|
||||
]);
|
||||
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
'type' => 'folder',
|
||||
'item_id' => $documents->id,
|
||||
'user_id' => $user->id,
|
||||
'permission' => 'editor',
|
||||
'is_protected' => false,
|
||||
'password' => null,
|
||||
'expire_in' => null,
|
||||
]);
|
||||
|
||||
// 6.
|
||||
$videohive = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Videohive by MakingCG',
|
||||
'created_at' => now()->subMinutes(5),
|
||||
]);
|
||||
|
||||
$user
|
||||
->favouriteFolders()
|
||||
->sync([
|
||||
$shared_folder->id,
|
||||
$random_pics->id,
|
||||
$documents->id,
|
||||
$peters_files->id,
|
||||
]);
|
||||
|
||||
// Get documents to root directory
|
||||
collect([
|
||||
[
|
||||
'name' => 'Random Document',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'School Report',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Personal Savings',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'Top Secret Files',
|
||||
'basename' => 'Stories of the Night Skies.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($user) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => null,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get documents to documents folder
|
||||
collect([
|
||||
[
|
||||
'name' => 'Home Improvement',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Project Notes',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Personal Savings',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'License',
|
||||
'basename' => 'Stories of the Night Skies.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($user, $documents) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $documents->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get documents to shared folder
|
||||
collect([
|
||||
[
|
||||
'name' => 'Home plan',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Software Licence',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($user, $shared_folder) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $shared_folder->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get documents to peter's files folder
|
||||
collect([
|
||||
[
|
||||
'name' => 'Project Backup',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Yearly report',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Work Update',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'Person Writing on Notebook',
|
||||
'basename' => 'Stories of the Night Skies.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
[
|
||||
'name' => 'Blank Business Composition Computer',
|
||||
'basename' => 'Licence.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => '2020 April - Export',
|
||||
'basename' => 'Project Notes.pdf',
|
||||
'mimetype' => 'pdf',
|
||||
],
|
||||
[
|
||||
'name' => 'Ballpen Blur Close Up Computer',
|
||||
'basename' => 'School Report.pages',
|
||||
'mimetype' => 'pages',
|
||||
],
|
||||
])
|
||||
->each(function ($file) use ($user, $peters_files) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $peters_files->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file['name'],
|
||||
'basename' => $basename,
|
||||
'type' => 'file',
|
||||
'author' => 'visitor',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get videos
|
||||
collect([
|
||||
'Apple Watch App Video Promotion.mp4',
|
||||
'Professional 3D Device Pack for Element 3D.mp4',
|
||||
'Smart Watch 3D Device Pack for Element 3D.mp4',
|
||||
'Sphere Bound 3D Titles.mp4',
|
||||
])
|
||||
->each(function ($file) use ($user, $videohive) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $videohive->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'video',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp4',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get video into video folder
|
||||
collect([
|
||||
'Apple Watch App Video Promotion.mp4',
|
||||
])
|
||||
->each(function ($file) use ($user, $video) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $video->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'video',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp4',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get audios
|
||||
collect([
|
||||
'D-Block & S-te-Fan - Bla Bla.mp3',
|
||||
])
|
||||
->each(function ($file) use ($user, $audio) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/audio/$file"), $basename, 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $audio->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'audio',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp3',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'Eggcited bro.jpg',
|
||||
'Get a Rest.jpg',
|
||||
'Get Your Shit Together.jpg',
|
||||
'Happiness is when you are right beside me.jpg',
|
||||
'Have a Nice Day.jpg',
|
||||
'It Works On My Machine.jpg',
|
||||
'I am Just Trying to shine.jpg',
|
||||
'It Works On My Machine.jpg',
|
||||
'Missing you It is Pig Time.jpg',
|
||||
'Sofishticated.jpg',
|
||||
'whaaaaat.jpg',
|
||||
'You Are My Sunshine.jpg',
|
||||
])
|
||||
->each(function ($file) use ($user) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/$file"), $basename, 'private');
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/thumbnail-$file"), "thumbnail-$basename", 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => null,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'image',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => "thumbnail-$basename",
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get apartments gallery
|
||||
collect([
|
||||
'Apartment Architecture Ceiling Chairs.jpg',
|
||||
'Apartment Chair.jpg',
|
||||
'Apartment Contemporary Couch Curtains.jpg',
|
||||
'Brown Wooden Center Table.jpg',
|
||||
'Home.jpg',
|
||||
'Kitchen Appliances.jpg',
|
||||
'Kitchen Island.jpg',
|
||||
])
|
||||
->each(function ($file) use ($user, $apartments) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/$file"), $basename, 'private');
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/thumbnail-$file"), "thumbnail-$basename", 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $apartments->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'image',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => "thumbnail-$basename",
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get nature gallery
|
||||
collect([
|
||||
'Bird Patterncolorful Green.jpg',
|
||||
'Close Up Of Peacock.jpg',
|
||||
'Close Up Photography Of Tiger.jpg',
|
||||
'Cold Nature Cute Ice.jpg',
|
||||
'Landscape Photo of Forest.jpg',
|
||||
'Photo of Hawksbill Sea Turtle.jpg',
|
||||
'Photo Of Reindeer in The Snow.jpg',
|
||||
'View Of Elephant in Water.jpg',
|
||||
'Waterfall Between Trees.jpg',
|
||||
'Wildlife Photography of Elephant During Golden Hour.jpg',
|
||||
'Yellow Animal Eyes Fur.jpg',
|
||||
])
|
||||
->each(function ($file) use ($user, $nature) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/$file"), $basename, 'private');
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/thumbnail-$file"), "thumbnail-$basename", 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'folder_id' => $nature->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'image',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => "thumbnail-$basename",
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
private function create_share_records(): void
|
||||
{
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$images = File::whereType('image')
|
||||
->whereFolderId(null)
|
||||
->take(3)
|
||||
->pluck('id');
|
||||
|
||||
$images->each(function ($id) use ($user) {
|
||||
Share::create([
|
||||
'user_id' => $user->id,
|
||||
'item_id' => $id,
|
||||
'type' => 'file',
|
||||
'is_protected' => false,
|
||||
'permission' => 'editor',
|
||||
'password' => null,
|
||||
'expire_in' => null,
|
||||
]);
|
||||
});
|
||||
|
||||
$files = File::whereType('file')
|
||||
->whereFolderId(null)
|
||||
->take(2)
|
||||
->pluck('id');
|
||||
|
||||
$files->each(function ($id) use ($user) {
|
||||
Share::create([
|
||||
'user_id' => $user->id,
|
||||
'item_id' => $id,
|
||||
'type' => 'file',
|
||||
'is_protected' => false,
|
||||
'permission' => 'editor',
|
||||
'password' => null,
|
||||
'expire_in' => null,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Store main app settings into database
|
||||
*/
|
||||
private function store_default_settings(): void
|
||||
{
|
||||
// Get options
|
||||
collect([
|
||||
[
|
||||
'name' => 'setup_wizard_database',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => 'VueFileManager',
|
||||
],
|
||||
[
|
||||
'name' => 'app_description',
|
||||
'value' => 'Your self-hosted storage cloud software powered by Laravel and Vue',
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo',
|
||||
'value' => 'system/logo.svg',
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo_horizontal',
|
||||
'value' => 'system/logo-horizontal.svg',
|
||||
],
|
||||
[
|
||||
'name' => 'app_favicon',
|
||||
'value' => 'system/favicon.png',
|
||||
],
|
||||
[
|
||||
'name' => 'app_og_image',
|
||||
'value' => 'system/og-image.jpg',
|
||||
],
|
||||
[
|
||||
'name' => 'app_touch_icon',
|
||||
'value' => 'system/touch-icon.png',
|
||||
],
|
||||
[
|
||||
'name' => 'google_analytics',
|
||||
'value' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'contact_email',
|
||||
'value' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'registration',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_default',
|
||||
'value' => 5,
|
||||
],
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $this->license,
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => '26b889eb-3602-4bf2-beb3-3sc378fcf484',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_address',
|
||||
'value' => 'Palo Alto 20',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_city',
|
||||
'value' => 'Palo Alto',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_country',
|
||||
'value' => 'US',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_name',
|
||||
'value' => 'VueFileManager Inc.',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_phone_number',
|
||||
'value' => '312343141243214',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_postal_code',
|
||||
'value' => '43213',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_state',
|
||||
'value' => 'California',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_vat_number',
|
||||
'value' => '41241241234',
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Get system images
|
||||
collect(['logo.svg', 'logo-horizontal.svg', 'favicon.png', 'og-image.jpg', 'touch-icon.png'])
|
||||
->each(function ($file) {
|
||||
Storage::putFileAs('system', storage_path("demo/app/$file"), $file, 'private');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate database and generate application keys
|
||||
*/
|
||||
private function migrate_and_generate(): void
|
||||
{
|
||||
// Migrate database
|
||||
$this->call('migrate:fresh', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
// Generate app key
|
||||
$this->call('key:generate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear app cache
|
||||
*/
|
||||
private function clear_cache(): void
|
||||
{
|
||||
$this->call('cache:clear');
|
||||
$this->call('config:clear');
|
||||
$this->call('view:clear');
|
||||
}
|
||||
}
|
||||
100
app/Console/Commands/SetupOasisEnvironment.php
Normal file
100
app/Console/Commands/SetupOasisEnvironment.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SetupOasisEnvironment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'setup:oasis';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Setup Oasis demo content';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Setting up Oasis environment');
|
||||
|
||||
$this->set_oasis_data();
|
||||
|
||||
$this->info('Dispatching jobs...');
|
||||
$this->call('queue:work', [
|
||||
'--stop-when-empty' => true,
|
||||
]);
|
||||
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
public function set_oasis_data()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'app_color',
|
||||
], [
|
||||
'value' => '#ae5fec',
|
||||
]);
|
||||
|
||||
// Get system images
|
||||
collect(['logo.png', 'logo-horizontal.png', 'favicon.png', 'oasis-og-image.jpg'])
|
||||
->each(function ($file) {
|
||||
Storage::putFileAs('system', storage_path("demo/oasis/$file"), $file, 'private');
|
||||
});
|
||||
|
||||
collect([
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => 'Oasis',
|
||||
],
|
||||
[
|
||||
'name' => 'app_description',
|
||||
'value' => 'Chytrý, bezpečný, pohodlný šanon vždy s Vámi.',
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo',
|
||||
'value' => 'system/logo.png',
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo_horizontal',
|
||||
'value' => 'system/logo-horizontal.png',
|
||||
],
|
||||
[
|
||||
'name' => 'app_favicon',
|
||||
'value' => 'system/favicon.png',
|
||||
],
|
||||
[
|
||||
'name' => 'app_og_image',
|
||||
'value' => 'system/oasis-og-image.jpg',
|
||||
],
|
||||
])->each(function ($option) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $option['name'],
|
||||
], [
|
||||
'value' => $option['value'],
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
222
app/Console/Commands/SetupProdEnvironment.php
Normal file
222
app/Console/Commands/SetupProdEnvironment.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use App\Services\SetupService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SetupProdEnvironment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'setup:prod';
|
||||
protected $license = 'Extended';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Set up production environment';
|
||||
|
||||
private $setup;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = resolve(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Setting up production environment');
|
||||
|
||||
$this->info('Creating system directories...');
|
||||
$this->setup->create_directories();
|
||||
|
||||
$this->info('Migrating Databases...');
|
||||
$this->migrate_and_generate();
|
||||
|
||||
$this->info('Storing default settings and content...');
|
||||
$this->store_default_settings();
|
||||
$this->setup->seed_default_pages();
|
||||
$this->setup->seed_default_settings($this->license);
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->info('Creating default admin...');
|
||||
$this->create_admin();
|
||||
|
||||
$this->info('Clearing application cache...');
|
||||
$this->clear_cache();
|
||||
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store main app settings into database
|
||||
*/
|
||||
private function store_default_settings(): void
|
||||
{
|
||||
// Get options
|
||||
collect([
|
||||
[
|
||||
'name' => 'setup_wizard_database',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => 'VueFileManager',
|
||||
],
|
||||
[
|
||||
'name' => 'app_description',
|
||||
'value' => 'Your self-hosted storage cloud software powered by Laravel and Vue',
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo_horizontal',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_favicon',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_og_image',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'app_touch_icon',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'google_analytics',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'contact_email',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'registration',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_limitation',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'storage_default',
|
||||
'value' => 5,
|
||||
],
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $this->license,
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => '26b889eb-3602-4bf2-beb3-3sc378fcf484',
|
||||
],
|
||||
[
|
||||
'name' => 'billing_address',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_city',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_country',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_name',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_phone_number',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_postal_code',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_state',
|
||||
'value' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'billing_vat_number',
|
||||
'value' => null,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default admin account
|
||||
*/
|
||||
private function create_admin(): void
|
||||
{
|
||||
$user = User::forceCreate([
|
||||
'role' => 'admin',
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'password' => bcrypt('vuefilemanager'),
|
||||
]);
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'storage_capacity' => 5,
|
||||
'name' => 'Admin',
|
||||
]);
|
||||
|
||||
// Show user credentials
|
||||
$this->info('Default admin account created. Email: howdy@hi5ve.digital and Password: vuefilemanager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate database and generate application keys
|
||||
*/
|
||||
private function migrate_and_generate(): void
|
||||
{
|
||||
// Migrate database
|
||||
$this->call('migrate:fresh', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
// Generate app key
|
||||
$this->call('key:generate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear app cache
|
||||
*/
|
||||
private function clear_cache(): void
|
||||
{
|
||||
$this->call('cache:clear');
|
||||
$this->call('config:clear');
|
||||
$this->call('view:clear');
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Services\SchedulerService;
|
||||
use App\Services\Oasis\OasisService;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProdEnvironment;
|
||||
use App\Console\Commands\SetupOasisEnvironment;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
@@ -13,19 +17,50 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
SetupDevEnvironment::class,
|
||||
SetupProdEnvironment::class,
|
||||
SetupOasisEnvironment::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();
|
||||
$scheduler = resolve(SchedulerService::class);
|
||||
|
||||
$schedule->call(function () use ($scheduler) {
|
||||
$scheduler->delete_expired_shared_links();
|
||||
})->everyTenMinutes();
|
||||
|
||||
$schedule->call(function () use ($scheduler) {
|
||||
$scheduler->delete_old_zips();
|
||||
|
||||
if (! is_storage_driver(['local'])) {
|
||||
$scheduler->delete_failed_files();
|
||||
}
|
||||
})->everySixHours();
|
||||
|
||||
// Oasis Drive
|
||||
$schedule->call(function () {
|
||||
resolve(OasisService::class)->order_reminder();
|
||||
})->hourly();
|
||||
|
||||
// Run queue jobs every minute
|
||||
$schedule->command('queue:work --stop-when-empty')
|
||||
->everyMinute()
|
||||
->withoutOverlapping();
|
||||
|
||||
// Backup app database daily
|
||||
$schedule->command('backup:clean')
|
||||
->daily()
|
||||
->at('01:00');
|
||||
$schedule->command('backup:run --only-db')
|
||||
->daily()
|
||||
->at('01:30');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +70,7 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -13,7 +13,6 @@ class Handler extends ExceptionHandler
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -29,12 +28,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 +42,18 @@ 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)
|
||||
{
|
||||
if ($exception instanceof ModelNotFoundException) {
|
||||
return response()
|
||||
->redirectTo('/not-found')->setStatusCode(404);
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use \Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
|
||||
|
||||
class FileManagerFile extends Model
|
||||
{
|
||||
use Searchable, SoftDeletes, SoftCascadeTrait;
|
||||
|
||||
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'file_url'
|
||||
];
|
||||
|
||||
/**
|
||||
* Format created at date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreatedAtAttribute()
|
||||
{
|
||||
return format_date($this->attributes['created_at'], __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form\a\t created at date reformat
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeletedAtAttribute()
|
||||
{
|
||||
if (! $this->attributes['deleted_at']) return null;
|
||||
|
||||
return format_date($this->attributes['deleted_at'], __('vuefilemanager.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format filesize
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getFilesizeAttribute()
|
||||
{
|
||||
return Metric::bytes($this->attributes['filesize'])->format();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format thumbnail url
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getThumbnailAttribute()
|
||||
{
|
||||
return $this->attributes['thumbnail'] ? route('thumbnail', ['name' => $this->attributes['thumbnail']]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format file url
|
||||
*
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getFileUrlAttribute()
|
||||
{
|
||||
return route('file', ['name' => $this->attributes['basename']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index file
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toSearchableArray()
|
||||
{
|
||||
$array = $this->toArray();
|
||||
$name = Str::slug($array['name'], ' ');
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $name,
|
||||
'nameNgrams' => utf8_encode((new TNTIndexer)->buildTrigrams(implode(', ', [$name]))),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo('App\FileManagerFolder', 'folder_id', 'unique_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get folder
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function folder()
|
||||
{
|
||||
return $this->hasOne('App\FileManagerFolder', 'unique_id', 'folder_id');
|
||||
}
|
||||
}
|
||||
57
app/Http/Controllers/Admin/DashboardController.php
Normal file
57
app/Http/Controllers/Admin/DashboardController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use ByteUnits\Metric;
|
||||
use App\Services\StripeService;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
private StripeService $stripe;
|
||||
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for dashboard
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Get total premium users
|
||||
$premium_users = Subscription::whereStripeStatus('active')
|
||||
->count();
|
||||
|
||||
// Get total storage usage
|
||||
$storage_usage = Metric::bytes(
|
||||
\DB::table('files')->sum('filesize')
|
||||
)->format();
|
||||
|
||||
return [
|
||||
'license' => get_setting('license'),
|
||||
'app_version' => config('vuefilemanager.version'),
|
||||
'total_users' => User::count(),
|
||||
'total_used_space' => $storage_usage,
|
||||
'total_premium_users' => $premium_users,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the newest users
|
||||
*
|
||||
* @return UsersCollection
|
||||
*/
|
||||
public function newbies()
|
||||
{
|
||||
return new UsersCollection(
|
||||
User::sortable(['created_at' => 'desc'])
|
||||
->paginate(10)
|
||||
);
|
||||
}
|
||||
}
|
||||
44
app/Http/Controllers/Admin/InvoiceController.php
Normal file
44
app/Http/Controllers/Admin/InvoiceController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Http\Resources\InvoiceAdminCollection;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
private StripeService $stripe;
|
||||
|
||||
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 invoice $token
|
||||
*
|
||||
* @param $customer
|
||||
* @param $token
|
||||
* @return InvoiceResource|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show($customer, $token)
|
||||
{
|
||||
return view('vuefilemanager.invoice')
|
||||
->with('settings', get_settings_in_json())
|
||||
->with('invoice', $this->stripe->getUserInvoice($customer, $token));
|
||||
}
|
||||
}
|
||||
138
app/Http/Controllers/Admin/LanguageController.php
Normal file
138
app/Http/Controllers/Admin/LanguageController.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\LanguageResource;
|
||||
use App\Http\Resources\LanguageCollection;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\Languages\UpdateStringRequest;
|
||||
use App\Http\Requests\Languages\CreateLanguageRequest;
|
||||
use App\Http\Requests\Languages\UpdateLanguageRequest;
|
||||
|
||||
class LanguageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all languages for admin translate
|
||||
*
|
||||
* @return array|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function get_languages()
|
||||
{
|
||||
return response(
|
||||
new LanguageCollection(Language::sortable(['created_at', 'DESC'])->get()),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all language strings for admin translate
|
||||
*
|
||||
* @param Language $language
|
||||
*/
|
||||
public function get_language(Language $language)
|
||||
{
|
||||
return response(
|
||||
new LanguageResource($language),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new language
|
||||
*
|
||||
* @param CreateLanguageRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function create_language(CreateLanguageRequest $request)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language = Language::create([
|
||||
'name' => $request->input('name'),
|
||||
'locale' => $request->input('locale'),
|
||||
]);
|
||||
|
||||
return response(
|
||||
new LanguageResource($language),
|
||||
201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update language
|
||||
*
|
||||
* @param UpdateLanguageRequest $request
|
||||
* @param Language $language
|
||||
*/
|
||||
public function update_language(UpdateLanguageRequest $request, Language $language)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language->update(make_single_input($request));
|
||||
|
||||
return response(
|
||||
new LanguageResource($language),
|
||||
201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update string for language
|
||||
*
|
||||
* @param UpdateStringRequest $request
|
||||
* @param Language $language
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function update_string(UpdateStringRequest $request, Language $language)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language
|
||||
->languageTranslations()
|
||||
->where('key', $request->name)
|
||||
->update([
|
||||
'value' => $request->value,
|
||||
]);
|
||||
|
||||
cache()->forget("language-translations-{$language->locale}");
|
||||
|
||||
return response(
|
||||
'Done',
|
||||
204
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the language with all children strings
|
||||
* @param Language $language
|
||||
* @return Response
|
||||
*/
|
||||
public function delete_language(Language $language): Response
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
abort_if($language->locale === 'en', 401, "Sorry, you can't delete default language.");
|
||||
|
||||
// If user try to delete language used as default,
|
||||
// then set en language as default
|
||||
if ($language->locale === get_setting('language')) {
|
||||
Setting::whereName('language')->first()
|
||||
->update(['value' => 'en']);
|
||||
}
|
||||
|
||||
$language->delete();
|
||||
|
||||
return response(
|
||||
'Done',
|
||||
204
|
||||
);
|
||||
}
|
||||
}
|
||||
64
app/Http/Controllers/Admin/PagesController.php
Normal file
64
app/Http/Controllers/Admin/PagesController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Page;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PageResource;
|
||||
use App\Http\Resources\PageCollection;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class PagesController extends Controller
|
||||
{
|
||||
private $demo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all pages
|
||||
*
|
||||
* @return PageCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new PageCollection(
|
||||
Page::sortable()
|
||||
->paginate(10)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single page resource
|
||||
*
|
||||
* @param $page
|
||||
* @return PageResource
|
||||
*/
|
||||
public function show(Page $page)
|
||||
{
|
||||
return new PageResource($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update page content
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Page $page
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function update(Request $request, Page $page)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$page->update(
|
||||
make_single_input($request)
|
||||
);
|
||||
|
||||
return response(new PageResource($page), 204);
|
||||
}
|
||||
}
|
||||
158
app/Http/Controllers/Admin/PlanController.php
Normal file
158
app/Http/Controllers/Admin/PlanController.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PlanResource;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Http\Resources\PlanCollection;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
private StripeService $stripe;
|
||||
|
||||
private DemoService $demo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->stripe = resolve(StripeService::class);
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plans
|
||||
*
|
||||
* @return PlanCollection|Application|ResponseFactory|Response
|
||||
*/
|
||||
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 response(new PlanCollection($plans), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plan record
|
||||
*
|
||||
* @param $id
|
||||
* @return PlanResource|Application|ResponseFactory|Response
|
||||
*/
|
||||
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 response(new PlanResource($plan), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new plan
|
||||
*
|
||||
* @param Request $request
|
||||
* @return PlanResource|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// TODO: inline request
|
||||
if (is_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 response($plan, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update plan attribute
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Update plan
|
||||
$this->stripe->updatePlan($request, $id);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing', 'plan-' . $id]);
|
||||
|
||||
return response('Saved!', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete plan
|
||||
*
|
||||
* @param $id
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// 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::whereStripePlan($id)
|
||||
->pluck('user_id');
|
||||
|
||||
return new UsersCollection(
|
||||
User::sortable()
|
||||
->findMany($subscribers)
|
||||
);
|
||||
}
|
||||
}
|
||||
182
app/Http/Controllers/Admin/SettingController.php
Normal file
182
app/Http/Controllers/Admin/SettingController.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Stripe;
|
||||
use Artisan;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
private $demo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table content
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
if (strpos($request->column, '|') !== false) {
|
||||
$columns = explode('|', $request->column);
|
||||
|
||||
return Setting::whereIn('name', $columns)
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
|
||||
return Setting::where('name', $request->column)
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Store image if exist
|
||||
if ($request->hasFile($request->name)) {
|
||||
// Find and update image path
|
||||
Setting::updateOrCreate([
|
||||
'name' => $request->name,
|
||||
], [
|
||||
'value' => store_system_image($request, $request->name),
|
||||
]);
|
||||
|
||||
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)
|
||||
{
|
||||
// TODO: pridat validator do requestu
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
setEnvironmentValue([
|
||||
'MAIL_DRIVER' => $request->driver,
|
||||
'MAIL_HOST' => $request->host,
|
||||
'MAIL_PORT' => $request->port,
|
||||
'MAIL_USERNAME' => $request->username,
|
||||
'MAIL_PASSWORD' => $request->password,
|
||||
'MAIL_ENCRYPTION' => $request->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)
|
||||
{
|
||||
// TODO: pridat validator do requestu
|
||||
// Check payment setup status
|
||||
if (get_setting('payments_configured')) {
|
||||
abort(401, 'Gone');
|
||||
}
|
||||
|
||||
// Try to get stripe account details
|
||||
try {
|
||||
if (! app()->runningUnitTests()) {
|
||||
Stripe::make($request->secret, '2020-03-02')
|
||||
->account()
|
||||
->details();
|
||||
}
|
||||
} catch (UnauthorizedException $e) {
|
||||
throw new HttpException(401, $e->getMessage());
|
||||
}
|
||||
|
||||
// Get options
|
||||
collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
// 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');
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear application cache
|
||||
*/
|
||||
public function flush_cache()
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
230
app/Http/Controllers/Admin/UserController.php
Normal file
230
app/Http/Controllers/Admin/UserController.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Storage;
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use App\Http\Requests\Admin\ChangeRoleRequest;
|
||||
use App\Http\Requests\Admin\CreateUserByAdmin;
|
||||
use App\Http\Requests\Admin\DeleteUserRequest;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\Admin\ChangeStorageCapacityRequest;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
private StripeService $stripe;
|
||||
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user details
|
||||
*
|
||||
* @param User $user
|
||||
* @return UserResource
|
||||
*/
|
||||
public function details(User $user)
|
||||
{
|
||||
return new UserResource(
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @param User $user
|
||||
* @return UserStorageResource
|
||||
*/
|
||||
public function storage(User $user)
|
||||
{
|
||||
return new UserStorageResource(
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @param User $user
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function invoices(User $user)
|
||||
{
|
||||
return new InvoiceCollection(
|
||||
$this
|
||||
->stripe
|
||||
->getUserInvoices($user)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user subscription details
|
||||
*
|
||||
* @param User $user
|
||||
* @return UserSubscription|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function subscription(User $user)
|
||||
{
|
||||
if (! $user->stripeId() || ! $user->subscription('main')) {
|
||||
return response("User doesn't have any subscription.", 404);
|
||||
}
|
||||
|
||||
return new UserSubscription(
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 User $user
|
||||
* @return UserResource
|
||||
*/
|
||||
public function change_role(ChangeRoleRequest $request, User $user)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_demo_account('howdy@hi5ve.digial')) {
|
||||
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 User $user
|
||||
* @return UserStorageResource
|
||||
*/
|
||||
public function change_storage_capacity(ChangeStorageCapacityRequest $request, User $user)
|
||||
{
|
||||
$user
|
||||
->settings()
|
||||
->update(
|
||||
$request->input('attributes')
|
||||
);
|
||||
|
||||
return new UserStorageResource(
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send user password reset link
|
||||
*
|
||||
* @param User $user
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function reset_password(User $user)
|
||||
{
|
||||
// Demo preview
|
||||
if (is_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|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function create_user(CreateUserByAdmin $request)
|
||||
{
|
||||
// Create user
|
||||
$user = User::forceCreate([
|
||||
'role' => $request->role,
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'name' => $request->name,
|
||||
'avatar' => store_avatar($request, 'avatar'),
|
||||
'storage_capacity' => $request->storage_capacity,
|
||||
]);
|
||||
|
||||
UserSettings::reguard();
|
||||
|
||||
return response(new UserResource($user), 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user with all user data
|
||||
*
|
||||
* @param DeleteUserRequest $request
|
||||
* @param User $user
|
||||
* @return ResponseFactory|Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete_user(DeleteUserRequest $request, User $user)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
if ($user->subscribed('main')) {
|
||||
abort(202, "You can\'t delete this account while user have active subscription.");
|
||||
}
|
||||
|
||||
if ($user->id === Auth::id()) {
|
||||
abort(406, "You can\'t delete your account");
|
||||
}
|
||||
|
||||
if ($user->settings->name !== $request->name) {
|
||||
abort(403, 'The name you typed is wrong!');
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
202
app/Http/Controllers/App/AppFunctionsController.php
Normal file
202
app/Http/Controllers/App/AppFunctionsController.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\App;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\Share;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PageResource;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Mail\SendContactMessage;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use App\Http\Resources\PricingCollection;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use App\Http\Requests\PublicPages\SendContactMessageRequest;
|
||||
|
||||
class AppFunctionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* List of allowed settings to get from public request
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $blacklist = [
|
||||
'purchase_code',
|
||||
'license',
|
||||
];
|
||||
|
||||
private StripeService $stripe;
|
||||
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
// Try to connect to database
|
||||
\DB::getPdo();
|
||||
|
||||
// Get setup status
|
||||
$setup_status = get_setup_status();
|
||||
|
||||
// Get app pages
|
||||
$pages = Page::all();
|
||||
|
||||
// Get all settings
|
||||
$settings = get_settings_in_json();
|
||||
} catch (PDOException $e) {
|
||||
$setup_status = 'setup-database';
|
||||
}
|
||||
|
||||
return view('index')
|
||||
->with('settings', $settings ?? null)
|
||||
->with('legal', $pages ?? null)
|
||||
->with('installation', $setup_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get og site for web crawlers
|
||||
*
|
||||
* @param Share $shared
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function og_site(Share $shared)
|
||||
{
|
||||
// Get file/folder record
|
||||
$item = ('App\\Models\\' . ucfirst($shared->type))
|
||||
::where('user_id', $shared->user->id)
|
||||
->where('id', $shared->item_id)
|
||||
->first();
|
||||
|
||||
if ($item->thumbnail) {
|
||||
$item->setPublicUrl($shared->token);
|
||||
}
|
||||
|
||||
return view('vuefilemanager.crawler.og-view')
|
||||
->with('settings', get_settings_in_json())
|
||||
->with('metadata', [
|
||||
'url' => url('/share', ['token' => $shared->token]),
|
||||
'is_protected' => $shared->is_protected,
|
||||
'user' => $shared->user->settings->name,
|
||||
'name' => $item->name,
|
||||
'size' => $shared->type === 'folder'
|
||||
? $item->items
|
||||
: $item->filesize,
|
||||
'thumbnail' => $item->thumbnail ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contact message from pages
|
||||
*
|
||||
* @param SendContactMessageRequest $request
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function contact_form(SendContactMessageRequest $request)
|
||||
{
|
||||
Mail::to(
|
||||
get_setting('contact_email')
|
||||
)->send(
|
||||
new SendContactMessage($request->all())
|
||||
);
|
||||
|
||||
return response('Done', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single page content
|
||||
*
|
||||
* @param Page $page
|
||||
* @return PageResource
|
||||
*/
|
||||
public function get_page(Page $page)
|
||||
{
|
||||
return new PageResource($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected settings from public route
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_setting_columns(Request $request)
|
||||
{
|
||||
if (strpos($request->column, '|') !== false) {
|
||||
$columns = collect(explode('|', $request->column))
|
||||
->each(function ($column) {
|
||||
if (in_array($column, $this->blacklist)) {
|
||||
abort(401);
|
||||
}
|
||||
});
|
||||
|
||||
return Setting::whereIn('name', $columns)
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
|
||||
if (in_array($request->column, $this->blacklist)) {
|
||||
abort(401);
|
||||
}
|
||||
|
||||
return Setting::where('name', $request->column)
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active storage plans
|
||||
*
|
||||
* @return PricingCollection
|
||||
*/
|
||||
public function get_storage_plans()
|
||||
{
|
||||
// Get pricing from 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language translations for frontend app
|
||||
*/
|
||||
public function get_translations($lang)
|
||||
{
|
||||
$translations = cache()
|
||||
->rememberForever("language-translations-$lang", function () use ($lang) {
|
||||
try {
|
||||
return Language::whereLocale($lang)
|
||||
->firstOrFail()
|
||||
->languageTranslations;
|
||||
} catch (QueryException | ModelNotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return $translations
|
||||
? map_language_translations($translations)
|
||||
: get_default_language_translations();
|
||||
}
|
||||
}
|
||||
84
app/Http/Controllers/App/Maintenance.php
Normal file
84
app/Http/Controllers/App/Maintenance.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\App;
|
||||
|
||||
use Gate;
|
||||
use Artisan;
|
||||
use App\Models\Language;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\LanguageService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class Maintenance extends Controller
|
||||
{
|
||||
/**
|
||||
* Start maintenance mode
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('up');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in production mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End maintenance mode
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('down');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in maintenance mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get new language translations from default translations
|
||||
* and insert it into database
|
||||
*
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function upgrade_translations()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
resolve(LanguageService::class)
|
||||
->upgrade_language_translations();
|
||||
|
||||
return response('Done.', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function upgrade_database()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('migrate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'Operation was successful.';
|
||||
}
|
||||
|
||||
if ($command === 1) {
|
||||
echo 'Operation failed.';
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
}
|
||||
479
app/Http/Controllers/App/SetupWizardController.php
Normal file
479
app/Http/Controllers/App/SetupWizardController.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\App;
|
||||
|
||||
use Schema;
|
||||
use Stripe;
|
||||
use Artisan;
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\SetupService;
|
||||
use App\Services\StripeService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use App\Http\Requests\SetupWizard\StoreAppSetupRequest;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use App\Http\Requests\SetupWizard\StoreStripePlansRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeBillingRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreEnvironmentSetupRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeCredentialsRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreDatabaseCredentialsRequest;
|
||||
|
||||
class SetupWizardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Inject Stripe Service
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->stripe = resolve(StripeService::class);
|
||||
$this->setup = resolve(SetupService::class);
|
||||
|
||||
$this->check_setup_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Envato purchase code
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response|mixed
|
||||
*/
|
||||
public function verify_purchase_code(Request $request)
|
||||
{
|
||||
// Verify purchase code
|
||||
$response = Http::get('https://verify.vuefilemanager.com/api/verify-code/' . $request->purchaseCode);
|
||||
|
||||
if ($response->successful()) {
|
||||
return response($response, 204);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (! app()->runningUnitTests()) {
|
||||
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());
|
||||
}
|
||||
|
||||
// TODO: add SANCTUM_STATEFUL_DOMAINS parameter
|
||||
|
||||
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,
|
||||
]);
|
||||
|
||||
Artisan::call('config:cache');
|
||||
|
||||
Artisan::call('key:generate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
Artisan::call('migrate:fresh', [
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
// Store setup wizard progress
|
||||
Setting::forceCreate([
|
||||
'name' => 'setup_wizard_database',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store and test stripe credentials
|
||||
*
|
||||
* @param StoreStripeCredentialsRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_stripe_credentials(StoreStripeCredentialsRequest $request)
|
||||
{
|
||||
if (! app()->runningUnitTests()) {
|
||||
// Create stripe instance
|
||||
$stripe = Stripe::make($request->secret, '2020-03-02');
|
||||
|
||||
try {
|
||||
// Try to get stripe account details
|
||||
$stripe->account()->details();
|
||||
} catch (UnauthorizedException $e) {
|
||||
throw new HttpException(401, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Set settings
|
||||
collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
// 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', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Stripe billings
|
||||
*
|
||||
* @param StoreStripeBillingRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_stripe_billings(StoreStripeBillingRequest $request)
|
||||
{
|
||||
// Get options
|
||||
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,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Stripe subscription plan
|
||||
*
|
||||
* @param StoreStripePlansRequest $request
|
||||
* @return \Illuminate\Contracts\Foundation\Application|ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_stripe_plans(StoreStripePlansRequest $request)
|
||||
{
|
||||
foreach ($request->plans as $plan) {
|
||||
$this->stripe->createPlan($plan);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store environment setup
|
||||
*
|
||||
* @param StoreEnvironmentSetupRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function store_environment_setup(StoreEnvironmentSetupRequest $request)
|
||||
{
|
||||
if (! app()->runningUnitTests()) {
|
||||
$drivers = [
|
||||
'local' => [
|
||||
'FILESYSTEM_DRIVER' => 'local',
|
||||
],
|
||||
's3' => [
|
||||
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
|
||||
'AWS_ACCESS_KEY_ID' => $request->storage['key'] ?? null,
|
||||
'AWS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null,
|
||||
'AWS_DEFAULT_REGION' => $request->storage['region'] ?? null,
|
||||
'AWS_BUCKET' => $request->storage['bucket'] ?? null,
|
||||
],
|
||||
'spaces' => [
|
||||
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
|
||||
'DO_SPACES_KEY' => $request->storage['key'] ?? null,
|
||||
'DO_SPACES_SECRET' => $request->storage['secret'] ?? null,
|
||||
'DO_SPACES_ENDPOINT' => $request->storage['endpoint'] ?? null,
|
||||
'DO_SPACES_REGION' => $request->storage['region'] ?? null,
|
||||
'DO_SPACES_BUCKET' => $request->storage['bucket'] ?? null,
|
||||
],
|
||||
'wasabi' => [
|
||||
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
|
||||
'WASABI_KEY' => $request->storage['key'] ?? null,
|
||||
'WASABI_SECRET' => $request->storage['secret'] ?? null,
|
||||
'WASABI_ENDPOINT' => $request->storage['endpoint'] ?? null,
|
||||
'WASABI_REGION' => $request->storage['region'] ?? null,
|
||||
'WASABI_BUCKET' => $request->storage['bucket'] ?? null,
|
||||
],
|
||||
'backblaze' => [
|
||||
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
|
||||
'BACKBLAZE_KEY' => $request->storage['key'] ?? null,
|
||||
'BACKBLAZE_SECRET' => $request->storage['secret'] ?? null,
|
||||
'BACKBLAZE_ENDPOINT' => $request->storage['endpoint'] ?? null,
|
||||
'BACKBLAZE_REGION' => $request->storage['region'] ?? null,
|
||||
'BACKBLAZE_BUCKET' => $request->storage['bucket'] ?? null,
|
||||
],
|
||||
'oss' => [
|
||||
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
|
||||
'OSS_ACCESS_KEY_ID' => $request->storage['key'] ?? null,
|
||||
'OSS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null,
|
||||
'OSS_ENDPOINT' => $request->storage['endpoint'] ?? null,
|
||||
'OSS_REGION' => $request->storage['region'] ?? null,
|
||||
'OSS_BUCKET' => $request->storage['bucket'] ?? null,
|
||||
],
|
||||
];
|
||||
|
||||
// Storage credentials for storage
|
||||
setEnvironmentValue(
|
||||
$drivers[$request->storage['driver']]
|
||||
);
|
||||
|
||||
// Store credentials for mail
|
||||
// TODO: add options for mailgun
|
||||
setEnvironmentValue([
|
||||
'MAIL_DRIVER' => $request->mail['driver'],
|
||||
'MAIL_HOST' => $request->mail['host'],
|
||||
'MAIL_PORT' => $request->mail['port'],
|
||||
'MAIL_USERNAME' => $request->mail['username'],
|
||||
'MAIL_PASSWORD' => $request->mail['password'],
|
||||
'MAIL_ENCRYPTION' => $request->mail['encryption'],
|
||||
]);
|
||||
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store app settings
|
||||
* @param StoreAppSetupRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store_app_settings(StoreAppSetupRequest $request)
|
||||
{
|
||||
// Get options
|
||||
collect([
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => $request->title,
|
||||
],
|
||||
[
|
||||
'name' => 'app_description',
|
||||
'value' => $request->description,
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo',
|
||||
'value' => store_system_image($request, 'logo'),
|
||||
],
|
||||
[
|
||||
'name' => 'app_logo_horizontal',
|
||||
'value' => store_system_image($request, 'logo_horizontal'),
|
||||
],
|
||||
[
|
||||
'name' => 'app_favicon',
|
||||
'value' => store_system_image($request, 'favicon'),
|
||||
],
|
||||
[
|
||||
'name' => 'app_og_image',
|
||||
'value' => store_system_image($request, 'og_image'),
|
||||
],
|
||||
[
|
||||
'name' => 'app_touch_icon',
|
||||
'value' => store_system_image($request, 'touch_icon'),
|
||||
],
|
||||
[
|
||||
'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 ?? 5,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
setEnvironmentValue([
|
||||
'APP_NAME' => Str::camel($request->title),
|
||||
]);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and login admin account
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function create_admin_account(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
// TODO: validator do requestu
|
||||
$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',
|
||||
]);
|
||||
|
||||
// Create user
|
||||
$user = User::forceCreate([
|
||||
'role' => 'admin',
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'storage_capacity' => get_setting('storage_default') ?? 5,
|
||||
'avatar' => store_avatar($request, 'avatar'),
|
||||
'name' => $request->name,
|
||||
]);
|
||||
|
||||
collect([
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $request->license,
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => $request->purchase_code,
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Set up application
|
||||
$this->setup->seed_default_pages();
|
||||
$this->setup->seed_default_settings($request->license);
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
// Login account
|
||||
if (Auth::attempt($request->only(['email', 'password']))) {
|
||||
$request->session()->regenerate();
|
||||
|
||||
return response('Registration was successful', 204);
|
||||
}
|
||||
|
||||
return response('Something went wrong', 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get setup wizard status
|
||||
*
|
||||
* @return false | null
|
||||
*/
|
||||
private function check_setup_status()
|
||||
{
|
||||
try {
|
||||
// Check database connections
|
||||
DB::getPdo();
|
||||
|
||||
// Get setup_wizard status
|
||||
if (Schema::hasTable('settings') && get_setting('setup_wizard_success')) {
|
||||
abort(410, 'Gone');
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Response;
|
||||
|
||||
class AppFunctionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show index page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view("index");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_avatar($basename)
|
||||
{
|
||||
// Get file path
|
||||
$path = storage_path() . '/app/avatars/' . $basename;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -1,144 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\ClientProfile;
|
||||
use App\Models\User\UserAttribute;
|
||||
use App\Models\User\UserNotificationSetting;
|
||||
use App\ProviderProfile;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
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;
|
||||
use App\Http\Requests\Auth\CheckAccountRequest;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Check if user account exist
|
||||
*
|
||||
* @param Request $request
|
||||
* @param CheckAccountRequest $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();
|
||||
$user = User::whereEmail($request->email)
|
||||
->first();
|
||||
|
||||
// Return user info
|
||||
if ($user) return [
|
||||
'name' => $user->name,
|
||||
'avatar' => $user->avatar,
|
||||
if (! $user) {
|
||||
return response(__t('user_not_fount'), 404);
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $user->settings->name,
|
||||
'avatar' => $user->settings->avatar,
|
||||
];
|
||||
|
||||
// Abort with 404, user not found
|
||||
return abort('404', __('vuefilemanager.user_not_fount'));
|
||||
}
|
||||
/**
|
||||
* Login user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$response = Route::dispatch(self::make_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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
// Check if account registration is enabled
|
||||
if (! config('vuefilemanager.registration') ) abort(401);
|
||||
|
||||
// Validate request
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
]);
|
||||
|
||||
// Create user
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
$response = Route::dispatch(self::make_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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout user entity
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
// Get user tokens and remove it
|
||||
auth()->user()->tokens()->each(function ($token) {
|
||||
|
||||
// Remove tokens
|
||||
$token->delete();
|
||||
});
|
||||
|
||||
return response('Logout successfull', 200)->cookie('token', '', -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make request for get user token
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $provider
|
||||
* @return Request
|
||||
*/
|
||||
private static function make_request(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' => '',
|
||||
]);
|
||||
|
||||
return Request::create(url('/oauth/token'), 'POST', $request->all());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\TestMail;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\ResetUserPasswordNotification;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
@@ -30,7 +29,6 @@ class ResetPasswordController extends Controller
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
|
||||
/**
|
||||
* Get the response for a successful password reset.
|
||||
*
|
||||
@@ -40,7 +38,6 @@ class ResetPasswordController extends Controller
|
||||
*/
|
||||
protected function sendResetResponse(Request $request, $response)
|
||||
{
|
||||
|
||||
return response(['message' => Lang::get($response)]);
|
||||
}
|
||||
|
||||
@@ -53,7 +50,6 @@ class ResetPasswordController extends Controller
|
||||
*/
|
||||
protected function sendResetFailedResponse(Request $request, $response)
|
||||
{
|
||||
|
||||
return response(['error' => Lang::get($response)], 422);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
|
||||
215
app/Http/Controllers/FileManager/BrowseController.php
Normal file
215
app/Http/Controllers/FileManager/BrowseController.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Requests\FileBrowser\SearchRequest;
|
||||
|
||||
class BrowseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get directory with files
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return Collection
|
||||
*/
|
||||
public function folder(Request $request, $id)
|
||||
{
|
||||
$root_id = $id === 'undefined' ? null : $id;
|
||||
|
||||
// Get folder trash items
|
||||
if ($request->query('trash')) {
|
||||
// Get folders and files
|
||||
$folders = Folder::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('parent_id', $root_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = File::onlyTrashed()
|
||||
->with('parent')
|
||||
->where('folder_id', $root_id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])->collapse();
|
||||
}
|
||||
|
||||
// Get folders and files
|
||||
$folders = Folder::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('parent_id', $root_id)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = File::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('folder_id', $root_id)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest user uploads
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
$user = User::with(['latest_uploads' => function ($query) {
|
||||
$query->sortable(['created_at' => 'desc']);
|
||||
}])
|
||||
->where('id', Auth::id())
|
||||
->first();
|
||||
|
||||
return $user->latest_uploads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get trashed files
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function trash()
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get folders and files
|
||||
$folders_trashed = Folder::onlyTrashed()
|
||||
->with(['trashed_folders', 'parent'])
|
||||
->where('user_id', $user_id)
|
||||
->get(['parent_id', 'id', 'name']);
|
||||
|
||||
$folders = Folder::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('id', filter_folders_ids($folders_trashed))
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Get files trashed
|
||||
$files_trashed = File::onlyTrashed()
|
||||
->with(['parent'])
|
||||
->where('user_id', $user_id)
|
||||
->where(function ($query) use ($folders_trashed) {
|
||||
$query->whereNull('folder_id');
|
||||
$query->orWhereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), '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()
|
||||
{
|
||||
$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 = Folder::with(['parent', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('id', $folder_ids)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = File::with(['parent', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('user_id', $user_id)
|
||||
->whereIn('id', $file_ids)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant uploads
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function participant_uploads()
|
||||
{
|
||||
return File::with(['parent'])
|
||||
->where('user_id', Auth::id())
|
||||
->whereAuthor('visitor')
|
||||
->sortable()
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user folder tree
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function navigation_tree()
|
||||
{
|
||||
$folders = Folder::with('folders:id,parent_id,id,name')
|
||||
->where('parent_id', null)
|
||||
->where('user_id', Auth::id())
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'id', 'name']);
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => __t('home'),
|
||||
'location' => 'base',
|
||||
'folders' => $folders,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search files
|
||||
*
|
||||
* @param SearchRequest $request
|
||||
* @return Collection
|
||||
*/
|
||||
public function search(SearchRequest $request)
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
|
||||
$query = remove_accents($request->input('query'));
|
||||
|
||||
// Search files id db
|
||||
$searched_files = File::search($query)
|
||||
->where('user_id', $user_id)
|
||||
->get();
|
||||
|
||||
$searched_folders = Folder::search($query)
|
||||
->where('user_id', $user_id)
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$searched_folders, $searched_files])
|
||||
->collapse();
|
||||
}
|
||||
}
|
||||
167
app/Http/Controllers/FileManager/EditItemsController.php
Normal file
167
app/Http/Controllers/FileManager/EditItemsController.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use Exception;
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\HelperService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\FileManagerService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\FileFunctions\UploadRequest;
|
||||
use App\Http\Requests\FileFunctions\MoveItemRequest;
|
||||
use App\Http\Requests\FileFunctions\DeleteItemRequest;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
use App\Http\Requests\FileFunctions\CreateFolderRequest;
|
||||
|
||||
class EditItemsController extends Controller
|
||||
{
|
||||
private $filemanager;
|
||||
private $helper;
|
||||
private $demo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->filemanager = resolve(FileManagerService::class);
|
||||
$this->helper = resolve(HelperService::class);
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new folder for authenticated master|editor user
|
||||
*
|
||||
* @param CreateFolderRequest $request
|
||||
* @return Folder|array|Model
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create_folder(CreateFolderRequest $request)
|
||||
{
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->create_folder($request);
|
||||
}
|
||||
|
||||
// Create new folder
|
||||
return $this->filemanager->create_folder($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item for authenticated master|editor user
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function rename_item(RenameItemRequest $request, $id)
|
||||
{
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->rename_item($request, $id);
|
||||
}
|
||||
|
||||
// If request contain icon or color, then change it
|
||||
if ($request->filled('emoji') || $request->filled('color')) {
|
||||
$this->filemanager->edit_folder_properties($request, $id);
|
||||
}
|
||||
|
||||
// Rename Item
|
||||
return $this->filemanager->rename_item($request, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete item for authenticated master|editor user
|
||||
*
|
||||
* @param DeleteItemRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete_item(DeleteItemRequest $request)
|
||||
{
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
foreach ($request->input('items') as $item) {
|
||||
$this->filemanager->delete_item($item, $item['id']);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload file for authenticated master|editor user
|
||||
*
|
||||
* @param UploadRequest $request
|
||||
* @return array|Model|\Illuminate\Support\Facades\File
|
||||
* @throws Exception
|
||||
*/
|
||||
public function upload(UploadRequest $request)
|
||||
{
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->upload($request);
|
||||
}
|
||||
|
||||
return $this->filemanager->upload($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move item for authenticated master|editor user
|
||||
*
|
||||
* @param MoveItemRequest $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function move(MoveItemRequest $request)
|
||||
{
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
$this->filemanager->move($request, $request->to_id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* User download folder via zip
|
||||
*
|
||||
* @param $id
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function zip_folder($id)
|
||||
{
|
||||
$folder = Folder::whereUserId(Auth::id())
|
||||
->where('id', $id);
|
||||
|
||||
if (! $folder->exists()) {
|
||||
abort(404, "Requested folder doesn't exists.");
|
||||
}
|
||||
|
||||
$zip = $this->filemanager->zip_folder($id);
|
||||
|
||||
return response([
|
||||
'url' => route('zip', $zip->id),
|
||||
'name' => $zip->basename,
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* User download multiple files via zip
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function zip_multiple_files(Request $request)
|
||||
{
|
||||
$files = File::whereUserId(Auth::id())
|
||||
->whereIn('id', $request->input('items'))
|
||||
->get();
|
||||
|
||||
$zip = $this->filemanager->zip_files($files);
|
||||
|
||||
return response([
|
||||
'url' => route('zip', $zip->id),
|
||||
'name' => $zip->basename,
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
70
app/Http/Controllers/FileManager/FavouriteController.php
Normal file
70
app/Http/Controllers/FileManager/FavouriteController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class FavouriteController extends Controller
|
||||
{
|
||||
/**
|
||||
* FavouriteController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add folder to user favourites
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// todo: pridat validator ako AddToFavouritesRequest
|
||||
|
||||
foreach ($request->folders as $id) {
|
||||
// Get user & folder
|
||||
$user = Auth::user();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->favourites($user);
|
||||
}
|
||||
|
||||
// Add folder to user favourites
|
||||
$user
|
||||
->favouriteFolders()
|
||||
->syncWithoutDetaching($id);
|
||||
}
|
||||
|
||||
// Return updated favourites
|
||||
return response($user->favouriteFolders, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folder from user favourites
|
||||
*
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->favourites($user);
|
||||
}
|
||||
|
||||
// Remove folder from user favourites
|
||||
$user->favouriteFolders()->detach($id);
|
||||
|
||||
// Return updated favourites
|
||||
return response($user->favouriteFolders, 204);
|
||||
}
|
||||
}
|
||||
143
app/Http/Controllers/FileManager/FileAccessController.php
Normal file
143
app/Http/Controllers/FileManager/FileAccessController.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\Zip;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\HelperService;
|
||||
use App\Models\File as UserFile;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileAccessController extends Controller
|
||||
{
|
||||
private $helper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->helper = resolve(HelperService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get avatar
|
||||
*
|
||||
* @param $basename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_avatar($basename)
|
||||
{
|
||||
// Check if file exist
|
||||
if (! Storage::exists("/avatars/$basename")) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Return avatar
|
||||
return Storage::download("/avatars/$basename", $basename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system image
|
||||
*
|
||||
* @param $basename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_system_image($basename)
|
||||
{
|
||||
// Check if file exist
|
||||
if (! Storage::exists("/system/$basename")) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Return avatar
|
||||
return Storage::download("/system/$basename", $basename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function get_file(Request $request, $filename)
|
||||
{
|
||||
// Get file record
|
||||
$file = UserFile::withTrashed()
|
||||
->where('user_id', Auth::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->helper->download_file($file, Auth::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generated zip for user
|
||||
*
|
||||
* @param $id
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
public function get_zip($id)
|
||||
{
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$zip = Zip::whereId($id)
|
||||
->where('user_id', Auth::id())
|
||||
->firstOrFail();
|
||||
|
||||
$zip
|
||||
->user
|
||||
->record_download(
|
||||
$disk->size("zip/$zip->basename")
|
||||
);
|
||||
|
||||
return $disk->download("zip/$zip->basename", $zip->basename, [
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Length' => $disk->size("zip/$zip->basename"),
|
||||
'Accept-Ranges' => 'bytes',
|
||||
'Content-Range' => 'bytes 0-600/' . $disk->size("zip/$zip->basename"),
|
||||
'Content-Disposition' => "attachment; filename=$zip->basename",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = UserFile::withTrashed()
|
||||
->whereUserId(Auth::id())
|
||||
->whereThumbnail($filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check user permission
|
||||
/*if (!$request->user()->tokenCan('master')) {
|
||||
$this->check_file_access($request, $file);
|
||||
}*/
|
||||
|
||||
return $this->helper->download_thumbnail_file($file, Auth::id());
|
||||
}
|
||||
}
|
||||
148
app/Http/Controllers/FileManager/ShareController.php
Normal file
148
app/Http/Controllers/FileManager/ShareController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use Validator;
|
||||
use App\Models\Zip;
|
||||
use App\Models\Share;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Resources\ShareResource;
|
||||
use App\Notifications\SharedSendViaEmail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Http\Requests\Share\CreateShareRequest;
|
||||
use App\Http\Requests\Share\UpdateShareRequest;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class ShareController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get shared record
|
||||
*
|
||||
* @param Share $shared
|
||||
* @return ShareResource
|
||||
*/
|
||||
public function show(Share $shared)
|
||||
{
|
||||
return new ShareResource(
|
||||
$shared
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file share link
|
||||
*
|
||||
* @param CreateShareRequest $request
|
||||
* @param $id
|
||||
* @return ShareResource
|
||||
*/
|
||||
public function store(CreateShareRequest $request, $id)
|
||||
{
|
||||
// Create shared options
|
||||
$shared = Share::create([
|
||||
'password' => $request->has('password') ? bcrypt($request->password) : null,
|
||||
'type' => $request->type === 'folder' ? 'folder' : 'file',
|
||||
'is_protected' => $request->isPassword,
|
||||
'permission' => $request->permission ?? null,
|
||||
'item_id' => $id,
|
||||
'expire_in' => $request->expiration ?? null,
|
||||
'user_id' => Auth::id(),
|
||||
]);
|
||||
|
||||
// Send shared link via email
|
||||
if ($request->has('emails')) {
|
||||
foreach ($request->emails as $email) {
|
||||
Notification::route('mail', $email)->notify(
|
||||
new SharedSendViaEmail($shared->token)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Return created shared record
|
||||
return new ShareResource($shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
'is_protected' => $request->protected,
|
||||
'expire_in' => $request->expiration,
|
||||
'password' => $request->password ? bcrypt($request->password) : $shared->password,
|
||||
]);
|
||||
|
||||
// Return shared record
|
||||
return new ShareResource($shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sharing item
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
foreach ($request->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();
|
||||
}
|
||||
}
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send shared link via email to recipients
|
||||
*
|
||||
* @param $token
|
||||
* @param $request
|
||||
*/
|
||||
public function send_to_emails_recipients(Request $request, $token)
|
||||
{
|
||||
// TODO: pridat validation request
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
121
app/Http/Controllers/FileManager/TrashController.php
Normal file
121
app/Http/Controllers/FileManager/TrashController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class TrashController extends Controller
|
||||
{
|
||||
/**
|
||||
* TrashController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore item from trash
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function restore(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
// TODO: zrefaktorovat validator do requestu
|
||||
$validator = Validator::make($request->input('items'), [
|
||||
'*.type' => 'required|string',
|
||||
'*.id' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) {
|
||||
abort(400, 'Bad input');
|
||||
}
|
||||
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
foreach ($request->input('items') as $restore) {
|
||||
// Get folder
|
||||
if ($restore['type'] === 'folder') {
|
||||
// Get folder
|
||||
$item = Folder::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('id', $restore['id'])
|
||||
->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->parent_id = null;
|
||||
$item->save();
|
||||
}
|
||||
} else {
|
||||
// Get item
|
||||
$item = File::onlyTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('id', $restore['id'])
|
||||
->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->folder_id = null;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Restore Item
|
||||
$item->restore();
|
||||
}
|
||||
|
||||
// Return response
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty user trash
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function dump()
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Get files and folders
|
||||
$folders = Folder::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
$files = File::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
|
||||
// Force delete folder
|
||||
$folders->each->forceDelete();
|
||||
|
||||
// Force delete files
|
||||
foreach ($files as $file) {
|
||||
// Delete file
|
||||
Storage::delete("/files/$user_id/{$file->basename}");
|
||||
|
||||
// Delete thumbnail if exist
|
||||
if ($file->thumbnail) {
|
||||
Storage::delete("/files/$user_id/{$file->getRawOriginal('thumbnail')}");
|
||||
}
|
||||
|
||||
// Delete file permanently
|
||||
$file->forceDelete();
|
||||
}
|
||||
|
||||
// Return response
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
@@ -1,623 +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 = get_file_type($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 ( $filetype == 'image' ) {
|
||||
|
||||
$thumbnail = 'thumbnail-' . $filename;
|
||||
|
||||
// Create intervention image
|
||||
$image = Image::make($file->getRealPath())->orientate();
|
||||
|
||||
$image->resize(256, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
})->stream();
|
||||
|
||||
// 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);
|
||||
$response->header("Accept-Ranges", "bytes");
|
||||
$response->header("Content-Range", "bytes 0-" . $size . "/" . $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;
|
||||
}
|
||||
}
|
||||
125
app/Http/Controllers/Oasis/AdminController.php
Normal file
125
app/Http/Controllers/Oasis/AdminController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use Hash;
|
||||
use Notification;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\UserSettings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Requests\Admin\CreateUserByAdmin;
|
||||
use App\Http\Requests\Oasis\CreateOrderRequest;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Services\Oasis\CzechRegisterSearchService;
|
||||
use App\Notifications\Oasis\PaymentRequiredNotification;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get company details from czech company register
|
||||
*
|
||||
* @return array|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function get_company_details()
|
||||
{
|
||||
$api = resolve(CzechRegisterSearchService::class);
|
||||
|
||||
$result = $api->findByIco(
|
||||
request()->get('ico')
|
||||
);
|
||||
|
||||
if (empty($result)) {
|
||||
return response('Not Found', 404);
|
||||
}
|
||||
|
||||
return response($result[0], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new client and send email with payment details
|
||||
*
|
||||
* @param CreateOrderRequest $request
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function create_order(CreateOrderRequest $request)
|
||||
{
|
||||
// Create user
|
||||
$newbie = User::create([
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make(Str::random()),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
// Store user settings
|
||||
$newbie
|
||||
->settings()
|
||||
->create([
|
||||
'storage_capacity' => 0,
|
||||
'ico' => $request->ico ?? null,
|
||||
'name' => $request->name,
|
||||
'address' => $request->address,
|
||||
'state' => $request->state,
|
||||
'city' => $request->city,
|
||||
'postal_code' => $request->postal_code,
|
||||
'country' => $request->country,
|
||||
'phone_number' => $request->phone_number ?? null,
|
||||
'timezone' => '1.0',
|
||||
]);
|
||||
|
||||
// Store subscription request
|
||||
$newbie
|
||||
->subscriptionRequest()
|
||||
->create([
|
||||
'requested_plan' => $request->plan,
|
||||
]);
|
||||
|
||||
$plan = resolve(StripeService::class)
|
||||
->getPlan($request->plan);
|
||||
|
||||
// Send notification with payment details
|
||||
$newbie->notify(new PaymentRequiredNotification(
|
||||
$newbie->subscriptionRequest,
|
||||
$plan
|
||||
));
|
||||
|
||||
return response(
|
||||
new UserResource($newbie),
|
||||
201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new user by admin
|
||||
*
|
||||
* @param CreateUserByAdmin $request
|
||||
* @return UserResource|Application|ResponseFactory|Response
|
||||
*/
|
||||
public function create_user(CreateUserByAdmin $request)
|
||||
{
|
||||
// Create user
|
||||
$user = User::forceCreate([
|
||||
'role' => $request->role,
|
||||
'email' => $request->email,
|
||||
'password' => \Illuminate\Support\Facades\Hash::make($request->password),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'name' => $request->name,
|
||||
'avatar' => store_avatar($request, 'avatar'),
|
||||
'storage_capacity' => $request->storage_capacity,
|
||||
'payment_activation' => 1,
|
||||
]);
|
||||
|
||||
return response(new UserResource($user), 201);
|
||||
}
|
||||
}
|
||||
135
app/Http/Controllers/Oasis/SubscriptionController.php
Normal file
135
app/Http/Controllers/Oasis/SubscriptionController.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Oasis\SubscriptionRequest;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\User\UpdateUserPasswordRequest;
|
||||
use App\Http\Resources\Oasis\SubscriptionRequestResource;
|
||||
|
||||
class SubscriptionController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->stripe = resolve(StripeService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subscription request details
|
||||
*
|
||||
* @param SubscriptionRequest $order
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function get_subscription_request(SubscriptionRequest $order)
|
||||
{
|
||||
return response(
|
||||
new SubscriptionRequestResource($order),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get setup intent to register credit card
|
||||
*
|
||||
* @param SubscriptionRequest $order
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function get_setup_intent(SubscriptionRequest $order)
|
||||
{
|
||||
// Create stripe customer if not exist
|
||||
$order->user->createOrGetStripeCustomer();
|
||||
|
||||
// Return setup intent
|
||||
return response($order->user->createSetupIntent(), 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe user
|
||||
*
|
||||
* @param Request $request
|
||||
* @param SubscriptionRequest $order
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function subscribe(Request $request, SubscriptionRequest $order)
|
||||
{
|
||||
// Make subscription from subscription request
|
||||
if ($order->exists) {
|
||||
// Create subscription
|
||||
$order->user
|
||||
->newSubscription('main', $order->requested_plan)
|
||||
->create(
|
||||
$this->stripe->getOrSetDefaultPaymentMethod($request, $order->user)
|
||||
);
|
||||
|
||||
// Update Subscription request
|
||||
$order->update(['status' => 'payed']);
|
||||
|
||||
$user = $order->user;
|
||||
}
|
||||
|
||||
// Make subscription after user sign up and pay for the plan
|
||||
if (! $order->exists) {
|
||||
$user = Auth::user();
|
||||
|
||||
// Set user billing
|
||||
$user->setBilling($request->billing);
|
||||
|
||||
// Update stripe customer billing info
|
||||
$this->stripe->updateCustomerDetails($user);
|
||||
|
||||
// Make subscription
|
||||
$this->stripe->createOrReplaceSubscription($request, $user);
|
||||
}
|
||||
|
||||
// Get plan
|
||||
$plan = $this->stripe->getPlan(
|
||||
$order->requested_plan ?? $request->input('plan.data.id')
|
||||
);
|
||||
|
||||
// Update user storage limit
|
||||
$user
|
||||
->settings()
|
||||
->update([
|
||||
'storage_capacity' => $plan['product']['metadata']['capacity'],
|
||||
'payment_activation' => 1,
|
||||
]);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user password
|
||||
*
|
||||
* @param UpdateUserPasswordRequest $request
|
||||
* @param SubscriptionRequest $order
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function set_password(UpdateUserPasswordRequest $request, SubscriptionRequest $order)
|
||||
{
|
||||
// Check unauthorized action
|
||||
if ($order->status !== 'payed') {
|
||||
abort(401, "Sorry, you don't have permission.");
|
||||
}
|
||||
|
||||
// Set user password
|
||||
$order->user->password = Hash::make($request->password);
|
||||
$order->user->save();
|
||||
|
||||
// Update status
|
||||
$order->update([
|
||||
'status' => 'logged',
|
||||
]);
|
||||
|
||||
// Log in user
|
||||
Auth::login($order->user);
|
||||
$request->session()->regenerate();
|
||||
|
||||
return response('Password was set.', 204);
|
||||
}
|
||||
}
|
||||
248
app/Http/Controllers/Sharing/BrowseShareController.php
Normal file
248
app/Http/Controllers/Sharing/BrowseShareController.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\HelperService;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\FileResource;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Http\Resources\ShareResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Http\Requests\Share\AuthenticateShareRequest;
|
||||
|
||||
class BrowseShareController extends Controller
|
||||
{
|
||||
private $helper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->helper = resolve(HelperService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show page index and delete access_token & shared_token cookie
|
||||
* @param Share $shared
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
public function index(Share $shared)
|
||||
{
|
||||
// Delete share_session if exist
|
||||
if ($shared->is_protected) {
|
||||
cookie()->queue('share_session', '', -1);
|
||||
}
|
||||
|
||||
// Check if shared is image file and then show it
|
||||
if ($shared->type === 'file' && ! $shared->is_protected) {
|
||||
$image = File::whereUserId($shared->user_id)
|
||||
->whereType('image')
|
||||
->whereId($shared->item_id)
|
||||
->first();
|
||||
|
||||
if ($image) {
|
||||
// Store user download size
|
||||
$shared
|
||||
->user
|
||||
->record_download(
|
||||
(int) $image->getRawOriginal('filesize')
|
||||
);
|
||||
|
||||
return $this->get_single_image($image, $shared->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
return view('index')
|
||||
->with('installation', 'setup-done')
|
||||
->with('settings', get_settings_in_json() ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Password for protected item
|
||||
*
|
||||
* @param AuthenticateShareRequest $request
|
||||
* @param Share $shared
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function authenticate(AuthenticateShareRequest $request, Share $shared)
|
||||
{
|
||||
// Check password
|
||||
if (Hash::check($request->password, $shared->password)) {
|
||||
$cookie = json_encode([
|
||||
'token' => $shared->token,
|
||||
'authenticated' => true,
|
||||
]);
|
||||
|
||||
// Return authorize token with shared options
|
||||
return response(new ShareResource($shared), 200)
|
||||
->cookie('share_session', $cookie, 43200);
|
||||
}
|
||||
|
||||
abort(401, __t('incorrect_password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse shared folder
|
||||
*
|
||||
* @param $id
|
||||
* @param Share $shared
|
||||
* @return Collection
|
||||
*/
|
||||
public function browse_folder($id, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check if user can get directory
|
||||
$this->helper->check_item_access($id, $shared);
|
||||
|
||||
// Get files and folders
|
||||
list($folders, $files) = $this->helper->get_items_under_shared_by_folder_id($id, $shared);
|
||||
|
||||
// Set thumbnail links for public files
|
||||
$files->map(function ($file) use ($shared) {
|
||||
$file->setPublicUrl($shared->token);
|
||||
});
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search shared files
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Share $shared
|
||||
* @return Collection
|
||||
*/
|
||||
public function search(Request $request, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
$query = remove_accents(
|
||||
$request->input('query')
|
||||
);
|
||||
|
||||
// Search files id db
|
||||
$searched_files = File::search($query)
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
$searched_folders = Folder::search($query)
|
||||
->where('user_id', $shared->user_id)
|
||||
->get();
|
||||
|
||||
// Get all children content
|
||||
$foldersIds = Folder::with('folders:id,parent_id,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, $shared) {
|
||||
// Set public urls
|
||||
$file->setPublicUrl($shared->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->id, $accessible_folder_ids);
|
||||
});
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get navigation tree of shared folder
|
||||
*
|
||||
* @param Share $shared
|
||||
* @return array
|
||||
*/
|
||||
public function navigation_tree(Share $shared)
|
||||
{
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check if user can get directory
|
||||
$this->helper->check_item_access($shared->item_id, $shared);
|
||||
|
||||
// Get folders
|
||||
$folders = Folder::with('folders:id,parent_id,name')
|
||||
->whereParentId($shared->item_id)
|
||||
->whereUserId($shared->user_id)
|
||||
->sortable()
|
||||
->get(['id', 'parent_id', 'id', 'name']);
|
||||
|
||||
return [
|
||||
[
|
||||
'id' => $shared->item_id,
|
||||
'name' => __t('home'),
|
||||
'location' => 'public',
|
||||
'folders' => $folders,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared file record
|
||||
*
|
||||
* @param Share $shared
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_single_file(Share $shared)
|
||||
{
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Get file
|
||||
$file = File::whereUserId($shared->user_id)
|
||||
->whereId($shared->item_id)
|
||||
->firstOrFail();
|
||||
|
||||
// Set access urls
|
||||
$file->setPublicUrl($shared->token);
|
||||
|
||||
return response(new FileResource($file), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image from storage and show it
|
||||
*
|
||||
* @param $file
|
||||
* @param $user_id
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
private function get_single_image($file, $user_id)
|
||||
{
|
||||
// Format pretty filename
|
||||
$file_pretty_name = $file->name . '.' . $file->mimetype;
|
||||
|
||||
// Get file path
|
||||
$path = "/files/$user_id/$file->basename";
|
||||
|
||||
// Check if file exist
|
||||
if (! Storage::exists($path)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return Storage::response($path, $file_pretty_name, [
|
||||
'Content-Type' => Storage::mimeType($path),
|
||||
'Content-Length' => Storage::size($path),
|
||||
'Accept-Ranges' => 'bytes',
|
||||
'Content-Range' => 'bytes 0-600/' . Storage::size($path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
110
app/Http/Controllers/Sharing/FileSharedAccessController.php
Normal file
110
app/Http/Controllers/Sharing/FileSharedAccessController.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\Zip;
|
||||
use App\Models\Share;
|
||||
use App\Services\HelperService;
|
||||
use App\Models\File as UserFile;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileSharedAccessController extends Controller
|
||||
{
|
||||
private $helper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->helper = resolve(HelperService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generated zip for guest
|
||||
*
|
||||
* @param $id
|
||||
* @param $token
|
||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||
*/
|
||||
public function get_zip_public($id, $token)
|
||||
{
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$zip = Zip::where('id', $id)
|
||||
->where('shared_token', $token)
|
||||
->first();
|
||||
|
||||
$zip
|
||||
->user
|
||||
->record_download(
|
||||
$disk->size("zip/$zip->basename")
|
||||
);
|
||||
|
||||
return $disk
|
||||
->download("zip/$zip->basename", $zip->basename, [
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Length' => $disk->size("zip/$zip->basename"),
|
||||
'Accept-Ranges' => 'bytes',
|
||||
'Content-Range' => 'bytes 0-600/' . $disk->size("zip/$zip->basename"),
|
||||
'Content-Disposition' => 'attachment; filename=' . $zip->basename,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file public
|
||||
*
|
||||
* @param $filename
|
||||
* @param Share $shared
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_file_public($filename, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Get file record
|
||||
$file = UserFile::where('user_id', $shared->user_id)
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||
|
||||
// Store user download size
|
||||
$shared
|
||||
->user
|
||||
->record_download(
|
||||
(int) $file->getRawOriginal('filesize')
|
||||
);
|
||||
|
||||
return $this->helper->download_file($file, $shared->user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public image thumbnail
|
||||
*
|
||||
* @param $filename
|
||||
* @param Share $shared
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_thumbnail_public($filename, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Get file record
|
||||
$file = UserFile::where('user_id', $shared->user_id)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||
|
||||
// Store user download size
|
||||
$shared
|
||||
->user
|
||||
->record_download(
|
||||
(int) $file->getRawOriginal('filesize')
|
||||
);
|
||||
|
||||
return $this->helper->download_thumbnail_file($file, $shared->user_id);
|
||||
}
|
||||
}
|
||||
300
app/Http/Controllers/Sharing/ManipulateShareItemsController.php
Normal file
300
app/Http/Controllers/Sharing/ManipulateShareItemsController.php
Normal file
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\HelperService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\FileManagerService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\FileFunctions\UploadRequest;
|
||||
use App\Http\Requests\FileFunctions\MoveItemRequest;
|
||||
use App\Http\Requests\FileFunctions\DeleteItemRequest;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
use App\Http\Requests\FileFunctions\CreateFolderRequest;
|
||||
|
||||
class ManipulateShareItemsController extends Controller
|
||||
{
|
||||
private $filemanager;
|
||||
private $helper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->filemanager = resolve(FileManagerService::class);
|
||||
$this->helper = resolve(HelperService::class);
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new folder for guest user with edit permission
|
||||
*
|
||||
* @param CreateFolderRequest $request
|
||||
* @param Share $shared
|
||||
* @return array|\Illuminate\Contracts\Foundation\Application|ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function create_folder(CreateFolderRequest $request, Share $shared)
|
||||
{
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
return $this->demo->create_folder($request);
|
||||
}
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check shared permission
|
||||
if (is_visitor($shared)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
// Check access to requested directory
|
||||
$this->helper->check_item_access($request->parent_id, $shared);
|
||||
|
||||
// Create folder
|
||||
$folder = $this->filemanager->create_folder($request, $shared);
|
||||
|
||||
return response($folder, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename item for guest user with edit permission
|
||||
*
|
||||
* @param RenameItemRequest $request
|
||||
* @param $id
|
||||
* @param Share $shared
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function rename_item(RenameItemRequest $request, $id, Share $shared)
|
||||
{
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
return $this->demo->rename_item($request, $id);
|
||||
}
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check shared permission
|
||||
if (is_visitor($shared)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
// Get file|folder item
|
||||
$item = get_item($request->type, $id);
|
||||
|
||||
// Check access to requested item
|
||||
if ($request->type === 'folder') {
|
||||
$this->helper->check_item_access($item->id, $shared);
|
||||
} else {
|
||||
$this->helper->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('icon')) {
|
||||
$this->filemanager->edit_folder_properties($request, $id);
|
||||
}
|
||||
|
||||
// Rename item
|
||||
$item = $this->filemanager->rename_item($request, $id, $shared);
|
||||
|
||||
// Set public url
|
||||
if ($item->type !== 'folder') {
|
||||
$item->setPublicUrl($shared->token);
|
||||
}
|
||||
|
||||
return response($item, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete item for guest user with edit permission
|
||||
*
|
||||
* @param DeleteItemRequest $request
|
||||
* @param Share $shared
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete_item(DeleteItemRequest $request, Share $shared)
|
||||
{
|
||||
abort_if(is_demo_account($shared->user->email), 204, 'Done.');
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check shared permission
|
||||
if (is_visitor($shared)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
foreach ($request->items as $file) {
|
||||
// Get file|folder item
|
||||
$item = get_item($file['type'], $file['id']);
|
||||
|
||||
// Check access to requested item
|
||||
if ($file['type'] === 'folder') {
|
||||
$this->helper->check_item_access($item->id, $shared);
|
||||
} else {
|
||||
$this->helper->check_item_access($item->folder_id, $shared);
|
||||
}
|
||||
|
||||
// Delete item
|
||||
$this->filemanager->delete_item($file, $file['id'], $shared);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file for guest user with edit permission
|
||||
*
|
||||
* @param UploadRequest $request
|
||||
* @param Share $shared
|
||||
* @return File|\Illuminate\Contracts\Foundation\Application|ResponseFactory|Model|\Illuminate\Http\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function upload(UploadRequest $request, Share $shared)
|
||||
{
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
return $this->demo->upload($request);
|
||||
}
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check shared permission
|
||||
if (is_visitor($shared)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
// Check access to requested directory
|
||||
$this->helper->check_item_access($request->folder_id, $shared);
|
||||
|
||||
// Return new uploaded file
|
||||
$new_file = $this->filemanager->upload($request, $shared);
|
||||
|
||||
// Set public access url
|
||||
$new_file->setPublicUrl($shared->token);
|
||||
|
||||
return response($new_file, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move item for guest user with edit permission
|
||||
*
|
||||
* @param MoveItemRequest $request
|
||||
* @param Share $shared
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function move(MoveItemRequest $request, Share $shared)
|
||||
{
|
||||
abort_if(is_demo_account($shared->user->email), 204, 'Done.');
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check shared permission
|
||||
if (is_visitor($shared)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
foreach ($request->items as $item) {
|
||||
if ($item['type'] === 'folder') {
|
||||
$this->helper->check_item_access([
|
||||
$request->to_id, $item['id'],
|
||||
], $shared);
|
||||
}
|
||||
|
||||
if ($item['type'] !== 'folder') {
|
||||
$file = File::where('id', $item['id'])
|
||||
->where('user_id', $shared->user_id)
|
||||
->firstOrFail();
|
||||
|
||||
$this->helper->check_item_access([
|
||||
$request->to_id, $file->folder_id,
|
||||
], $shared);
|
||||
}
|
||||
}
|
||||
|
||||
$this->filemanager->move($request, $request->to_id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guest download folder via zip
|
||||
*
|
||||
* @param $id
|
||||
* @param Share $shared
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function zip_folder($id, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
// Check access to requested folder
|
||||
$this->helper->check_item_access($id, $shared);
|
||||
|
||||
// Get folder
|
||||
$folder = Folder::whereUserId($shared->user_id)
|
||||
->where('id', $id);
|
||||
|
||||
if (! $folder->exists()) {
|
||||
abort(404, 'Requested folder doesn\'t exists.');
|
||||
}
|
||||
|
||||
$zip = $this->filemanager->zip_folder($id, $shared);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip_public', [
|
||||
'id' => $zip->id,
|
||||
'token' => $shared->token,
|
||||
]),
|
||||
'name' => $zip->basename,
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guest download multiple files via zip
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Share $shared
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function zip_multiple_files(Request $request, Share $shared)
|
||||
{
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
$file_parent_folders = File::whereUserId($shared->user_id)
|
||||
->whereIn('id', $request->items)
|
||||
->get()
|
||||
->pluck('folder_id')
|
||||
->toArray();
|
||||
|
||||
// Check access to requested directory
|
||||
$this->helper->check_item_access($file_parent_folders, $shared);
|
||||
|
||||
// Get requested files
|
||||
$files = File::whereUserId($shared->user_id)
|
||||
->whereIn('id', $request->items)
|
||||
->get();
|
||||
|
||||
$zip = $this->filemanager->zip_files($files, $shared);
|
||||
|
||||
// Get file
|
||||
return response([
|
||||
'url' => route('zip_public', [
|
||||
'id' => $zip->id,
|
||||
'token' => $shared->token,
|
||||
]),
|
||||
'name' => $zip->basename,
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Subscription;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\StripeService;
|
||||
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
|
||||
|
||||
class StripeWebhookController extends CashierController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->stripe = resolve(StripeService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::whereStripeId($payload['data']['object']['customer'])
|
||||
->firstOrFail();
|
||||
|
||||
// Update storage capacity
|
||||
$user
|
||||
->settings()
|
||||
->update([
|
||||
'storage_capacity' => get_setting('storage_default'),
|
||||
]);
|
||||
|
||||
return $this->successMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Invoice Payment Succeeded
|
||||
*
|
||||
* @param $payload
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handleInvoicePaymentSucceeded($payload)
|
||||
{
|
||||
// Get user
|
||||
$user = User::whereStripeId($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();
|
||||
}
|
||||
}
|
||||
128
app/Http/Controllers/User/AccountController.php
Normal file
128
app/Http/Controllers/User/AccountController.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\User\UpdateUserPasswordRequest;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
/**
|
||||
* AccountController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 settings relationship
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update_user_settings(Request $request)
|
||||
{
|
||||
// Validate request
|
||||
// TODO: pridat validator do requestu
|
||||
$validator = Validator::make($request->all(), [
|
||||
'avatar' => 'sometimes|file',
|
||||
'name' => 'string',
|
||||
'value' => 'string',
|
||||
]);
|
||||
|
||||
// Return error
|
||||
if ($validator->fails()) {
|
||||
abort(400, 'Bad input');
|
||||
}
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Update avatar
|
||||
if ($request->hasFile('avatar')) {
|
||||
$user
|
||||
->settings()
|
||||
->update([
|
||||
'avatar' => store_avatar($request, 'avatar'),
|
||||
]);
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
$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(UpdateUserPasswordRequest $request)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Change and store new password
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
$user->save();
|
||||
|
||||
return response('Changed!', 204);
|
||||
}
|
||||
}
|
||||
164
app/Http/Controllers/User/PaymentMethodsController.php
Normal file
164
app/Http/Controllers/User/PaymentMethodsController.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\StripeService;
|
||||
use Laravel\Cashier\PaymentMethod;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Http\Resources\PaymentCardResource;
|
||||
use App\Http\Resources\PaymentCardCollection;
|
||||
use App\Http\Resources\PaymentDefaultCardResource;
|
||||
use App\Http\Requests\Payments\RegisterNewPaymentMethodRequest;
|
||||
|
||||
class PaymentMethodsController extends Controller
|
||||
{
|
||||
private StripeService $stripe;
|
||||
|
||||
private DemoService $demo;
|
||||
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
$this->demo = resolve(DemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// 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
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
151
app/Http/Controllers/User/SubscriptionController.php
Normal file
151
app/Http/Controllers/User/SubscriptionController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use App\Models\User;
|
||||
use Stripe\SetupIntent;
|
||||
use App\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\Subscription\StoreUpgradeAccountRequest;
|
||||
|
||||
class SubscriptionController extends Controller
|
||||
{
|
||||
private $stripe;
|
||||
private $demo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->stripe = resolve(StripeService::class);
|
||||
$this->demo = DemoService::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate setup intent
|
||||
*
|
||||
* @return Application|ResponseFactory|Response|SetupIntent
|
||||
*/
|
||||
public function setup_intent()
|
||||
{
|
||||
return response(
|
||||
$this->stripe->getSetupIntent(Auth::user()),
|
||||
201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user subscription detail
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$user = User::find(Auth::id());
|
||||
|
||||
if (! $user->subscription('main')) {
|
||||
return abort(204, 'User don\'t have any subscription');
|
||||
}
|
||||
|
||||
$slug = 'subscription-user-' . $user->id;
|
||||
|
||||
if (Cache::has($slug)) {
|
||||
return Cache::get($slug);
|
||||
}
|
||||
|
||||
return Cache::rememberForever($slug, function () use ($user) {
|
||||
return new UserSubscription(
|
||||
$user
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade account to subscription
|
||||
*
|
||||
* @param StoreUpgradeAccountRequest $request
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function upgrade(StoreUpgradeAccountRequest $request)
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->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|Response
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$user = User::find(Auth::id());
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->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|Response
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$user = User::find(Auth::id());
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->response_204();
|
||||
}
|
||||
|
||||
// Resume subscription
|
||||
$user->subscription('main')->resume();
|
||||
|
||||
// Forget user subscription
|
||||
Cache::forget('subscription-user-' . $user->id);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\FileManagerFolder;
|
||||
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')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user folder tree
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function folder_tree() {
|
||||
|
||||
$folders = FileManagerFolder::with('folders:id,parent_id,unique_id,name')
|
||||
->where('parent_id', 0)
|
||||
->where('user_id', Auth::id())
|
||||
->get(['id', 'parent_id', 'unique_id', 'name']);
|
||||
|
||||
return [
|
||||
[
|
||||
'unique_id' => 0,
|
||||
'name' => __('vuefilemanager.home'),
|
||||
'location' => 'base',
|
||||
'folders' => $folders,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\CookieAuth;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
@@ -15,12 +14,13 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,9 @@ class Kernel extends HttpKernel
|
||||
],
|
||||
|
||||
'api' => [
|
||||
//'throttle:60,1',
|
||||
EnsureFrontendRequestsAreStateful::class,
|
||||
//'throttle:api',
|
||||
//\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
@@ -55,7 +57,6 @@ class Kernel extends HttpKernel
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
@@ -63,24 +64,5 @@ 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,
|
||||
];
|
||||
|
||||
/**
|
||||
* The priority-sorted list of middleware.
|
||||
*
|
||||
* This forces non-global middleware to always be in the given order.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewarePriority = [
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
CookieAuth::class,
|
||||
\App\Http\Middleware\Authenticate::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Illuminate\Auth\Middleware\Authorize::class,
|
||||
];
|
||||
}
|
||||
|
||||
36
app/Http/Mail/SendContactMessage.php
Normal file
36
app/Http/Mail/SendContactMessage.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App\Http\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendContactMessage 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()
|
||||
{
|
||||
return $this->from(config('mail.from')['address'])
|
||||
->replyTo($this->request['email'])
|
||||
->subject('New Contact Message from ' . $this->request['email'])
|
||||
->view('mails.contact-message')
|
||||
->with('request', $this->request);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
@@ -12,6 +11,8 @@ class CheckForMaintenanceMode extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'/service/upgrade-database',
|
||||
'/service/down',
|
||||
'/service/up',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class CookieAuth
|
||||
{
|
||||
/**
|
||||
* 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('token')) {
|
||||
|
||||
$token = $request->cookie('token');
|
||||
|
||||
$request->headers->add(['Authorization' => 'Bearer ' . $token]);
|
||||
|
||||
} else {
|
||||
abort(401);
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
@@ -12,6 +11,5 @@ class EncryptCookies extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'token'
|
||||
];
|
||||
}
|
||||
|
||||
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
];
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -13,13 +11,17 @@ class RedirectIfAuthenticated
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/files');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
@@ -19,6 +18,7 @@ class VerifyCsrfToken extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'/deploy',
|
||||
'/stripe/*',
|
||||
];
|
||||
}
|
||||
|
||||
67
app/Http/Notifications/ConfirmPayment.php
Normal file
67
app/Http/Notifications/ConfirmPayment.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace App\Http\Notifications;
|
||||
|
||||
use Laravel\Cashier\Payment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Admin/ChangeRoleRequest.php
Normal file
30
app/Http/Requests/Admin/ChangeRoleRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Admin/ChangeStorageCapacityRequest.php
Normal file
30
app/Http/Requests/Admin/ChangeStorageCapacityRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Requests/Admin/CreateUserByAdmin.php
Normal file
34
app/Http/Requests/Admin/CreateUserByAdmin.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Requests/Admin/DeleteUserRequest.php
Normal file
29
app/Http/Requests/Admin/DeleteUserRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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 [
|
||||
'name' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Requests/Auth/CheckAccountRequest.php
Normal file
29
app/Http/Requests/Auth/CheckAccountRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Requests/FileBrowser/SearchRequest.php
Normal file
29
app/Http/Requests/FileBrowser/SearchRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/FileFunctions/CreateFolderRequest.php
Normal file
30
app/Http/Requests/FileFunctions/CreateFolderRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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' => 'nullable|uuid',
|
||||
'name' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/FileFunctions/DeleteItemRequest.php
Normal file
31
app/Http/Requests/FileFunctions/DeleteItemRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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[*].id' => 'required|integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/FileFunctions/MoveItemRequest.php
Normal file
31
app/Http/Requests/FileFunctions/MoveItemRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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_id' => 'nullable|uuid',
|
||||
'items[*].type' => 'required|string',
|
||||
'items[*].id' => 'required|uuid',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/FileFunctions/RenameItemRequest.php
Normal file
30
app/Http/Requests/FileFunctions/RenameItemRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/FileFunctions/UploadRequest.php
Normal file
32
app/Http/Requests/FileFunctions/UploadRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\FileFunctions;
|
||||
|
||||
use App\Rules\DisabledMimetypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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 [
|
||||
'filename' => 'required|string',
|
||||
'folder_id' => 'nullable|uuid',
|
||||
'file' => ['required', 'file', new DisabledMimetypes],
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Languages/CreateLanguageRequest.php
Normal file
30
app/Http/Requests/Languages/CreateLanguageRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Languages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateLanguageRequest 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',
|
||||
'locale' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Languages/UpdateLanguageRequest.php
Normal file
30
app/Http/Requests/Languages/UpdateLanguageRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Languages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateLanguageRequest 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',
|
||||
'value' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Languages/UpdateStringRequest.php
Normal file
30
app/Http/Requests/Languages/UpdateStringRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Languages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateStringRequest 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',
|
||||
'value' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/Oasis/CreateOrderRequest.php
Normal file
38
app/Http/Requests/Oasis/CreateOrderRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Oasis;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateOrderRequest 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 [
|
||||
'ico' => 'sometimes|nullable',
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|email|unique:users',
|
||||
'phone_number' => 'string|nullable',
|
||||
'address' => 'required|string',
|
||||
'state' => 'required|string',
|
||||
'city' => 'required|string',
|
||||
'postal_code' => 'required|string',
|
||||
'country' => 'required|string',
|
||||
'plan' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/PublicPages/SendContactMessageRequest.php
Normal file
30
app/Http/Requests/PublicPages/SendContactMessageRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\PublicPages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SendContactMessageRequest 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',
|
||||
'logo_horizontal' => '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,34 @@
|
||||
<?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,42 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Requests/SetupWizard/StoreStripeBillingRequest.php
Normal file
36
app/Http/Requests/SetupWizard/StoreStripeBillingRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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,32 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Requests/SetupWizard/StoreStripePlansRequest.php
Normal file
34
app/Http/Requests/SetupWizard/StoreStripePlansRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Http/Requests/Share/AuthenticateShareRequest.php
Normal file
19
app/Http/Requests/Share/AuthenticateShareRequest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/Share/CreateShareRequest.php
Normal file
35
app/Http/Requests/Share/CreateShareRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Share;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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',
|
||||
'type' => 'required|string',
|
||||
'expiration' => 'integer|nullable',
|
||||
'permission' => 'string',
|
||||
'password' => 'string',
|
||||
'emails.*' => 'email',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/Share/UpdateShareRequest.php
Normal file
33
app/Http/Requests/Share/UpdateShareRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Http\Requests\Share;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
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,55 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user