Compare commits
870 Commits
SayaliChee
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6a45d8a80 | ||
|
|
14af12c818 | ||
|
|
b9614c75dc | ||
|
|
1a9b92ce49 | ||
|
|
d221544c24 | ||
|
|
f310428fd6 | ||
|
|
6721d6890a | ||
|
|
7083252e5c | ||
|
|
55a6d8cfe6 | ||
|
|
323ffbc631 | ||
|
|
7c62e42548 | ||
|
|
3814a176a7 | ||
|
|
d6c5e1ae24 | ||
|
|
2cbb0f955b | ||
|
|
ad0367ec73 | ||
|
|
0d90f9de93 | ||
|
|
11d5467d88 | ||
|
|
ce2120374b | ||
|
|
fc3517e7a6 | ||
|
|
0f460faa17 | ||
|
|
8b347013b7 | ||
|
|
984936e4de | ||
|
|
80ad968314 | ||
|
|
1136eb3ee3 | ||
|
|
8343cecd62 | ||
|
|
e7704c22b8 | ||
|
|
4b0537af70 | ||
|
|
f4943d9b2b | ||
|
|
87ece61e06 | ||
|
|
17390bf873 | ||
|
|
5927f32a8e | ||
|
|
6aff746e2b | ||
|
|
fb3b95b1ba | ||
|
|
11f8b03075 | ||
|
|
d2e1ff1fd3 | ||
|
|
0351840e0c | ||
|
|
9db365a3eb | ||
|
|
b1da47eb24 | ||
|
|
11d00eb076 | ||
|
|
5cc4f0d0ea | ||
|
|
bf2c992911 | ||
|
|
3af56e90e7 | ||
|
|
a3284c9688 | ||
|
|
43be39c47f | ||
|
|
6036f0e2ad | ||
|
|
4d755c7630 | ||
|
|
a8d0393cb4 | ||
|
|
c686993103 | ||
|
|
4a167e4a12 | ||
|
|
01fc617229 | ||
|
|
79f5af0cf3 | ||
|
|
cf778142d3 | ||
|
|
a8b6baaaff | ||
|
|
6d926b495e | ||
|
|
6160919166 | ||
|
|
029e25f4a2 | ||
|
|
e576d43edb | ||
|
|
5b6c8a8e51 | ||
|
|
31a014505f | ||
|
|
5d9a051b4a | ||
|
|
85fc5692e6 | ||
|
|
e78930117f | ||
|
|
a6d7cc5a3d | ||
|
|
a716f6a61d | ||
|
|
fe410c6501 | ||
|
|
9fc03f7637 | ||
|
|
ccee9fc3e1 | ||
|
|
7b9b92bc9f | ||
|
|
8c593f00b5 | ||
|
|
844a932b2f | ||
|
|
15c2322a8b | ||
|
|
8e1a546814 | ||
|
|
9a0d833993 | ||
|
|
8bfb4ce86d | ||
|
|
f0bf98e211 | ||
|
|
2feaf50e96 | ||
|
|
1b7aa59054 | ||
|
|
2ba787237b | ||
|
|
4fc13f3a22 | ||
|
|
dc315ffc2f | ||
|
|
ad1ef6c204 | ||
|
|
ddb4b6379f | ||
|
|
e82cc78f3a | ||
|
|
3fce81ba95 | ||
|
|
a6ec410322 | ||
|
|
9448e8796b | ||
|
|
5dcd85f0d9 | ||
|
|
ba4f07993b | ||
|
|
3a5d9cdd0d | ||
|
|
666ed5dcd7 | ||
|
|
d9b528ba86 | ||
|
|
7b45532884 | ||
|
|
d351eceba4 | ||
|
|
306839b182 | ||
|
|
bae2423539 | ||
|
|
81563d32aa | ||
|
|
508bc37e05 | ||
|
|
20e0c4599c | ||
|
|
57d92e8ccc | ||
|
|
1adb6dc55b | ||
|
|
ba1fa566b3 | ||
|
|
872ac5661c | ||
|
|
45e4b5cc2e | ||
|
|
c8c9a2912d | ||
|
|
e96054d612 | ||
|
|
8fbb3d76c6 | ||
|
|
8e56b3d824 | ||
|
|
33429d5704 | ||
|
|
f6fbbbf970 | ||
|
|
8aaa3e221c | ||
|
|
35a4d47ca6 | ||
|
|
d28f420bbf | ||
|
|
038497ccf3 | ||
|
|
975853c22d | ||
|
|
c7b8bcb5c3 | ||
|
|
e1dafb509f | ||
|
|
06a823b7d6 | ||
|
|
d0ed063a42 | ||
|
|
da8fae2343 | ||
|
|
b4fcf211c1 | ||
|
|
51d28709bc | ||
|
|
80c73c98ec | ||
|
|
7d7cfeb8b7 | ||
|
|
90519e7e00 | ||
|
|
41223879d2 | ||
|
|
01d017d131 | ||
|
|
66367d405a | ||
|
|
a3e4593812 | ||
|
|
22fbf0a365 | ||
|
|
1dc3e8e264 | ||
|
|
8af2e01e97 | ||
|
|
d44e651894 | ||
|
|
fb0414f368 | ||
|
|
58f965da76 | ||
|
|
36caf1a54d | ||
|
|
38e666c4a0 | ||
|
|
9f5438980c | ||
|
|
fbc719ba13 | ||
|
|
d1f8b6fa86 | ||
|
|
64f8538b43 | ||
|
|
661b29fbdc | ||
|
|
368f375eaa | ||
|
|
f79bf19bfc | ||
|
|
a3827f8b8d | ||
|
|
6a8ade88fa | ||
|
|
25964bb471 | ||
|
|
d0788543cd | ||
|
|
489c79d421 | ||
|
|
e2141fb7c3 | ||
|
|
9b67dcdc8d | ||
|
|
a3677a22da | ||
|
|
64eeba054f | ||
|
|
7e722421ae | ||
|
|
a667aac49a | ||
|
|
7e17c5b6e8 | ||
|
|
ff8ebad56a | ||
|
|
17800867b8 | ||
|
|
bc0945f70e | ||
|
|
dc5cabe495 | ||
|
|
5b927df6f3 | ||
|
|
513facba64 | ||
|
|
202e25963d | ||
|
|
c0c521451e | ||
|
|
75cee21685 | ||
|
|
34a6227abf | ||
|
|
1121c5c2db | ||
|
|
a6c155044a | ||
|
|
7e846dac5b | ||
|
|
613fb987a3 | ||
|
|
fb71b81016 | ||
|
|
e7e800569f | ||
|
|
83e2eeabe0 | ||
|
|
a65af42d8e | ||
|
|
b5f5135e3d | ||
|
|
bafd01c2fc | ||
|
|
8a725ee0f5 | ||
|
|
4c6b80d18d | ||
|
|
76c626da23 | ||
|
|
6a96c73f1f | ||
|
|
1c3a7a2f4c | ||
|
|
525fe5af50 | ||
|
|
600be67ab7 | ||
|
|
e0edbb98c1 | ||
|
|
74c77f6b0f | ||
|
|
67cea1a47f | ||
|
|
27719f3c99 | ||
|
|
dc239f907e | ||
|
|
4bbebe58f3 | ||
|
|
87364d48ea | ||
|
|
d8a394c083 | ||
|
|
ff8d524599 | ||
|
|
75b6f9f4ca | ||
|
|
c5259d3964 | ||
|
|
819d9abb97 | ||
|
|
102722caaa | ||
|
|
03a2dd02ab | ||
|
|
d14abf8a58 | ||
|
|
16ee1144d3 | ||
|
|
4314cdbb80 | ||
|
|
05738e57cb | ||
|
|
8fc344a763 | ||
|
|
b6524d6f51 | ||
|
|
4c6cefbb5e | ||
|
|
bde503cb11 | ||
|
|
b5afa4f041 | ||
|
|
90d1761da1 | ||
|
|
7a509c2215 | ||
|
|
9aa0c6e9d3 | ||
|
|
3cc6b5710c | ||
|
|
e53f20eb92 | ||
|
|
864cf755ee | ||
|
|
05e18dbcb0 | ||
|
|
7291b216b1 | ||
|
|
42660ef409 | ||
|
|
8c6c39373b | ||
|
|
cf021b5ba4 | ||
|
|
de7ef119b1 | ||
|
|
eef99c6cf2 | ||
|
|
3e73528089 | ||
|
|
e0ce641fc4 | ||
|
|
300f48818e | ||
|
|
6a3565c3bc | ||
|
|
fbbe48826e | ||
|
|
0c633df862 | ||
|
|
7d1aa67898 | ||
|
|
239693059b | ||
|
|
0f85a77dfb | ||
|
|
fea7d5134a | ||
|
|
9b99377117 | ||
|
|
1afbb7f900 | ||
|
|
f56bb41405 | ||
|
|
1c00ff6bfb | ||
|
|
5a41d0b81c | ||
|
|
b96724518b | ||
|
|
1415e94de5 | ||
|
|
0e73c08647 | ||
|
|
5e306ae7c2 | ||
|
|
f69a0f7df1 | ||
|
|
f98d56761d | ||
|
|
a50e46e238 | ||
|
|
65d6c679f3 | ||
|
|
33ef6a71d6 | ||
|
|
966fc691b0 | ||
|
|
f92763e059 | ||
|
|
9a84532d75 | ||
|
|
a27a8f1459 | ||
|
|
0c456d347a | ||
|
|
33178b7103 | ||
|
|
e3c7808fb9 | ||
|
|
1af5968001 | ||
|
|
a543e1f8e5 | ||
|
|
11d65029a9 | ||
|
|
2ec9ea5b92 | ||
|
|
158ef13f81 | ||
|
|
b0e083df6d | ||
|
|
cdc1c1cb23 | ||
|
|
2f75acb2a6 | ||
|
|
fc46b30f8a | ||
|
|
f7f2947982 | ||
|
|
fa30efe9c0 | ||
|
|
8325bbc815 | ||
|
|
96d598d42b | ||
|
|
27d6764fbc | ||
|
|
0cc0f87b75 | ||
|
|
132439f291 | ||
|
|
f2f8ef2fda | ||
|
|
f84d79d09c | ||
|
|
237d3172c1 | ||
|
|
e3bcd5321e | ||
|
|
917d566795 | ||
|
|
13f0a808bb | ||
|
|
b9ccd35742 | ||
|
|
cbda01f160 | ||
|
|
7caafe8dc8 | ||
|
|
5929fbdadb | ||
|
|
cad7ed5396 | ||
|
|
f07f00e89c | ||
|
|
8b639f240e | ||
|
|
681b91862a | ||
|
|
d8fd11ed4f | ||
|
|
cca6aefd5c | ||
|
|
2d771f2170 | ||
|
|
05dec2db37 | ||
|
|
e061d3f670 | ||
|
|
c4c6e304be | ||
|
|
362036606d | ||
|
|
deb6ae0488 | ||
|
|
657b5e962a | ||
|
|
454b254568 | ||
|
|
2d0d6c71eb | ||
|
|
c8bb3ea999 | ||
|
|
87dfcc4e81 | ||
|
|
aa17412214 | ||
|
|
f2ac46db19 | ||
|
|
e1b8cdd57f | ||
|
|
895f1466ab | ||
|
|
6bf1a1bf4a | ||
|
|
50d4996ec6 | ||
|
|
6a1520c5d6 | ||
|
|
2c0030e37c | ||
|
|
5180f7267e | ||
|
|
84b1dbcaa4 | ||
|
|
f2daffaee5 | ||
|
|
4523ac7cef | ||
|
|
22fa66f56f | ||
|
|
05a502b126 | ||
|
|
1d1b9a4206 | ||
|
|
f2771132ba | ||
|
|
5399d2814b | ||
|
|
fb862c47ea | ||
|
|
551ecccef9 | ||
|
|
89fb83ae5d | ||
|
|
cd21513553 | ||
|
|
c9844e12b5 | ||
|
|
146ffbd337 | ||
|
|
8342002782 | ||
|
|
f2077e77eb | ||
|
|
e1ede21417 | ||
|
|
8871c6ed22 | ||
|
|
3ecbd11a85 | ||
|
|
f35c960dfa | ||
|
|
534b0d8d29 | ||
|
|
99c3cead0c | ||
|
|
ef75aff612 | ||
|
|
78984cf9e7 | ||
|
|
d1ad9a6e48 | ||
|
|
af1d9f3fdf | ||
|
|
68838da0ff | ||
|
|
889da666bb | ||
|
|
9889e663af | ||
|
|
a7645e499e | ||
|
|
c29af1a72a | ||
|
|
55fa8997a7 | ||
|
|
f50e910970 | ||
|
|
4808f0f3a8 | ||
|
|
8ee88b5ef8 | ||
|
|
0cd46ad83d | ||
|
|
4aa72ebef6 | ||
|
|
1ab57c7727 | ||
|
|
ce5edcedbc | ||
|
|
68810a3d66 | ||
|
|
f93beff03f | ||
|
|
35136b12a7 | ||
|
|
6a7d3b05da | ||
|
|
9abdf81109 | ||
|
|
93b9559d54 | ||
|
|
09d15f09b6 | ||
|
|
da4700bd27 | ||
|
|
6a32aad513 | ||
|
|
fde8df31e8 | ||
|
|
95fab6022c | ||
|
|
b5e6af1005 | ||
|
|
3d4302d531 | ||
|
|
b2ab6de332 | ||
|
|
ee39232cc1 | ||
|
|
f3229c6266 | ||
|
|
ad86fb89ce | ||
|
|
a8afd5352c | ||
|
|
c1833cff98 | ||
|
|
e15a0d1243 | ||
|
|
437a2109a1 | ||
|
|
2f220363a1 | ||
|
|
797f53a210 | ||
|
|
338d94ccc9 | ||
|
|
85e23ac2d0 | ||
|
|
850c60ba5f | ||
|
|
c526fcbdad | ||
|
|
3d9da59c6d | ||
|
|
459975ea7b | ||
|
|
4b9e568985 | ||
|
|
333089cea1 | ||
|
|
b35d1617ea | ||
|
|
e5816b00c8 | ||
|
|
97df439c6f | ||
|
|
c81852d661 | ||
|
|
8d2bc89490 | ||
|
|
72612cbcb1 | ||
|
|
49833f94fe | ||
|
|
6a00d7119f | ||
|
|
364be93cdc | ||
|
|
5c184b80ee | ||
|
|
930176ddb9 | ||
|
|
105245fec1 | ||
|
|
ec964f2ce6 | ||
|
|
34fb933a12 | ||
|
|
3c3d2e41a6 | ||
|
|
b93ac105d8 | ||
|
|
4f5960c9ae | ||
|
|
989b64e505 | ||
|
|
f2bae2622d | ||
|
|
bc1c466fd1 | ||
|
|
bab6c3324a | ||
|
|
092f206d60 | ||
|
|
433c7ba338 | ||
|
|
458a502740 | ||
|
|
7ead79267b | ||
|
|
18867acc2f | ||
|
|
72491bfd2e | ||
|
|
bf99303876 | ||
|
|
f5e7487877 | ||
|
|
3f0e4a479e | ||
|
|
e2074625e4 | ||
|
|
57c4820219 | ||
|
|
831d19f056 | ||
|
|
6b46f22a4d | ||
|
|
1d6065ce70 | ||
|
|
fbe06c6900 | ||
|
|
418278d053 | ||
|
|
80eb0d728b | ||
|
|
38cad36f99 | ||
|
|
ad40740362 | ||
|
|
19c4641ea7 | ||
|
|
f15deee72b | ||
|
|
63f6744068 | ||
|
|
7fa338eba1 | ||
|
|
9d59702dc3 | ||
|
|
63b0a6a990 | ||
|
|
5dc57eaa83 | ||
|
|
94f65baea6 | ||
|
|
62c505c11a | ||
|
|
3751541754 | ||
|
|
f019b7429e | ||
|
|
cc91181cc3 | ||
|
|
63b251ff32 | ||
|
|
d49a66bc1b | ||
|
|
f73d4212f0 | ||
|
|
3d94692b39 | ||
|
|
9156be0de1 | ||
|
|
563246bd54 | ||
|
|
3d52559366 | ||
|
|
4299c55178 | ||
|
|
ef48a5fd9d | ||
|
|
f1f4991aec | ||
|
|
4e18854a28 | ||
|
|
fcbc7639c1 | ||
|
|
770380878d | ||
|
|
376501f090 | ||
|
|
7a164f39f5 | ||
|
|
28a4007da9 | ||
|
|
3f5dee257e | ||
|
|
7839959168 | ||
|
|
ad8a61611e | ||
|
|
284a1e11dc | ||
|
|
e0f0440f22 | ||
|
|
9d57f8a5d2 | ||
|
|
1ff71dc65d | ||
|
|
d650a79a99 | ||
|
|
474cd5a99d | ||
|
|
65096a5c61 | ||
|
|
c104da1a11 | ||
|
|
ea5911c6cf | ||
|
|
5bfb7bcdbd | ||
|
|
315da27c38 | ||
|
|
5f4a1c12aa | ||
|
|
99f6657008 | ||
|
|
797813221a | ||
|
|
e8b1f2956f | ||
|
|
250ac11453 | ||
|
|
b94647b055 | ||
|
|
d4ac78bfee | ||
|
|
361145bb0f | ||
|
|
06517f4c4a | ||
|
|
e5b7b4d3a4 | ||
|
|
532ab8b651 | ||
|
|
a58ef55c1d | ||
|
|
ffade2dd6a | ||
|
|
819ea4efe8 | ||
|
|
b7adf8c0c4 | ||
|
|
70c3d7456e | ||
|
|
907d6dddc4 | ||
|
|
e8dc0f2931 | ||
|
|
8500eb6535 | ||
|
|
3781cc027f | ||
|
|
a59f3d723d | ||
|
|
60a841498d | ||
|
|
494e1eca80 | ||
|
|
7cf9bf0c54 | ||
|
|
a5062ff1c1 | ||
|
|
65c22ace01 | ||
|
|
f5fa754532 | ||
|
|
d479cdf869 | ||
|
|
0bd8c3d88f | ||
|
|
53cdc96c6d | ||
|
|
9b7916b5ab | ||
|
|
47c8db98b6 | ||
|
|
af7319e0dd | ||
|
|
e973c25958 | ||
|
|
613ef95a84 | ||
|
|
aef89afb18 | ||
|
|
11adc43d6d | ||
|
|
74f51721cb | ||
|
|
4f63083faa | ||
|
|
a67837b393 | ||
|
|
2436ce0516 | ||
|
|
88e05c423a | ||
|
|
9c9d9f0a65 | ||
|
|
8b6dc4cadb | ||
|
|
8df19d5abe | ||
|
|
2d03551719 | ||
|
|
3f9f711565 | ||
|
|
3ff23ed7a3 | ||
|
|
493a3facbe | ||
|
|
814f491513 | ||
|
|
ded3ea50f6 | ||
|
|
da6dc78ccf | ||
|
|
a2251b779d | ||
|
|
475be7db85 | ||
|
|
7c3a811d8b | ||
|
|
6daeca0628 | ||
|
|
1a575539ce | ||
|
|
b1ea9d07cb | ||
|
|
f80cb1194e | ||
|
|
1a5ce47d81 | ||
|
|
cf2edb06d6 | ||
|
|
2f70e266a4 | ||
|
|
728f1fbceb | ||
|
|
06a85d5693 | ||
|
|
8d74a4d83c | ||
|
|
50ae997a42 | ||
|
|
d63a3f1f40 | ||
|
|
82455c4d82 | ||
|
|
c6e1bc0a1d | ||
|
|
5cfa57b410 | ||
|
|
f14a73eb99 | ||
|
|
75720d7b44 | ||
|
|
f6d70f645d | ||
|
|
499f00148b | ||
|
|
236e337783 | ||
|
|
2f21a34b98 | ||
|
|
901b2c6666 | ||
|
|
a7fabb3179 | ||
|
|
e6f01f7aa6 | ||
|
|
45fda180ac | ||
|
|
7c9754adf1 | ||
|
|
ab4e353d93 | ||
|
|
22d5bbe0e4 | ||
|
|
31cab80ff9 | ||
|
|
34103efdc0 | ||
|
|
1aff35adfe | ||
|
|
3b9d03b623 | ||
|
|
5dc49a9c68 | ||
|
|
d0052df774 | ||
|
|
e395c7761f | ||
|
|
a728aab8d7 | ||
|
|
d1d2de8b27 | ||
|
|
893c5d3517 | ||
|
|
a33c94ae65 | ||
|
|
2c66be8cce | ||
|
|
adae7fc567 | ||
|
|
dae33b4f25 | ||
|
|
f54789e832 | ||
|
|
6786450d30 | ||
|
|
616b0b2e44 | ||
|
|
f967347cb9 | ||
|
|
f50ea7e39e | ||
|
|
04cc977f06 | ||
|
|
f1e148a335 | ||
|
|
6f83144139 | ||
|
|
dbf6d811fa | ||
|
|
c6a24319d5 | ||
|
|
6a3925520d | ||
|
|
b1ac95669b | ||
|
|
cbec6a7c4b | ||
|
|
22980dce7f | ||
|
|
d71d0d9dbc | ||
|
|
a6df2e54ec | ||
|
|
10aa81cc08 | ||
|
|
8b83434189 | ||
|
|
0903478fde | ||
|
|
55988aa60a | ||
|
|
4287299d72 | ||
|
|
69aa9acba8 | ||
|
|
25d89ceb25 | ||
|
|
644d7d4c20 | ||
|
|
e0e63c4611 | ||
|
|
29df0086a7 | ||
|
|
9816afe1f4 | ||
|
|
917d5f88db | ||
|
|
2fcd62d624 | ||
|
|
f861a43f5f | ||
|
|
c6d92b8a39 | ||
|
|
10a71600d8 | ||
|
|
e79819252b | ||
|
|
b73d4dab68 | ||
|
|
fb998f22ab | ||
|
|
7273fd633a | ||
|
|
5b6186ede1 | ||
|
|
f0967e4f57 | ||
|
|
8a8a97acb3 | ||
|
|
1f30bb524a | ||
|
|
2396db80ef | ||
|
|
6f270d9ffb | ||
|
|
bdf9fc83d8 | ||
|
|
baf8d1abf5 | ||
|
|
607811057f | ||
|
|
d5bcebb79a | ||
|
|
6298431efc | ||
|
|
5c7e54b944 | ||
|
|
ab11a08cb6 | ||
|
|
8db9c1b7f5 | ||
|
|
591f0958c3 | ||
|
|
d1dad4f91a | ||
|
|
db5d52fa57 | ||
|
|
be01fc8556 | ||
|
|
68798c435e | ||
|
|
7543ede451 | ||
|
|
4f62ee8939 | ||
|
|
3b382c3d60 | ||
|
|
d3f143d0c9 | ||
|
|
848d22d5f4 | ||
|
|
b146116623 | ||
|
|
693bf46137 | ||
|
|
ad8feb4fae | ||
|
|
cbe292bb5a | ||
|
|
ccc255b0f2 | ||
|
|
b7317bedd6 | ||
|
|
9bc4c7f1f4 | ||
|
|
c885ae5fd3 | ||
|
|
cdf002d677 | ||
|
|
7d856c368b | ||
|
|
65d371748c | ||
|
|
daa9a59432 | ||
|
|
c6cfafc411 | ||
|
|
2c86e4feaa | ||
|
|
e0ff94c035 | ||
|
|
92bc5711d6 | ||
|
|
4983cca5ce | ||
|
|
a25f6306c3 | ||
|
|
cbf1a13230 | ||
|
|
7cdd769e45 | ||
|
|
c13004865d | ||
|
|
301cc47ca0 | ||
|
|
f08a5b62b8 | ||
|
|
cd77a330d9 | ||
|
|
77268ae08a | ||
|
|
7c1337c21f | ||
|
|
cccaeef32c | ||
|
|
9ed108513e | ||
|
|
bc7f8c9dab | ||
|
|
6aecb9f399 | ||
|
|
4072c658b6 | ||
|
|
4828165a38 | ||
|
|
fec670310b | ||
|
|
d9a28bfff2 | ||
|
|
2db71ff7c7 | ||
|
|
b6b8f5bf57 | ||
|
|
76a6ba8dfa | ||
|
|
b2dbced98e | ||
|
|
adf8c27e38 | ||
|
|
0ac4cb2118 | ||
|
|
f7f87d07e0 | ||
|
|
7b4723fe73 | ||
|
|
bf533dae9e | ||
|
|
f25d8a7154 | ||
|
|
08e6eaf265 | ||
|
|
59c9de87f2 | ||
|
|
6f6e1ead22 | ||
|
|
4156c8968b | ||
|
|
ffe76b509f | ||
|
|
8ec08aab03 | ||
|
|
0ceeb6e59a | ||
|
|
9721378c66 | ||
|
|
dd5cb06b4c | ||
|
|
db6b8b7752 | ||
|
|
9838868b05 | ||
|
|
32d5ff0edb | ||
|
|
c91c0a3129 | ||
|
|
ae862c0b42 | ||
|
|
995b2c14ce | ||
|
|
f9512d6b4b | ||
|
|
550372628d | ||
|
|
55920f17cf | ||
|
|
deeabe37c9 | ||
|
|
2df39304d4 | ||
|
|
736f323c37 | ||
|
|
acb2b9330d | ||
|
|
671add21ce | ||
|
|
c28c94b134 | ||
|
|
f4a50fc3f9 | ||
|
|
3bc89966d4 | ||
|
|
a210958d5e | ||
|
|
cfd42368dc | ||
|
|
45d77ddae1 | ||
|
|
282c6d3574 | ||
|
|
eb868d9a5c | ||
|
|
17d43d109d | ||
|
|
5e2cecc044 | ||
|
|
63d25fe75b | ||
|
|
136fbf3a1b | ||
|
|
a24fdf4b93 | ||
|
|
7f858f4402 | ||
|
|
518218712b | ||
|
|
cffe6d2191 | ||
|
|
b222e681df | ||
|
|
8badd8d9a1 | ||
|
|
66c72206bd | ||
|
|
572b6359d8 | ||
|
|
1b7b7baca1 | ||
|
|
770d653b69 | ||
|
|
5bcfa4417d | ||
|
|
ffabacb7f2 | ||
|
|
8398e0b6fa | ||
|
|
4cef472a93 | ||
|
|
bda8d33d85 | ||
|
|
346d420b18 | ||
|
|
16153f4f6b | ||
|
|
275ac3b8a8 | ||
|
|
73c3b74cfa | ||
|
|
e92996fd34 | ||
|
|
995882662b | ||
|
|
bdc8aa3b05 | ||
|
|
5099619777 | ||
|
|
a254c0237d | ||
|
|
3bdd089cb5 | ||
|
|
309b58a3d0 | ||
|
|
0d19b8b329 | ||
|
|
869926ff94 | ||
|
|
267d4db72a | ||
|
|
58b3f3b19c | ||
|
|
4a177180de | ||
|
|
cf45241300 | ||
|
|
b41ef5ad20 | ||
|
|
e0824adb52 | ||
|
|
80a33133ca | ||
|
|
3003e10003 | ||
|
|
a67beef1ad | ||
|
|
84f0d7bb9d | ||
|
|
d3a14a7eb1 | ||
|
|
3df356addf | ||
|
|
ce781fb822 | ||
|
|
72037a2832 | ||
|
|
115bb1a87e | ||
|
|
ba6ec37b61 | ||
|
|
7cdda08edc | ||
|
|
c87448dea0 | ||
|
|
53f0068e2c | ||
|
|
64acafcf43 | ||
|
|
bc7d8cb09e | ||
|
|
9c69b246d2 | ||
|
|
dc2ecefbc0 | ||
|
|
5be9b18fb5 | ||
|
|
49c93ca960 | ||
|
|
13819cbb1a | ||
|
|
285cec097c | ||
|
|
e97e7bfac4 | ||
|
|
13b1567003 | ||
|
|
89ec831b04 | ||
|
|
0b542d0d05 | ||
|
|
15af51f691 | ||
|
|
cb96bd9fb7 | ||
|
|
6f6594ef99 | ||
|
|
cb20bad55c | ||
|
|
c399927f68 | ||
|
|
080a52a2dc | ||
|
|
396e185a1c | ||
|
|
9b6005c3d4 | ||
|
|
1d68a3b15d | ||
|
|
6d25c9c025 | ||
|
|
384478997a | ||
|
|
250f3443f9 | ||
|
|
3eb6dea23c | ||
|
|
a94f625134 | ||
|
|
30ec2635d6 | ||
|
|
d86913694c | ||
|
|
148b12c1c3 | ||
|
|
de147e6824 | ||
|
|
3e5d345c15 | ||
|
|
e05b127ae2 | ||
|
|
87c1bd0d23 | ||
|
|
7eed026227 | ||
|
|
0c9159099a | ||
|
|
a33c71d7a5 | ||
|
|
4b97d1f7f7 | ||
|
|
4816cf3fe7 | ||
|
|
dd4dc34a3d | ||
|
|
d83916ca03 | ||
|
|
abbd4a0b44 | ||
|
|
9f36012595 | ||
|
|
678032067f | ||
|
|
97a65c0a7b | ||
|
|
a687f958d1 | ||
|
|
e19da2e2c0 | ||
|
|
4e2c5b766a | ||
|
|
435d36343a | ||
|
|
a65a3e27ad | ||
|
|
a8a1703ff9 | ||
|
|
8f19297130 | ||
|
|
ef271fabce | ||
|
|
709172b5a7 | ||
|
|
fa88f5cab6 | ||
|
|
c2094a9064 | ||
|
|
721d341ca6 | ||
|
|
3c6161ada3 | ||
|
|
66dabdfbde | ||
|
|
f7dd226958 | ||
|
|
6db63a6cc1 | ||
|
|
9240217b2f | ||
|
|
ed2be8bb48 | ||
|
|
eb92ed7559 | ||
|
|
592e05b898 | ||
|
|
88c3114f0e | ||
|
|
3fb443a556 | ||
|
|
c87927707b | ||
|
|
86b6fd79f7 | ||
|
|
64a085b460 | ||
|
|
48330b4f9f | ||
|
|
39e3688cca | ||
|
|
9e9d9d24b7 | ||
|
|
b67d7edcf1 | ||
|
|
48755960a0 | ||
|
|
922b5f8c24 | ||
|
|
4ebdd543c6 | ||
|
|
b50566f298 | ||
|
|
5d648386bc | ||
|
|
1c0c1df28f | ||
|
|
b1a19de33d | ||
|
|
497a5e7975 | ||
|
|
41526aaeb0 | ||
|
|
bdb0d50b0e | ||
|
|
ab69cb22f7 | ||
|
|
ae0fe47740 | ||
|
|
fbd89d8d54 | ||
|
|
3f13fae1e9 | ||
|
|
483456196b | ||
|
|
04d5fc1c9c | ||
|
|
85da9014f5 | ||
|
|
43fe7dd9b9 | ||
|
|
57971e3a2f | ||
|
|
8645b5ae6f | ||
|
|
cf571fb5d7 | ||
|
|
21865cd21c | ||
|
|
d18386a63c | ||
|
|
22a028c0f7 | ||
|
|
fb9253b59a | ||
|
|
5553d62e89 | ||
|
|
9c2de05ee6 | ||
|
|
50161b1a21 | ||
|
|
7637e358fb | ||
|
|
48bc42d9eb | ||
|
|
b8ad62d085 | ||
|
|
a11bfdbfcb | ||
|
|
7dbb6a4fcd | ||
|
|
e996f4b320 | ||
|
|
9a465b908e | ||
|
|
02b35a8892 | ||
|
|
1ecc314e8e | ||
|
|
02d6094bec | ||
|
|
6982346e8e | ||
|
|
ed900e4a22 | ||
|
|
e44078ae0c | ||
|
|
f45a05590e | ||
|
|
9720034748 | ||
|
|
0f30c071a0 | ||
|
|
3bdaeea0a9 | ||
|
|
d5e968deaa | ||
|
|
831c77dbde | ||
|
|
2358f561bf | ||
|
|
0d11c2a76f | ||
|
|
64d91c6aa8 | ||
|
|
47ea603c10 | ||
|
|
52f7299d6a | ||
|
|
e4c12c5fa9 | ||
|
|
bd81d002b7 | ||
|
|
7af971cada | ||
|
|
f0db020b63 | ||
|
|
efeef736f9 | ||
|
|
15fa3454ff | ||
|
|
4fbcde8b07 | ||
|
|
7264174ede | ||
|
|
fb046fc536 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,3 +18,5 @@ yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
composer.lock
|
||||
composer.json
|
||||
|
||||
@@ -8,7 +8,10 @@ use App\Models\IamPrincipal;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Models\RestaurantTimeInterval;
|
||||
use App\Models\TimeInterval;
|
||||
|
||||
class ReinstateRestaurant extends Command
|
||||
{
|
||||
@@ -30,59 +33,72 @@ class ReinstateRestaurant extends Command
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$recordsToUpdate = RedeemRestaurant::where('is_redeem', 1)->get();
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$recordsToUpdate = RedeemRestaurant::where('is_redeem', 1)->get();
|
||||
|
||||
foreach ($recordsToUpdate as $record) {
|
||||
//find restaurant
|
||||
$managerestaurant = ManageRestaurant::where('id', $record->manage_restaurants_xid)->first();
|
||||
foreach ($recordsToUpdate as $record) {
|
||||
$managerestaurant = ManageRestaurant::where('id', $record->manage_restaurants_xid)->first();
|
||||
$restTime = RestaurantTimeInterval::select('time_hours')->where('manage_restaurants_xid', $managerestaurant->id)->first();
|
||||
// $stateTime = TimeInterval::select('time_hours')->where('manage_state_xid', $managerestaurant->state_xid)->first();
|
||||
|
||||
$customerData = IamPrincipal::where('id', $record->iam_principal_xid)->where('notification_status', 1)->where('principal_type_xid',3)->first(); //fetch customer
|
||||
$restTimeHours = $restTime ? $restTime->time_hours : 0;
|
||||
// $stateTimeHours = $stateTime ? $stateTime->time_hours : 0;
|
||||
|
||||
if ($managerestaurant && $managerestaurant->is_active == 1) {
|
||||
$redeemDate = Carbon::parse($record->redeem_date);
|
||||
$customerData = IamPrincipal::where('id', $record->iam_principal_xid)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->first();
|
||||
|
||||
$fourHourPlusTimeOfRecord = $redeemDate->copy()->addHours(4);
|
||||
if ($managerestaurant && $managerestaurant->is_active == 1) {
|
||||
$redeemDate = Carbon::parse($record->redeem_date);
|
||||
|
||||
$currentTime = Carbon::now();
|
||||
// Calculate the state time plus record time
|
||||
// $stateHourPlusTimeOfRecord = $redeemDate->copy()->addHours($stateTimeHours);
|
||||
// Log::info('state time' . $stateHourPlusTimeOfRecord);
|
||||
|
||||
if ($currentTime > $fourHourPlusTimeOfRecord) {
|
||||
$record->update([
|
||||
'is_redeem' => 0,
|
||||
'redeem_date' => null,
|
||||
'count' => $record->count + 1,
|
||||
'is_redeemption_undone' => 0,
|
||||
'redeemption_undone_date' => null,
|
||||
]);
|
||||
$restImage = ListingImageUrl('restaurant_images', $managerestaurant->image);
|
||||
$title = "Your " . $managerestaurant->name . " Reinstate successfully";
|
||||
$message = "Your " . $managerestaurant->name . " Reinstate successfully";
|
||||
$content_type = 'Restaurant Reinstate';
|
||||
$imageUrl = $restImage;
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerData->one_signal_player_id,
|
||||
$title,
|
||||
$message,
|
||||
$content_type,
|
||||
$imageUrl,
|
||||
$id = null
|
||||
);
|
||||
Log::info('Reinstate of record done at ' . now());
|
||||
|
||||
onesignalhelper::StoreNotificationDetails($customerData->id, $content_type, $title, $restImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::info('Reinstate task ran successfully at ' . now());
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Reinstate function failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
// if ($currentTime > $stateHourPlusTimeOfRecord) {
|
||||
// Only proceed if state time condition is met
|
||||
$restHourPlusTimeOfRecord = $redeemDate->copy()->addHours(intval($restTimeHours));
|
||||
Log::info('Restaurant time ' . $restHourPlusTimeOfRecord);
|
||||
|
||||
|
||||
if ($currentTime > $restHourPlusTimeOfRecord) {
|
||||
$record->update([
|
||||
'is_redeem' => 0,
|
||||
'count' => $record->count + 1,
|
||||
'is_redeemption_undone' => 0,
|
||||
'redeemption_undone_date' => null,
|
||||
]);
|
||||
|
||||
$restImage = ListingImageUrl('restaurant_images', $managerestaurant->image);
|
||||
$title = "Your " . $managerestaurant->name . " Reinstate successfully";
|
||||
$message = "Your " . $managerestaurant->name . " Reinstate successfully";
|
||||
$content_type = 'Restaurant Reinstate';
|
||||
$imageUrl = $restImage;
|
||||
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerData->one_signal_player_id,
|
||||
$title,
|
||||
$message,
|
||||
$content_type,
|
||||
$imageUrl,
|
||||
$id = null
|
||||
);
|
||||
Log::info('Reinstate of record done at ' . now());
|
||||
|
||||
onesignalhelper::StoreNotificationDetails($customerData->id, $content_type, $title, $restImage);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Reinstate function failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
114
app/Console/Commands/SentScheduleNotification.php
Normal file
114
app/Console/Commands/SentScheduleNotification.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\NotificationDetails;
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use DateTime;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SentScheduleNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:sent-schedule-notification';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'It will send Recommendation to users Based on stored Data';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$getAllPushNotifications = NotificationDetails::where('is_schedule', 1)
|
||||
->where('is_active', 1)
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
|
||||
$currentDateTime = new DateTime();
|
||||
|
||||
foreach ($getAllPushNotifications as $inAppNotificationItem) {
|
||||
|
||||
$storedDateTime = new DateTime($inAppNotificationItem->delivery_schedule);
|
||||
|
||||
$currentTime = $currentDateTime->format('Y-m-d H:i');
|
||||
$storedTime = $storedDateTime->format('Y-m-d H:i');
|
||||
|
||||
if ($currentTime == $storedTime) {
|
||||
$title = $inAppNotificationItem->type;
|
||||
$description = $inAppNotificationItem->description;
|
||||
$imagePath = $inAppNotificationItem->image;
|
||||
$stateIds = json_decode($inAppNotificationItem->state_ids, true);
|
||||
$userType = $inAppNotificationItem->user_type;
|
||||
|
||||
if ($userType == 1) {
|
||||
// Subscribed users
|
||||
$iamPrincipals = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', now())
|
||||
->get();
|
||||
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
|
||||
$users = IamPrincipal::whereIn('id', $iamPrincipalIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $stateIds)
|
||||
->get();
|
||||
} elseif ($userType == 2) {
|
||||
// Unsubscribed users
|
||||
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)->pluck('id');
|
||||
$subscribedIds = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', now())
|
||||
->pluck('iam_principal_xid');
|
||||
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
|
||||
$users = IamPrincipal::whereIn('id', $unsubscribedIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->whereIn('state_xid', $stateIds)
|
||||
->get();
|
||||
} elseif ($userType == 3) {
|
||||
// Both subscribed and unsubscribed users
|
||||
$users = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $stateIds)
|
||||
->get();
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user->one_signal_player_id) {
|
||||
OneSignalHelper::sendNotificationApi(
|
||||
$user->one_signal_player_id,
|
||||
$title,
|
||||
$description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
|
||||
Log::info("INAPP scheduled notification sent successfully to user ID: {$user->id}");
|
||||
onesignalhelper::StoreNotificationDetails($user->id, 'Notification', $title, $imagePath);
|
||||
|
||||
$inAppNotificationItem->is_active = 0;
|
||||
$inAppNotificationItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
52
app/Exports/DashboardExportUser.php
Normal file
52
app/Exports/DashboardExportUser.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardExportUser implements FromArray, WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return array_map(function ($transaction) {
|
||||
return [
|
||||
'ID' => $transaction['id'] ?? 'N/A',
|
||||
'Customer Name' => ($transaction['iam_principal']['first_name'] ?? 'Deleted') . ' ' . ($transaction['iam_principal']['last_name'] ?? 'User'),
|
||||
'Customer ID' => $transaction['iam_principal']['id'] ?? 'Deleted User',
|
||||
'Amount' => '$' . number_format($transaction['amount'] ?? 0, 2),
|
||||
'Product Name' => $transaction['subscription_product']['product_name'] ?? 'N/A',
|
||||
'Product Details' => $transaction['subscription_product']['product_details'] ?? 'N/A',
|
||||
'Subscription Status' => $transaction['status'] ?? 'Unknown',
|
||||
'Subscription Period Start' => isset($transaction['current_period_start']) ? Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A') : 'N/A',
|
||||
'Subscription Period End' => isset($transaction['current_period_end']) ? Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A') : 'N/A',
|
||||
'Next Payment Date' => isset($transaction['next_payment_date']) ? Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A') : 'N/A',
|
||||
];
|
||||
|
||||
}, $this->data);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'Customer Name',
|
||||
'Customer ID',
|
||||
'Amount',
|
||||
'Product Name',
|
||||
'Product Details',
|
||||
'Subscription Status',
|
||||
'Subscription Period Start',
|
||||
'Subscription Period End',
|
||||
'Next Payment Date'
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Exports/DashboardSelectedExportUser.php
Normal file
64
app/Exports/DashboardSelectedExportUser.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Subscriptions;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class DashboardSelectedExportUser implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $ids;
|
||||
|
||||
public function __construct($ids)
|
||||
{
|
||||
$this->ids = $ids; // Expecting $ids to be an array
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$selectedTransactions = Subscriptions::whereIn('id', $this->ids)
|
||||
->with(['iamPrincipal', 'subscriptionProduct'])
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$serial = 1;
|
||||
$mappedTransactions = collect($selectedTransactions)->map(function ($transaction) use (&$serial) {
|
||||
return [
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'Name' => ($transaction['iam_principal']['first_name'] ?? '') . ' ' . ($transaction['iam_principal']['last_name'] ?? ''),
|
||||
'Customer Id' => $transaction['iam_principal']['id'] ?? '',
|
||||
'Product Name' => $transaction['subscription_product']['product_name'] ?? '',
|
||||
'Product Detail' => $transaction['subscription_product']['product_details'] ?? '',
|
||||
'Amount' => $transaction['amount'],
|
||||
'Payment Details' => $transaction['stripe_customer_id'],
|
||||
'Subscription status' => $transaction['status'],
|
||||
'Subscription Start Date' => Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A'),
|
||||
'Subscription End Date' => Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A'),
|
||||
'Next Payment Date' => Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A')
|
||||
];
|
||||
});
|
||||
|
||||
return new Collection($mappedTransactions);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'Full Name',
|
||||
'Customer Id',
|
||||
'Product Name',
|
||||
'Product Detail',
|
||||
'Amount',
|
||||
'Payment Details',
|
||||
'Subscription status',
|
||||
'Subscription Start Date',
|
||||
'Subscription End Date',
|
||||
'Next Payment Date'
|
||||
];
|
||||
}
|
||||
}
|
||||
184
app/Exports/ExportReports.php
Normal file
184
app/Exports/ExportReports.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use App\Models\ReferralUsers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class ExportReports implements FromView
|
||||
{
|
||||
protected $reportType;
|
||||
protected $states;
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
protected $restaurants;
|
||||
|
||||
public function __construct($reportType, $states, $startDate, $endDate, $restaurants = [])
|
||||
{
|
||||
$this->reportType = $reportType;
|
||||
$this->states = $states;
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
$this->restaurants = $restaurants;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = collect();
|
||||
|
||||
if ($this->reportType === 'Total Subscribed') {
|
||||
$query = Subscriptions::query();
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
// dd($data);
|
||||
} elseif ($this->reportType === 'Total Users') {
|
||||
$query = IamPrincipal::query()->where('principal_type_xid',3);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Redemptions') {
|
||||
$query = RedeemRestaurant::with(['restaurant', 'customer'])->where('is_redeem', 0);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('customer', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Redemptions for Specific Restaurants') {
|
||||
$query = RedeemRestaurant::with('restaurant', 'customer');
|
||||
|
||||
if (!empty($this->restaurants)) {
|
||||
$query->whereIn('manage_restaurants_xid', $this->restaurants);
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Subscriptions Cancelled') {
|
||||
$query = Subscriptions::query()->where('is_cancelled_subscription', 1);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Subscriptions Cancelled') {
|
||||
$query = Subscriptions::with('iamPrincipal')->where('is_cancelled_subscription', 1);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Referrals Made') {
|
||||
$query = ReferralUsers::query()
|
||||
->with(['referredUser', 'referredUser.state'])
|
||||
->whereHas('referredUser', function ($query) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
});
|
||||
|
||||
if (!empty($this->startDate)) {
|
||||
$query->whereDate('referred_date_time', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if (!empty($this->endDate)) {
|
||||
$query->whereDate('referred_date_time', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Referees Joined') {
|
||||
$query = ReferralUsers::query()
|
||||
->with(['refeersUser', 'refeersUser.state'])
|
||||
->whereHas('refeersUser', function ($query) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
});
|
||||
|
||||
if (!empty($this->startDate)) {
|
||||
$query->whereDate('referred_date_time', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if (!empty($this->endDate)) {
|
||||
$query->whereDate('referred_date_time', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
return view('exports.reports', [
|
||||
'data' => $data,
|
||||
'reportType' => $this->reportType
|
||||
]);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,23 @@ class FeedbakExport implements FromCollection, WithHeadings
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
return ManageFeedback::with(['principal', 'feedbackReaction'])->get()->map(function ($feedback) {
|
||||
return ManageFeedback::with(['principal', 'feedbackReaction', 'restaurant'])->get()->map(function ($feedback) {
|
||||
$feedbackType = 'N/A';
|
||||
if ($feedback->is_app_feedback) {
|
||||
$feedbackType = 'App Feedback';
|
||||
} elseif ($feedback->is_restaurant_feedback) {
|
||||
$feedbackType = 'Restaurant Feedback';
|
||||
}
|
||||
|
||||
return [
|
||||
'Customer Id' => $feedback->principal ? $feedback->principal->id : 'N/A',
|
||||
'First Name' => $feedback->principal ? $feedback->principal->first_name : 'N/A',
|
||||
'Last Name' => $feedback->principal ? $feedback->principal->last_name : 'N/A',
|
||||
'Feedback Reaction' => $feedback->feedbackReaction ? $feedback->feedbackReaction->feedback_reaction_title : 'N/A',
|
||||
'Comment' => $feedback->comment,
|
||||
'Date Received' => $feedback->created_at,
|
||||
'Date Received' => \Carbon\Carbon::parse($feedback->created_at)->format('m/d/Y'),
|
||||
'Feedback Type' => $feedbackType,
|
||||
'Restaurant Name' => $feedback->restaurant ? $feedback->restaurant->name : 'N/A',
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -30,7 +39,12 @@ class FeedbakExport implements FromCollection, WithHeadings
|
||||
'Last Name',
|
||||
'Feedback Reaction',
|
||||
'Comment',
|
||||
'Date Received'
|
||||
'Date Received',
|
||||
'App Feedback',
|
||||
'Restaurant Feedback',
|
||||
'Restaurant Name'
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
183
app/Exports/ReportExports.php
Normal file
183
app/Exports/ReportExports.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use App\Models\ReferralUsers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class ReportExports implements FromView
|
||||
{
|
||||
protected $reportType;
|
||||
protected $states;
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
protected $restaurants;
|
||||
|
||||
public function __construct($reportType, $states, $startDate, $endDate, $restaurants = [])
|
||||
{
|
||||
$this->reportType = $reportType;
|
||||
$this->states = $states;
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
$this->restaurants = $restaurants;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = collect();
|
||||
|
||||
if ($this->reportType === 'Total Subscribed') {
|
||||
$query = Subscriptions::query();
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
// dd($data);
|
||||
} elseif ($this->reportType === 'Total Users') {
|
||||
$query = IamPrincipal::query()->where('principal_type_xid',3);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Redemptions') {
|
||||
$query = RedeemRestaurant::with(['restaurant', 'customer'])->where('is_redeem', 0);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('customer', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Redemptions for Specific Restaurants') {
|
||||
$query = RedeemRestaurant::with('restaurant', 'customer');
|
||||
|
||||
if (!empty($this->restaurants)) {
|
||||
$query->whereIn('manage_restaurants_xid', $this->restaurants);
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Subscriptions Cancelled') {
|
||||
$query = Subscriptions::query()->where('is_cancelled_subscription', 1);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Subscriptions Cancelled') {
|
||||
$query = Subscriptions::with('iamPrincipal')->where('is_cancelled_subscription', 1);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereHas('iamPrincipal', function ($q) {
|
||||
$q->whereIn('state_xid', $this->states);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Referrals Made') {
|
||||
$query = ReferralUsers::query()
|
||||
->with(['referredUser', 'referredUser.state'])
|
||||
->whereHas('referredUser', function ($query) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
});
|
||||
|
||||
if (!empty($this->startDate)) {
|
||||
$query->whereDate('referred_date_time', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if (!empty($this->endDate)) {
|
||||
$query->whereDate('referred_date_time', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
elseif ($this->reportType === 'Referees Joined') {
|
||||
$query = ReferralUsers::query()
|
||||
->with(['refeersUser', 'refeersUser.state'])
|
||||
->whereHas('refeersUser', function ($query) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
});
|
||||
|
||||
if (!empty($this->startDate)) {
|
||||
$query->whereDate('referred_date_time', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if (!empty($this->endDate)) {
|
||||
$query->whereDate('referred_date_time', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
return view('exports.report', [
|
||||
'data' => $data,
|
||||
'reportType' => $this->reportType
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,9 @@ class RestaurantExport implements FromCollection, WithHeadings
|
||||
public function collection()
|
||||
{
|
||||
return ManageRestaurant::select(
|
||||
'id',
|
||||
'name',
|
||||
'description',
|
||||
// 'description',
|
||||
'phone_number',
|
||||
'restaurant_id',
|
||||
'address',
|
||||
@@ -36,8 +37,9 @@ class RestaurantExport implements FromCollection, WithHeadings
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Id',
|
||||
'Restaurant Name',
|
||||
'Description',
|
||||
// 'Description',
|
||||
'Phone Number',
|
||||
'Restaurant Id',
|
||||
'Address',
|
||||
|
||||
@@ -27,8 +27,9 @@ class RestaurantExportSelected implements FromCollection, WithHeadings
|
||||
$selected_restaurant = ManageRestaurant::whereIn('id', $selectedCareIds)
|
||||
->orderBy('id', 'Desc')
|
||||
->select(
|
||||
'id',
|
||||
'name',
|
||||
'description',
|
||||
// 'description',
|
||||
'phone_number',
|
||||
'restaurant_id',
|
||||
'address',
|
||||
@@ -50,8 +51,9 @@ class RestaurantExportSelected implements FromCollection, WithHeadings
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Id',
|
||||
'Restaurant Name',
|
||||
'Description',
|
||||
// 'Description',
|
||||
'Phone Number',
|
||||
'Restaurant Id',
|
||||
'Address',
|
||||
|
||||
@@ -5,56 +5,63 @@ namespace App\Exports;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\IamPrincipal;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
|
||||
class customer_export implements FromCollection , WithHeadings
|
||||
class customer_export implements FromCollection, WithHeadings
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$customers = IamPrincipal::where('principal_type_xid', 3)
|
||||
->with(['isSubscribed', 'state'])
|
||||
->select(
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get();
|
||||
|
||||
$serial = 1;
|
||||
return $customers->map(function ($customer) use (&$serial) {
|
||||
$subscription = $customer->isSubscribed->first();
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$isSubscribed = $subscription && $subscription->next_payment_date >= $formattedDateTime && $subscription->status == 'complete' ? 'Subscribed' : 'Unsubscribed';
|
||||
|
||||
public function collection(){
|
||||
return IamPrincipal::where('principal_type_xid',3)
|
||||
->select('first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get()
|
||||
->map(function ($customer) {
|
||||
return [
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth'=> \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
'state_name' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
'subscription_status' => $isSubscribed, // Add the subscription status
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//function header in excel
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_name',
|
||||
'phone_number'
|
||||
|
||||
// Function to provide the headings in Excel
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Email Address',
|
||||
'Date of Birth',
|
||||
'State Name',
|
||||
'Phone Number',
|
||||
'Subscription Status',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ class customer_export_selected implements FromCollection, WithHeadings
|
||||
// Log the ids for debugging purposes
|
||||
Log::info('Fetching data for IDs: ' . implode(',', $this->ids));
|
||||
|
||||
$selected_customer = IamPrincipal::whereIn('id', $this->ids)
|
||||
->with('state:id,name') // Eager load the state relationship
|
||||
$selected_customers = IamPrincipal::whereIn('id', $this->ids)
|
||||
->with(['state:id,name', 'isSubscribed']) // Eager load the state and subscription relationships
|
||||
->orderBy('id', 'desc')
|
||||
->select(
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
@@ -36,33 +37,45 @@ class customer_export_selected implements FromCollection, WithHeadings
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get()
|
||||
->map(function ($customer) {
|
||||
return [
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), // Format the date
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
];
|
||||
});
|
||||
->get();
|
||||
|
||||
$serial = 1;
|
||||
$mappedCustomers = $selected_customers->map(function ($customer) use (&$serial) {
|
||||
$subscription = $customer->isSubscribed->first();
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$isSubscribed = $subscription && $subscription->next_payment_date >= $formattedDateTime && $subscription->status == 'complete' ? 'Subscribed' : 'Unsubscribed';
|
||||
return [
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), // Format the date
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
'subscription_status' => $isSubscribed, // Add the subscription status
|
||||
];
|
||||
});
|
||||
|
||||
// Log the fetched data for debugging purposes
|
||||
Log::info('Fetched customer data: ' . $selected_customer->toJson());
|
||||
Log::info('Fetched customer data: ' . $mappedCustomers->toJson());
|
||||
|
||||
return new Collection($selected_customer);
|
||||
return new Collection($mappedCustomers);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Email Address',
|
||||
'Date of Birth',
|
||||
'State Name',
|
||||
'Phone Number'
|
||||
'Phone Number',
|
||||
'Subscription Status' // Add the heading for subscription status
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
106
app/Exports/restaurant_export.php
Normal file
106
app/Exports/restaurant_export.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\IamPrincipal;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
// class restaurant_export implements FromCollection, WithHeadings
|
||||
// {
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
// $restaurant_users = IamPrincipal::where('principal_type_xid', 4)
|
||||
// ->with('restaurant')
|
||||
// ->select(
|
||||
// 'id',
|
||||
// 'first_name',
|
||||
// 'last_name',
|
||||
// 'email_address',
|
||||
// 'date_of_birth',
|
||||
// 'state_xid',
|
||||
// 'phone_number'
|
||||
// )
|
||||
// ->get();
|
||||
|
||||
// $serial = 1;
|
||||
// return $restaurant_users->map(function ($restaurant_user) use (&$serial) {
|
||||
// return [
|
||||
// 'Sr No.' => $serial++, // Increment serial number
|
||||
// 'id' =>$restaurant_user->id,
|
||||
// 'first_name' => $restaurant_user->first_name,
|
||||
// 'last_name' => $restaurant_user->last_name,
|
||||
// 'email_address' => $restaurant_user->email_address,
|
||||
// 'date_of_birth' => \Carbon\Carbon::parse($restaurant_user->date_of_birth)->format('m/d/Y'),
|
||||
// 'state_xid' =>$restaurant_user->state->name ?? '', // Access the state name and handle null
|
||||
// 'phone_number' => $restaurant_user->phone_number,
|
||||
|
||||
// ];
|
||||
// });
|
||||
// }
|
||||
|
||||
// // Function to provide the headings in Excel
|
||||
// public function headings(): array
|
||||
// {
|
||||
// return [
|
||||
// 'Sr No.',
|
||||
// 'User Id',
|
||||
// 'First Name',
|
||||
// 'Last Name',
|
||||
// 'Email Address',
|
||||
// 'Date of Birth',
|
||||
// 'State Name',
|
||||
// 'Phone Number',
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
class restaurant_export implements FromCollection, WithHeadings
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
// Fetch restaurant users with their related restaurant roles and state
|
||||
$restaurant_users = IamPrincipal::where('principal_type_xid', 4)
|
||||
->with(['getresturant.restaurant', 'state'])
|
||||
->get();
|
||||
|
||||
$serial = 1;
|
||||
return $restaurant_users->flatMap(function ($restaurant_user) use (&$serial) {
|
||||
return $restaurant_user->getresturant->map(function ($role) use (&$serial, $restaurant_user) {
|
||||
return [
|
||||
'Sr No.' => $serial++,
|
||||
'User Id' => $restaurant_user->id,
|
||||
'First Name' => $restaurant_user->first_name,
|
||||
'Last Name' => $restaurant_user->last_name,
|
||||
'Email Address' => $restaurant_user->email_address,
|
||||
'Date of Birth' => \Carbon\Carbon::parse($restaurant_user->date_of_birth)->format('m/d/Y'),
|
||||
// 'State Name' => $restaurant_user->state->name ?? '',
|
||||
'Phone Number' => $restaurant_user->phone_number,
|
||||
'Restaurant Name' => $role->restaurant->name ?? '',
|
||||
'Restaurant Address' => $role->restaurant->address ?? '',
|
||||
];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Email Address',
|
||||
'Date of Birth',
|
||||
// 'State Name',
|
||||
'Phone Number',
|
||||
'Restaurant Name',
|
||||
'Restaurant Address',
|
||||
];
|
||||
}
|
||||
}
|
||||
142
app/Exports/restaurant_export_selected.php
Normal file
142
app/Exports/restaurant_export_selected.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use App\Models\IamPrincipal;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
// class restaurant_export_selected implements FromCollection, WithHeadings
|
||||
// {
|
||||
// protected $ids;
|
||||
|
||||
// public function __construct($ids)
|
||||
// {
|
||||
// $this->ids = is_array($ids) ? $ids : explode(',', $ids);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
// Log::info('Fetching data for IDs: ' . implode(',', $this->ids));
|
||||
|
||||
// $selected_customers = IamPrincipal::whereIn('id', $this->ids)
|
||||
// ->with('state:id,name')
|
||||
// ->orderBy('id', 'desc')
|
||||
// ->select(
|
||||
// 'id',
|
||||
// 'first_name',
|
||||
// 'last_name',
|
||||
// 'email_address',
|
||||
// 'date_of_birth',
|
||||
// 'state_xid',
|
||||
// 'phone_number'
|
||||
// )
|
||||
// ->get();
|
||||
|
||||
// $serial = 1;
|
||||
// $mappedCustomers = $selected_customers->map(function ($customer) use (&$serial) {
|
||||
// return [
|
||||
// 'Sr No.' => $serial++,
|
||||
// 'id' => $customer->id,
|
||||
// 'first_name' => $customer->first_name,
|
||||
// 'last_name' => $customer->last_name,
|
||||
// 'email_address' => $customer->email_address,
|
||||
// 'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
// 'state_xid' => $customer->state->name ?? '',
|
||||
// 'phone_number' => $customer->phone_number,
|
||||
// ];
|
||||
// });
|
||||
|
||||
// Log::info('Fetched customer data: ' . $mappedCustomers->toJson());
|
||||
|
||||
// return new Collection($mappedCustomers);
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// return [
|
||||
// 'Sr No.',
|
||||
// 'User Id',
|
||||
// 'First Name',
|
||||
// 'Last Name',
|
||||
// 'Email Address',
|
||||
// 'Date of Birth',
|
||||
// 'State Name',
|
||||
// 'Phone Number'
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
class restaurant_export_selected implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $ids;
|
||||
|
||||
public function __construct($ids)
|
||||
{
|
||||
$this->ids = is_array($ids) ? $ids : explode(',', $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
Log::info('Fetching data for IDs: ' . implode(',', $this->ids));
|
||||
|
||||
$selected_customers = IamPrincipal::whereIn('id', $this->ids)
|
||||
->with(['state', 'getresturant.restaurant'])
|
||||
->orderBy('id', 'desc')
|
||||
->select(
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get();
|
||||
|
||||
$serial = 1;
|
||||
$mappedCustomers = $selected_customers->flatMap(function ($customer) use (&$serial) {
|
||||
return $customer->getresturant->map(function ($role) use (&$serial, $customer) {
|
||||
return [
|
||||
'Sr No.' => $serial++,
|
||||
'User Id' => $customer->id,
|
||||
'First Name' => $customer->first_name,
|
||||
'Last Name' => $customer->last_name,
|
||||
'Email Address' => $customer->email_address,
|
||||
'Date of Birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
// 'State Name' => optional($customer->state)->name ?? 'NA',
|
||||
'Phone Number' => $customer->phone_number,
|
||||
'Restaurant Name' => optional($role->restaurant)->name ?? 'NA',
|
||||
'Restaurant Address' => optional($role->restaurant)->address ?? 'NA',
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
Log::info('Fetched customer data: ' . $mappedCustomers->toJson());
|
||||
|
||||
return new Collection($mappedCustomers);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Email Address',
|
||||
'Date of Birth',
|
||||
// 'State Name',
|
||||
'Phone Number',
|
||||
'Restaurant Name',
|
||||
'Restaurant Address'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\APIs\CustomerAPIs\AuthServices;
|
||||
@@ -101,7 +101,7 @@ class AuthController extends Controller
|
||||
}
|
||||
},
|
||||
],
|
||||
'phone_number' => 'required|min:10',
|
||||
'phone_number' => 'required|numeric|min:10',
|
||||
// 'address_line1' => 'required|max:50',
|
||||
'state_xid' => 'required',
|
||||
|
||||
@@ -164,7 +164,7 @@ class AuthController extends Controller
|
||||
function ($attribute, $value, $fail) {
|
||||
$existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 3)->whereNull('deleted_at')->exists();
|
||||
if (!$existingUser) {
|
||||
$fail('The selected email address is invalid.');
|
||||
$fail('Entered e-mail address is not in our system.');
|
||||
}
|
||||
},
|
||||
],
|
||||
@@ -269,4 +269,20 @@ class AuthController extends Controller
|
||||
return response()->json(__('something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 19 June 2024
|
||||
* Use : Search State.
|
||||
*/
|
||||
public function searchState(Request $request)
|
||||
{
|
||||
try {
|
||||
return $this->AuthServices->searchState($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Login API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\APIs\CustomerAPIs\CMSApiServices;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\IamPrincipal;
|
||||
@@ -12,6 +12,8 @@ use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Subscriptions;
|
||||
use Stripe\Subscription;
|
||||
|
||||
class CustomerControllerApi extends Controller
|
||||
{
|
||||
@@ -168,7 +170,42 @@ class CustomerControllerApi extends Controller
|
||||
|
||||
if ($token) {
|
||||
$iamPrincipalId = $token['sub'];
|
||||
$deleteUser = IamPrincipal::find($iamPrincipalId);
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
$userId = $iamPrincipalId;
|
||||
|
||||
// dd($id,$stripeSecret);
|
||||
|
||||
$getSubscriptionData = Subscriptions::where('iam_principal_xid', $userId)->where('subscription_status', 'active')->first();
|
||||
if ($getSubscriptionData) {
|
||||
$subscriptionId = $getSubscriptionData->subscription_id;
|
||||
|
||||
$cancelledSubscription = $stripe->subscriptions->update(
|
||||
$subscriptionId,
|
||||
['cancel_at_period_end' => true]
|
||||
);
|
||||
|
||||
$subscriptionFromDatabase = Subscriptions::where('subscription_id', $subscriptionId)->first();
|
||||
$subscriptionFromDatabase->cancelled_at = date('Y-m-d H:i:s', $cancelledSubscription->canceled_at);
|
||||
|
||||
$subscriptionFromDatabase->subscription_status = $cancelledSubscription->status;
|
||||
$subscriptionFromDatabase->is_cancelled_subscription = 1;
|
||||
$subscriptionFromDatabase->status = "cancelled";
|
||||
|
||||
$subscriptionFromDatabase->save();
|
||||
|
||||
|
||||
$getSubscription = $stripe->subscriptions->retrieve($subscriptionFromDatabase->subscription_id, []);
|
||||
|
||||
|
||||
$getSubscribeCustomer = $stripe->customers->retrieve(
|
||||
$subscriptionFromDatabase->stripe_customer_id,
|
||||
[]
|
||||
);
|
||||
}
|
||||
$deleteUser = IamPrincipal::find($userId);
|
||||
$deleteUser->one_signal_player_id = null;
|
||||
$deleteUser->save();
|
||||
|
||||
@@ -187,4 +224,28 @@ class CustomerControllerApi extends Controller
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 15 July 2024
|
||||
* Use : To get user subscription status.
|
||||
*/
|
||||
public function CheckSubscription()
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
$response = $this->CustomerApiServices->CheckSubscription($customerIamId);
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), ['is_subscribed' => $response], 200);
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\FeedbackReaction;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -24,7 +24,7 @@ class NotificationController extends Controller
|
||||
$page = $request->query('page', 1);
|
||||
|
||||
if ($customerIamId) {
|
||||
$notificationsData = NotificationDetails::where('principal_xid', $customerIamId)->orderBy('id', 'Desc')->get();
|
||||
$notificationsData = NotificationDetails::where('principal_xid', $customerIamId)->where('is_active', 1)->orderBy('id', 'Desc')->get();
|
||||
|
||||
$totalItems = $notificationsData->count();
|
||||
$totalPages = ceil($totalItems / $perPage);
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\Customer_API;
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\APIs\CustomerAPIs\RestaurantApiServices;
|
||||
@@ -171,7 +171,7 @@ class RestaurantControllerApi extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 04 June 2024
|
||||
* Use : To redeem restaurant.
|
||||
@@ -198,4 +198,26 @@ class RestaurantControllerApi extends Controller
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 20 June 2024
|
||||
* Use : To search from restaurant.
|
||||
*/
|
||||
public function searchRestaurant(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
return $this->RestaurantApiServices->searchRestaurant($customerIamId, $request);
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\APIs\CustomerAPIs\RulesApiServices;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RulesControllerAPI extends Controller
|
||||
{
|
||||
|
||||
protected $RulesApiServices;
|
||||
|
||||
public function __construct(RulesApiServices $RulesApiServices)
|
||||
{
|
||||
$this->RulesApiServices = $RulesApiServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 19 June 2024
|
||||
* Use : To get voucher rules and regulation.
|
||||
*/
|
||||
public function getVoucherRules()
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
$response = $this->RulesApiServices->getVoucherRules();
|
||||
return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200);
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Voucher rules get data controller function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 22 Jully 2024
|
||||
* Use : To get referral rules and regulation.
|
||||
*/
|
||||
|
||||
public function getReferralRules()
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$customerIamId = $token['sub'];
|
||||
$response = $this->RulesApiServices->getReferralRules();
|
||||
return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200);
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Referral rules get data controller function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\ReferralUsers;
|
||||
use App\Models\SubscriptionProducts;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Http\Request;
|
||||
use Stripe\Event;
|
||||
use Stripe\Stripe;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use DateTime;
|
||||
|
||||
class StripeWebhookController extends Controller
|
||||
{
|
||||
//
|
||||
|
||||
|
||||
public function getWebhook(Request $request)
|
||||
{
|
||||
// dd("ssssss",$request);
|
||||
Log::info('Stripe Webhook Received= in getWebhook ');
|
||||
}
|
||||
public function handleWebhook(Request $request)
|
||||
{
|
||||
Log::info("webhook At line 1");
|
||||
|
||||
// Verify the webhook signature for security
|
||||
$secret = config('constants.subscription.webhook_secret'); // Your webhook secret key
|
||||
|
||||
$payload = $request->getContent();
|
||||
$sigHeader = $request->header('Stripe-Signature');
|
||||
$event = null;
|
||||
|
||||
|
||||
try {
|
||||
$event = Event::constructFrom(
|
||||
json_decode($payload, true),
|
||||
$sigHeader,
|
||||
config('constants.subscription.webhook_secret')
|
||||
);
|
||||
|
||||
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
// Invalid payload
|
||||
return response()->json(['error' => 'Invalid payload'], 400);
|
||||
} catch (\Stripe\Exception\SignatureVerificationException $e) {
|
||||
// Signature verification failed
|
||||
return response()->json(['error' => 'Signature verification failed'], 400);
|
||||
}
|
||||
// $stripeSecret = config('services.stripe.key');
|
||||
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
|
||||
|
||||
|
||||
|
||||
Log::info("webhook called");
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
|
||||
if ($event->type === 'checkout.session.completed') {
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
// Handle successful subscription payment
|
||||
// You can access event data like $event->data->object
|
||||
|
||||
// Session::flush();
|
||||
$session = $event->data->object;
|
||||
|
||||
$metadata = $session->metadata;
|
||||
if ($metadata == null || empty($metadata)) {
|
||||
return response('Webhook Metadata received at null ', 200);
|
||||
}
|
||||
$userId = $metadata->userId;
|
||||
$userEmail = $metadata->userEmail;
|
||||
$subscriptionProductId = $metadata->subscriptionProductXid;
|
||||
|
||||
|
||||
$isReferralSubscription = $metadata->is_referral_subscription;
|
||||
$isCustomReferralCodeApplied = $metadata->isCustomReferralCodeApplied;
|
||||
|
||||
$referralUserId = $metadata->referral_user_id;
|
||||
|
||||
if ($isReferralSubscription == 1 && $isCustomReferralCodeApplied == 0) {
|
||||
//who has refer the Subscription to Current user
|
||||
Log::info("Referral User Subscription Updating Function Starts");
|
||||
|
||||
$referralUserSubscriptionData = Subscriptions::where('iam_principal_xid', $referralUserId)->where('subscription_status', '=', 'active')->first();
|
||||
|
||||
// $stripe->subscriptions->update(
|
||||
// $referralUserSubscriptionData->subscription_id,
|
||||
// ['proration_behavior' => 'none']
|
||||
// );
|
||||
if ($referralUserSubscriptionData && $referralUserSubscriptionData->is_cancelled_subscription == 0) {
|
||||
|
||||
|
||||
//update subscription add 30 days trial period to this subscription
|
||||
$nextPaymentDate = $referralUserSubscriptionData->next_payment_date;
|
||||
|
||||
// we are setting next payment date based on REFERRAL .. IF USER HAS NOT REFERRED YET.. then it will take next_payment_date
|
||||
//Otherwise IT need to take THE LAST REFERRED DATA
|
||||
|
||||
// $userLastReferredDate = ReferralUsers::where('iam_principal_xid',$referralUserId)->last();
|
||||
$userLastReferredDate = ReferralUsers::where('iam_principal_xid', $referralUserId)
|
||||
->orderBy('referred_date_time', 'desc')
|
||||
->first();
|
||||
|
||||
if ($userLastReferredDate) {
|
||||
Log::info("trial date added for multiple time");
|
||||
$date = new DateTime($referralUserSubscriptionData->next_payment_date);
|
||||
// $date = new DateTime($nextPaymentDate);
|
||||
$date->modify('+30 days');
|
||||
} else {
|
||||
$date = new DateTime($nextPaymentDate);
|
||||
}
|
||||
|
||||
|
||||
$newDate = $date->format('Y-m-d H:i:s');
|
||||
Log::info("new Date = ");
|
||||
Log::info($newDate);
|
||||
$timestampForReferralUser = $date->getTimestamp();
|
||||
Log::info($timestampForReferralUser);
|
||||
$updateSubscription = $stripe->subscriptions->update(
|
||||
$referralUserSubscriptionData->subscription_id,
|
||||
['trial_end' => $timestampForReferralUser]
|
||||
);
|
||||
|
||||
$SubscriptionObject = $stripe->subscriptions->retrieve($referralUserSubscriptionData->subscription_id, []);
|
||||
|
||||
$upcoming_invoice = $stripe->invoices->upcoming([
|
||||
'subscription' => $referralUserSubscriptionData->subscription_id, // use retrieved id from subscription
|
||||
]);
|
||||
Log::info("UPCOMING INVOICE");
|
||||
|
||||
Log::info($upcoming_invoice);
|
||||
$referralUserSubscriptionData->current_period_start = date('Y-m-d H:i:s', $SubscriptionObject->current_period_start);
|
||||
$referralUserSubscriptionData->current_period_end = date('Y-m-d H:i:s', $SubscriptionObject->current_period_end);
|
||||
$referralUserSubscriptionData->next_payment_date = date('Y-m-d H:i:s', $upcoming_invoice->next_payment_attempt);
|
||||
$referralUserSubscriptionData->next_invoice_amount = $upcoming_invoice->amount_due / 100;
|
||||
|
||||
$referralUserSubscriptionData->save();
|
||||
|
||||
Log::info("Referral User Subscription Updated with Referral");
|
||||
|
||||
//updated the Referral Users Subscription.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$subscriptionProductData = SubscriptionProducts::where('id', $subscriptionProductId)->first();
|
||||
|
||||
//checkout store in db
|
||||
$subscriptionData = $stripe->checkout->sessions->retrieve($session->id, []);
|
||||
$SubscriptionObject = $stripe->subscriptions->retrieve($subscriptionData->subscription, []);
|
||||
//update proration behavior
|
||||
// $stripe->subscriptions->update(
|
||||
// $subscriptionData->subscription,
|
||||
// ['proration_behavior' => 'none']
|
||||
// );
|
||||
|
||||
//update proration behavior
|
||||
|
||||
$priceObject = $stripe->prices->retrieve($SubscriptionObject->plan->id, []);
|
||||
|
||||
$amountSubtotalDollars = $subscriptionData->amount_total / 100;
|
||||
// Log::info('Subscription has been started ');
|
||||
|
||||
|
||||
|
||||
$subscriptionObjectFromInvoice = $stripe->subscriptions->retrieve($subscriptionData->subscription, []);
|
||||
|
||||
$upcoming_invoice = $stripe->invoices->upcoming([
|
||||
'subscription' => $subscriptionData->subscription, // use retrieved id from subscription
|
||||
]);
|
||||
|
||||
$id = Subscriptions::updateOrCreate(
|
||||
['iam_principal_xid' => $userId,
|
||||
'subscription_product_xid' => $subscriptionProductId],
|
||||
[
|
||||
'subscription_id' => $subscriptionData->subscription,
|
||||
'amount' => $amountSubtotalDollars,
|
||||
'stripe_customer_id' => $subscriptionData->customer,
|
||||
'subscription_status' => $subscriptionObjectFromInvoice->status,
|
||||
'current_period_start' => date('Y-m-d H:i:s', $SubscriptionObject->current_period_start),
|
||||
'current_period_end' => date('Y-m-d H:i:s', $SubscriptionObject->current_period_end),
|
||||
|
||||
'status' => 'complete',
|
||||
'next_payment_date' => date('Y-m-d H:i:s', $upcoming_invoice->next_payment_attempt),
|
||||
'next_invoice_amount' => $upcoming_invoice->amount_due / 100
|
||||
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
if ($isReferralSubscription == 1 && $isCustomReferralCodeApplied == 1) {
|
||||
|
||||
Log::info("new User Subscription Updating Function Starts");
|
||||
|
||||
//update Current User subscription to add 30 days additional to their subscription end
|
||||
$SubscriptionObject = $stripe->subscriptions->retrieve($subscriptionData->subscription, []);
|
||||
$newUserSubscriptionDetails = Subscriptions::where('iam_principal_xid', $userId)
|
||||
->where('subscription_product_xid', $subscriptionProductId)->first();
|
||||
|
||||
$nextPaymentDate = $newUserSubscriptionDetails->next_payment_date;
|
||||
$date = new DateTime($nextPaymentDate);
|
||||
// $date->modify('+30 days');
|
||||
$newDate = $date->format('Y-m-d H:i:s');
|
||||
Log::info("new Date = ");
|
||||
Log::info($newDate);
|
||||
$timestampForReferralUser = $date->getTimestamp();
|
||||
Log::info(" Updating Function Starts");
|
||||
|
||||
$updateSubscription = $stripe->subscriptions->update(
|
||||
$newUserSubscriptionDetails->subscription_id,
|
||||
['trial_end' => $timestampForReferralUser]
|
||||
);
|
||||
Log::info(" Updating Function END");
|
||||
|
||||
|
||||
$SubscriptionObject = $stripe->subscriptions->retrieve($newUserSubscriptionDetails->subscription_id, []);
|
||||
|
||||
$upcoming_invoice = $stripe->invoices->upcoming([
|
||||
'subscription' => $newUserSubscriptionDetails->subscription_id, // use retrieved id from subscription
|
||||
]);
|
||||
$newUserSubscriptionDetails->current_period_start = date('Y-m-d H:i:s', $SubscriptionObject->current_period_start);
|
||||
$newUserSubscriptionDetails->current_period_end = date('Y-m-d H:i:s', $SubscriptionObject->current_period_end);
|
||||
$newUserSubscriptionDetails->next_payment_date = date('Y-m-d H:i:s', $upcoming_invoice->next_payment_attempt);
|
||||
$newUserSubscriptionDetails->next_invoice_amount = $upcoming_invoice->amount_due / 100;
|
||||
|
||||
$newUserSubscriptionDetails->save();
|
||||
|
||||
Log::info("new User Subscription Updated with Referral");
|
||||
|
||||
|
||||
Log::info("Creating entry in Referral User table");
|
||||
Log::info($referralUserId);
|
||||
Log::info($userId);
|
||||
|
||||
Log::info($isCustomReferralCodeApplied);
|
||||
|
||||
|
||||
|
||||
ReferralUsers::create([
|
||||
|
||||
'iam_principal_xid' => $referralUserId, //Referral User Xid
|
||||
'referred_user_xid' => $userId, // new user Id
|
||||
'referred_date_time' => Carbon::now(),
|
||||
'isCustomReferralCodeApplied' =>$isCustomReferralCodeApplied
|
||||
]);
|
||||
Log::info("Created entry in Referral User table");
|
||||
|
||||
}
|
||||
|
||||
$getUserData = IamPrincipal::where('id', $userId)->first();
|
||||
|
||||
$title = "Congratulations your subscription is now active";
|
||||
$message = $getUserData->first_name . " has subscribed for " . $subscriptionProductData->product_name;
|
||||
$content_type = "new_subscription";
|
||||
|
||||
onesignalhelper::sendNotificationApi($getUserData->one_signal_player_id, $title, $message, $content_type, $image = null, $id = null);
|
||||
|
||||
Log::info('Subscription Taken Successfully by ');
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage());
|
||||
// return response()->json(['error' => __('something_went_wrong')], 500);
|
||||
Log::error('Customer Subscription Checkout session function failed: ' . $e->getMessage() . $e->getLine());
|
||||
DB::rollBack();
|
||||
|
||||
|
||||
}
|
||||
//end
|
||||
}
|
||||
|
||||
if ($event->type === 'invoice.payment_succeeded') {
|
||||
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
$invoice = $event->data->object;
|
||||
|
||||
$metadata = $invoice->metadata;
|
||||
|
||||
//
|
||||
$productID = $invoice->lines->data[0]->price->product;
|
||||
$subscriptionProductData = SubscriptionProducts::where('stripe_product_id', $productID)->first();
|
||||
|
||||
$customerID = $invoice->customer;
|
||||
|
||||
$subscriptionId = $invoice->lines->data[0]->subscription;
|
||||
|
||||
$subscriptionObject = $stripe->subscriptions->retrieve($subscriptionId, []);
|
||||
|
||||
$upcoming_invoice = $stripe->invoices->upcoming([
|
||||
'subscription' => $subscriptionId, // use retrieved id from subscription
|
||||
]);
|
||||
|
||||
|
||||
$isCustomerStoredInSubscriptionTable = Subscriptions::where('stripe_customer_id', $customerID)->first();
|
||||
if ($isCustomerStoredInSubscriptionTable == null) {
|
||||
return response('Webhook received at null ', 200);
|
||||
}
|
||||
|
||||
$subscriptionInDatabase = Subscriptions::where('stripe_customer_id', $customerID)->where('subscription_id', $subscriptionId)->where('is_cancelled_subscription', 0)->first();
|
||||
|
||||
$subscriptionInDatabase->subscription_status = $subscriptionObject->status;
|
||||
$subscriptionInDatabase->current_period_end = date('Y-m-d H:i:s', $upcoming_invoice->next_payment_attempt);
|
||||
$subscriptionInDatabase->status = 'complete';
|
||||
$subscriptionInDatabase->next_payment_date = date('Y-m-d H:i:s', $upcoming_invoice->next_payment_attempt);
|
||||
$subscriptionInDatabase->save();
|
||||
|
||||
|
||||
$iamPrincialData = IamPrincipal::where('id', $subscriptionInDatabase->iam_principal_xid)->first();
|
||||
|
||||
|
||||
|
||||
$title = "Congratulations your Subscription has been Renewed";
|
||||
$message = $iamPrincialData->first_name . " has subscribed for " . $subscriptionProductData->product_name;
|
||||
$content_type = "recurring_subscription";
|
||||
|
||||
onesignalhelper::sendNotificationApi($iamPrincialData->one_signal_player_id, $title, $message, $content_type, $image = null, $id = null);
|
||||
|
||||
Log::info("Recurring Subscription has been Updated");
|
||||
DB::commit();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage());
|
||||
// return response()->json(['error' => __('something_went_wrong')], 500);
|
||||
|
||||
DB::rollBack();
|
||||
Log::error('Customer Subscription Invoice payment function failed:' . $e->getMessage());
|
||||
|
||||
}
|
||||
// write your code here
|
||||
// after successful event this actions will be taken
|
||||
|
||||
//hritik code
|
||||
|
||||
}
|
||||
|
||||
return response('Webhook received', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\APIs\Customer_API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CustomReferralCode;
|
||||
use App\Models\Faq;
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\SubscriptionProducts;
|
||||
use App\Models\Subscriptions;
|
||||
use App\Services\APIs\CustomerAPIs\RulesApiServices;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class SubscriptionController extends Controller
|
||||
{
|
||||
|
||||
|
||||
//created by; Hritik
|
||||
//On - 28th June ,2024
|
||||
//use - to get Data of User in Webview and show list of product
|
||||
public function mySubscription(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
$getCustomToken = CustomReferralCode::where('is_active',1)->first();
|
||||
// $token = true;
|
||||
|
||||
// dd($token, Session::get('vendorToken'));
|
||||
if ($token) {
|
||||
// $user_id = 104;
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $user_id)
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->first();
|
||||
|
||||
$userData = IamPrincipal::where('id', $user_id)->first();
|
||||
|
||||
// $request['iam_principal_id'] = $user_id;
|
||||
|
||||
|
||||
$products = SubscriptionProducts::where('is_active', '1')->get();
|
||||
|
||||
if ($isSubscribedUser) {
|
||||
|
||||
return view("Admin.pages.subscriptions.my-subscription", compact('user_id', 'userData', 'isSubscribedUser', 'products'));
|
||||
}
|
||||
$productList = SubscriptionProducts::where('is_active', 1)->first();
|
||||
$faqs = Faq::where('faq_category_id',3)->where('is_active','1')->get(); //getting only subscription faqS
|
||||
|
||||
return view('Admin.pages.subscriptions.list-of-products', compact('productList', 'userData','faqs','getCustomToken'));
|
||||
} else {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//created by; Hritik
|
||||
//On - 28th June ,2024
|
||||
//use - to get Data of User in Webview and show list of product
|
||||
|
||||
|
||||
public function listOfProduct(Request $request)
|
||||
{
|
||||
try {
|
||||
$productList = SubscriptionProducts::where('is_active', 1)->first();
|
||||
|
||||
return view('Admin.pages.subscriptions.list-of-products', compact('productList'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//created by; Hritik
|
||||
//On - 02th July ,2024
|
||||
//use - to Create Subscription Product & price for Monthly
|
||||
|
||||
public function createStripeProduct(Request $request)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
|
||||
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
// dd($stripeSecret,$stripe,$request->all());
|
||||
|
||||
$validator = $this->validateSubscriptionsproductForm($request);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Stripe subscriptions plan validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 203);
|
||||
}
|
||||
|
||||
$id = SubscriptionProducts::create([
|
||||
'product_name' => $request->product_name,
|
||||
'product_value' => $request->product_value,
|
||||
'product_details' => $request->product_details,
|
||||
]);
|
||||
|
||||
$productCreate = $stripe->products->create([
|
||||
'name' => $request->product_name,
|
||||
]);
|
||||
|
||||
$updateCreatedPlan = SubscriptionProducts::where('id', $id->id)->update([
|
||||
'stripe_product_id' => $productCreate->id
|
||||
]);
|
||||
|
||||
|
||||
$totalPrice = $request->product_value;
|
||||
if ($totalPrice && $totalPrice != 0 && $totalPrice != null) {
|
||||
$productPrice1 = $stripe->prices->create([
|
||||
'unit_amount' => $totalPrice * 100,
|
||||
// amount entered by Admin (in cents)
|
||||
'currency' => 'usd',
|
||||
'recurring' => ['interval' => 'month'],
|
||||
'product' => $productCreate->id,
|
||||
'nickname' => 'Monthly Price',
|
||||
|
||||
]);
|
||||
|
||||
$updateCreatedPlan = SubscriptionProducts::where('id', $id->id)->update([
|
||||
'stripe_price_id' => $productPrice1->id
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'), 200);
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
Log::error('Favourite Restaurant service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//update trial Period
|
||||
public function updateTrialPeriod(Request $request)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$stripeSecret = config('constants.subscription.stripe_secret_key');
|
||||
|
||||
$validator = Validator::make(
|
||||
$request->all(),
|
||||
[
|
||||
|
||||
'stripe_id' => 'required',
|
||||
'timestamp_to_update' => 'required',
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Stripe subscriptions plan validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 203);
|
||||
}
|
||||
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
// dd($stripeSecret,$stripe,$request->all());
|
||||
|
||||
$stripeId = $request->stripe_id;
|
||||
$timestamp = $request->timestamp_to_update;
|
||||
|
||||
|
||||
$updateSubscription = $stripe->subscriptions->update(
|
||||
$stripeId,
|
||||
['trial_end' => $timestamp] //8 RD aUG
|
||||
);
|
||||
//8 sept
|
||||
|
||||
// 13th aug
|
||||
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage('success.save_data', $updateSubscription);
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
Log::error('Favourite Restaurant service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function validateSubscriptionsproductForm(Request $request)
|
||||
{
|
||||
return Validator::make(
|
||||
$request->all(),
|
||||
[
|
||||
|
||||
'product_name' => 'required',
|
||||
'product_value' => 'required',
|
||||
'product_details' => 'required',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//created by; Hritik
|
||||
//On - 02th July ,2024
|
||||
//use - to Create Subscription
|
||||
|
||||
public function subscriptionToPlan(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$isCustomReferralCodeApplied = 0;
|
||||
$customReferralCode = CustomReferralCode::where('referral_code', $request->referral_code_to_check)->where('is_active',1)->first();
|
||||
|
||||
if($customReferralCode && $customReferralCode->referral_code &&
|
||||
$customReferralCode->referral_code == $request->referral_code_to_check){
|
||||
$isCustomReferralCodeApplied = 1;
|
||||
}else{
|
||||
$isCustomReferralCodeApplied = 0;
|
||||
}
|
||||
$isReferralSubscription = 0;
|
||||
$referralUserId = $request->referral_user_id;
|
||||
if ($referralUserId && $referralUserId != null) {
|
||||
$isReferralSubscription = 1;
|
||||
} else {
|
||||
$isReferralSubscription = 0;
|
||||
}
|
||||
|
||||
$userId = $request->user_id;
|
||||
$subscriptionProductXid = $request->subscription_product_xid;
|
||||
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
// $taxId = (config('services.stripe.tax_id'));
|
||||
|
||||
$userData = IamPrincipal::where('id', $userId)->first();
|
||||
|
||||
if ($userData) {
|
||||
|
||||
$subscriptionPlan = SubscriptionProducts::where('id', $subscriptionProductXid)->first();
|
||||
|
||||
|
||||
if ($subscriptionPlan && $subscriptionPlan->stripe_price_id && $subscriptionPlan->stripe_price_id != null) {
|
||||
$checkout = $stripe->checkout->sessions->create([
|
||||
'customer_email' => $userData->email_address,
|
||||
'line_items' => [
|
||||
[
|
||||
'price' => $subscriptionPlan->stripe_price_id,
|
||||
'quantity' => 1,
|
||||
// 'tax_rates'=>[$taxId],
|
||||
],
|
||||
],
|
||||
'mode' => 'subscription',
|
||||
// 'allow_promotion_codes' => true,
|
||||
// 'tax_id_collection' => ['enabled' => true],
|
||||
'metadata' => [
|
||||
'userId' => $userData->id,
|
||||
'userEmail' => $userData->email_address,
|
||||
'subscriptionProductXid' => $subscriptionProductXid,
|
||||
|
||||
'is_referral_subscription' => $isReferralSubscription,
|
||||
'referral_user_id' => $referralUserId,
|
||||
'isCustomReferralCodeApplied'=> $isCustomReferralCodeApplied
|
||||
|
||||
],
|
||||
'success_url' => route('thankyou'),
|
||||
|
||||
// 'cancel_url' => "http://localhost/cheerstothe_season_2_o/my-subscription-page",
|
||||
]);
|
||||
|
||||
return Redirect::away($checkout->url);
|
||||
//note:-for now i am just sending the cveonly=0 and lmacve=1 for reference .'&lmacve=1&cveonly=0'
|
||||
} else {
|
||||
return redirect()->back()->with(['error' => "Something went wrong while subscription!"]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
// return redirect()->back()->with(['error' => "Something went wrong while subscription!" . $e->getMessage()]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function thankyou(Request $request)
|
||||
{
|
||||
|
||||
return view('Admin.pages.subscriptions.thank-you');
|
||||
}
|
||||
|
||||
//created by; Hritik
|
||||
//On - 28th May ,2024
|
||||
//use - To cancel the subscription of user on end of subscription end period
|
||||
|
||||
public function cancelSubscription(Request $request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
$userId = $request->iam_principal_xid;
|
||||
|
||||
// dd($request->all(),$stripeSecret);
|
||||
|
||||
$getSubscriptionData = Subscriptions::where('iam_principal_xid', $userId)->where('subscription_status', 'active')->first();
|
||||
|
||||
$subscriptionId = $getSubscriptionData->subscription_id;
|
||||
|
||||
$cancelledSubscription = $stripe->subscriptions->update(
|
||||
$subscriptionId,
|
||||
['cancel_at_period_end' => true]
|
||||
);
|
||||
|
||||
$subscriptionFromDatabase = Subscriptions::where('subscription_id', $subscriptionId)->first();
|
||||
$subscriptionFromDatabase->cancelled_at = date('Y-m-d H:i:s', $cancelledSubscription->canceled_at);
|
||||
|
||||
$subscriptionFromDatabase->subscription_status = $cancelledSubscription->status;
|
||||
$subscriptionFromDatabase->is_cancelled_subscription = 1; //2 for cancelled
|
||||
$subscriptionFromDatabase->status = "cancelled";
|
||||
|
||||
$subscriptionFromDatabase->save();
|
||||
|
||||
|
||||
$getSubscription = $stripe->subscriptions->retrieve($subscriptionFromDatabase->subscription_id, []);
|
||||
|
||||
|
||||
$getSubscribeCustomer = $stripe->customers->retrieve(
|
||||
$subscriptionFromDatabase->stripe_customer_id,
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
DB::commit();
|
||||
return redirect()->route('cancel-subscription-thank-you');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
|
||||
return redirect()->back()->with(['error' => "Something went wrong while cancelling subscription!" . $e->getMessage()]);
|
||||
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Created By : Hritik
|
||||
* Created at : 05 Jult 2024
|
||||
* Use : To get Cancel Subscription Success page.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function cancelSubscriptionThankYou(Request $request)
|
||||
{
|
||||
|
||||
|
||||
return view('Admin.pages.subscriptions.cancel-thank-you');
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Hritik
|
||||
* Created at : 05 Jult 2024
|
||||
* Use : To Apply Referral Code and return the User Id.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
public function applyReferralCode(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$referralCode = $request->input('referral_code');
|
||||
$currentUserId = $request->input('current_iam_principal_xid');
|
||||
$code = IamPrincipal::where('referral_code', $referralCode)->where('id', '!=', $currentUserId)->where('principal_type_xid', 3)->first();
|
||||
$customCode = CustomReferralCode::where('is_active',1)->where('referral_code',$referralCode)->first();
|
||||
if ($code ) {
|
||||
return response()->json(['success' => true, 'message' => 'Successfully applied referral code!', 'referralUserId' => $code->id ,'referral_code'=>$referralCode]);
|
||||
} else if( $customCode) {
|
||||
return response()->json(['success' => true, 'message' => 'Successfully applied referral code!', 'referralUserId' => 2 ,'referral_code'=>$referralCode]); //2 is admin Id //need to change when principal typr_xid = 1
|
||||
|
||||
}else{
|
||||
return response()->json(['success' => false, 'message' => 'Invalid referral code.']);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\APIs\RestaurantService\RedeemApiService;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
|
||||
use App\Services\APIs\RestaurantService\RestAuthApiService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -127,9 +127,9 @@ class RestAuthApiController extends Controller
|
||||
'string',
|
||||
'email',
|
||||
function ($attribute, $value, $fail) {
|
||||
$existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->whereNull('deleted_at')->exists();
|
||||
$existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->where('is_active', 1)->whereNull('deleted_at')->exists();
|
||||
if (!$existingUser) {
|
||||
$fail('The selected email address is invalid.');
|
||||
$fail('Entered e-mail address is not in our system..');
|
||||
}
|
||||
},
|
||||
],
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
use App\Services\APIs\RestaurantService\RestCMSService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
use App\Models\NotificationDetails;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\APIs\RestaurantApi;
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -98,10 +98,10 @@ class RestaurantControllerApi extends Controller
|
||||
'phone_number' => 'required',
|
||||
'address' => 'required',
|
||||
'bio' => 'required',
|
||||
'try_on_1' => 'required',
|
||||
'try_on_2' => 'required',
|
||||
'try_on_3' => 'required',
|
||||
'try_on_4' => 'required',
|
||||
'try_on_1' => 'required|max:18',
|
||||
'try_on_2' => 'required|max:18',
|
||||
'try_on_3' => 'required|max:18',
|
||||
'try_on_4' => 'required|max:18',
|
||||
|
||||
|
||||
|
||||
@@ -3,10 +3,18 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CustomReferralCode;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\IamPrincipal;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use Carbon\Carbon;
|
||||
use App\Exports\DashboardExportUser;
|
||||
use App\Exports\DashboardSelectedExportUser;
|
||||
use App\Models\ReferralUsers;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
|
||||
class DashboardController extends Controller
|
||||
@@ -17,14 +25,57 @@ class DashboardController extends Controller
|
||||
* Use : To show the dashboard.
|
||||
*/
|
||||
|
||||
// public function showDashboard(){
|
||||
|
||||
|
||||
// return view('Admin.dashboard');
|
||||
// }
|
||||
public function showDashboard()
|
||||
{
|
||||
// Monthly data
|
||||
|
||||
|
||||
$dailyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("DATE(created_at) as date"))
|
||||
->whereBetween('created_at', [now()->subDays(7), now()]) // Fetch data for the last 7 days
|
||||
->groupBy(DB::raw("DATE(created_at)"))
|
||||
->orderBy(DB::raw("DATE(created_at)"))
|
||||
->pluck('count', 'date')
|
||||
->toArray();
|
||||
$customReferralCode = CustomReferralCode::where('is_active', 1)->first();
|
||||
|
||||
$start_date = now()->subDays(7)->startOfDay();
|
||||
$end_date = now()->endOfDay();
|
||||
$formattedDailyData = [];
|
||||
while ($start_date <= $end_date) {
|
||||
$formattedDailyData[$start_date->format('Y-m-d')] = $dailyData[$start_date->format('Y-m-d')] ?? 0;
|
||||
$start_date->addDay();
|
||||
}
|
||||
|
||||
$defaultData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->whereYear('created_at', date('Y'))
|
||||
->groupBy(DB::raw("MONTH(created_at)"))
|
||||
->orderBy(DB::raw("MONTH(created_at)"))
|
||||
->pluck('count', 'month')
|
||||
->toArray();
|
||||
|
||||
$months = range(1, 12);
|
||||
$formattedDefaultData = [];
|
||||
foreach ($months as $month) {
|
||||
$formattedDefaultData[$month] = $defaultData[$month] ?? 0;
|
||||
}
|
||||
|
||||
$quarterlyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter"))
|
||||
->whereYear('created_at', date('Y'))
|
||||
->groupBy(DB::raw("QUARTER(created_at)"))
|
||||
->orderBy(DB::raw("QUARTER(created_at)"))
|
||||
->pluck('count', 'quarter')
|
||||
->toArray();
|
||||
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$quarterlyData[$i] = $quarterlyData[$i] ?? 0;
|
||||
}
|
||||
|
||||
ksort($quarterlyData);
|
||||
|
||||
$yearlyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year"))
|
||||
->groupBy(DB::raw("YEAR(created_at)"))
|
||||
->pluck('count', 'year')
|
||||
->toArray();
|
||||
|
||||
$dataMonthlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->where('principal_type_xid', 3)
|
||||
->whereYear('created_at', date('Y'))
|
||||
@@ -33,20 +84,16 @@ class DashboardController extends Controller
|
||||
->pluck('count', 'month')
|
||||
->toArray();
|
||||
|
||||
$dataMonthlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->where('principal_type_xid', 4)
|
||||
$dataMonthlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->whereYear('created_at', date('Y'))
|
||||
->groupBy(DB::raw("MONTH(created_at)"))
|
||||
->orderBy(DB::raw("MONTH(created_at)"))
|
||||
->pluck('count', 'month')
|
||||
->toArray();
|
||||
|
||||
// Fill missing months with zeros
|
||||
$months = range(1, 12);
|
||||
$dataMonthlyWithType3 = array_replace(array_fill_keys($months, 0), $dataMonthlyWithType3);
|
||||
$dataMonthlyWithType4 = array_replace(array_fill_keys($months, 0), $dataMonthlyWithType4);
|
||||
|
||||
// Quarterly data
|
||||
$dataQuarterlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter"))
|
||||
->where('principal_type_xid', 3)
|
||||
->groupBy(DB::raw("QUARTER(created_at)"))
|
||||
@@ -54,8 +101,7 @@ class DashboardController extends Controller
|
||||
->pluck('count', 'quarter')
|
||||
->toArray();
|
||||
|
||||
$dataQuarterlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter"))
|
||||
->where('principal_type_xid', 4)
|
||||
$dataQuarterlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("QUARTER(created_at) as quarter"))
|
||||
->groupBy(DB::raw("QUARTER(created_at)"))
|
||||
->orderBy(DB::raw("QUARTER(created_at)"))
|
||||
->pluck('count', 'quarter')
|
||||
@@ -66,31 +112,302 @@ class DashboardController extends Controller
|
||||
$dataQuarterlyWithType3 = array_replace(array_fill_keys($quarters, 0), $dataQuarterlyWithType3);
|
||||
$dataQuarterlyWithType4 = array_replace(array_fill_keys($quarters, 0), $dataQuarterlyWithType4);
|
||||
|
||||
// Yearly data
|
||||
$dataYearlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year"))
|
||||
->where('principal_type_xid', 3)
|
||||
->groupBy(DB::raw("YEAR(created_at)"))
|
||||
->pluck('count', 'year')
|
||||
->toArray();
|
||||
|
||||
$dataYearlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year"))
|
||||
->where('principal_type_xid', 4)
|
||||
$dataYearlyWithType4 = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year"))
|
||||
->groupBy(DB::raw("YEAR(created_at)"))
|
||||
->pluck('count', 'year')
|
||||
->toArray();
|
||||
|
||||
$customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count();
|
||||
$customerCount = IamPrincipal::where('principal_type_xid', 3)->count();
|
||||
$restaurantCount = ManageRestaurant::where('is_active', 1)->count();
|
||||
$formattedDateTime = now()->format('Y-m-d H:i:s');
|
||||
|
||||
return view('Admin.dashboard', compact(
|
||||
'customerCount',
|
||||
'restaurantCount',
|
||||
'dataMonthlyWithType3',
|
||||
'dataMonthlyWithType4',
|
||||
'dataQuarterlyWithType3',
|
||||
'dataQuarterlyWithType4',
|
||||
'dataYearlyWithType3',
|
||||
'dataYearlyWithType4'
|
||||
));
|
||||
$recent_transactions = Subscriptions::with('subscription')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
$formatted_transactions = $recent_transactions->map(function ($transaction) {
|
||||
return [
|
||||
'id' => $transaction->id,
|
||||
'subscription' => $transaction->subscription ? [
|
||||
'first_name' => $transaction->subscription->first_name,
|
||||
'last_name' => $transaction->subscription->last_name,
|
||||
'id' => $transaction->subscription->id,
|
||||
] : null,
|
||||
'amount' => $transaction->amount,
|
||||
'subscription_id' => $transaction->subscription_id,
|
||||
'stripe_customer_id' => $transaction->stripe_customer_id,
|
||||
'status' => $transaction->status,
|
||||
'current_period_start' => $transaction->current_period_start ? Carbon::parse($transaction->current_period_start)->format('m/d/Y') : null,
|
||||
'current_period_end' => $transaction->current_period_end ? Carbon::parse($transaction->current_period_end)->format('m/d/Y') : null,
|
||||
'next_payment_date' => $transaction->next_payment_date ? Carbon::parse($transaction->next_payment_date)->format('m/d/Y') : null,
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
$response = ReferralUsers::with(['referredUser', 'refeersUser'])->latest()->get()->toArray();
|
||||
|
||||
$referralData = [];
|
||||
|
||||
foreach ($response as $item) {
|
||||
$principalId = $item['iam_principal_xid'];
|
||||
|
||||
if (!isset($referralData[$principalId])) {
|
||||
$referralData[$principalId] = [
|
||||
'referred_user' => $item['referred_user'],
|
||||
'refeers_users' => []
|
||||
];
|
||||
}
|
||||
|
||||
// Add the refeers_user to the respective principalId
|
||||
if (isset($item['refeers_user'])) {
|
||||
$referralData[$principalId]['refeers_users'][] = $item['refeers_user'];
|
||||
}
|
||||
}
|
||||
|
||||
return view(
|
||||
'Admin.dashboard',
|
||||
compact(
|
||||
'customReferralCode',
|
||||
'customerCount',
|
||||
'restaurantCount',
|
||||
'dataMonthlyWithType3',
|
||||
'dataMonthlyWithType4',
|
||||
'dataQuarterlyWithType3',
|
||||
'dataQuarterlyWithType4',
|
||||
'dataYearlyWithType3',
|
||||
'dataYearlyWithType4',
|
||||
'formatted_transactions',
|
||||
'dailyData',
|
||||
'formattedDailyData',
|
||||
'defaultData',
|
||||
'formattedDefaultData',
|
||||
'quarterlyData',
|
||||
'yearlyData',
|
||||
'referralData'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Hritik
|
||||
Created at : 02 Aug 2024
|
||||
Use : To Store or Update Custom Referral Code
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function createOrUpdateReferralCode(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
// dd($request->all());
|
||||
|
||||
DB::beginTransaction();
|
||||
if($request->id){
|
||||
CustomReferralCode::where('id', $request->id)->update([
|
||||
'referral_code' => $request->referral_code,
|
||||
]);
|
||||
}else{
|
||||
CustomReferralCode::create([
|
||||
'referral_code' => $request->referral_code,
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status_code' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('Storing Referral Code function failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Something went wrong while storing Data.', 'status_code' => 500], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 08 July 2024
|
||||
Use : To Get Excel.
|
||||
*/
|
||||
|
||||
|
||||
// public function exportRecentTransactions(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// if ($request->has('all_id')) {
|
||||
// $recentTransaction = Subscriptions::with('subscription')->get()->toArray();
|
||||
// return Excel::download(new DashboardExportUser($recentTransaction), 'recent_transactions.xlsx');
|
||||
// }
|
||||
|
||||
// $ids = $request->input('selected_id');
|
||||
// $fileName = 'selected_customer_transaction_data.xlsx';
|
||||
// return Excel::download(new DashboardSelectedExportUser($ids), $fileName);
|
||||
// } catch (\Exception $e) {
|
||||
// return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function exportRecentTransactions(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
$recentTransaction = Subscriptions::with(['iamPrincipal', 'subscriptionProduct'])->get()->toArray();
|
||||
return Excel::download(new DashboardExportUser($recentTransaction), 'recent_transactions.xlsx');
|
||||
}
|
||||
|
||||
$ids = $request->input('selected_id');
|
||||
if (!is_array($ids)) {
|
||||
$ids = explode(',', $ids);
|
||||
}
|
||||
$fileName = 'selected_customer_transaction_data.xlsx';
|
||||
return Excel::download(new DashboardSelectedExportUser($ids), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Export Failed " . $e->getMessage());
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To get the page.
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
$referralCodes = CustomReferralCode::orderBy('id', 'desc')->get();
|
||||
// return $location;
|
||||
return view('Admin.pages.manage_referral_codes.index', compact('referralCodes'));
|
||||
}
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To store the location.
|
||||
*/
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$request->validate([
|
||||
'referral_code' => 'required|string|max:15',
|
||||
|
||||
]);
|
||||
|
||||
try {
|
||||
if (CustomReferralCode::where('referral_code', $request->referral_code)->exists()) {
|
||||
return response()->json(['success' => false, 'error' => 'Referral Code name already exists', 'status' => 422]);
|
||||
}
|
||||
|
||||
// new location
|
||||
$storeCode = new CustomReferralCode();
|
||||
$storeCode->referral_code = $request->referral_code;
|
||||
$storeCode->save();
|
||||
|
||||
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To change status.
|
||||
*/
|
||||
public function change_referral_code_status(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
// dd($request->all());
|
||||
DB::beginTransaction();
|
||||
$status = CustomReferralCode::find($request->referral_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
// return response()->json(['status' => 200]);
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Update Status function Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To delete location.
|
||||
*/
|
||||
public function delete_referral_code($id)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$passport = CustomReferralCode::find($id);
|
||||
$passport->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("delete_location function Load Failed " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To update location.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function update_referral_code(Request $request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
// Find the location data
|
||||
$updateReferralCode = CustomReferralCode::find($request->id);
|
||||
if (!$updateReferralCode) {
|
||||
return response()->json(['success' => false, 'error' => 'Referral Code not found', 'status' => 404]);
|
||||
}
|
||||
|
||||
// Update the location data
|
||||
$updateReferralCode->referral_code = $request->referral_code;
|
||||
$updateReferralCode->save();
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'message' => __('success.update_data'), 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Failed to update Code: " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'error' => __('auth.something_went_wrong'), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class LoginController extends Controller
|
||||
*/
|
||||
public function add_forgot_password(Request $request)
|
||||
{
|
||||
$user = DB::table('iam_principal')->where('email_address', $request->email)->first();
|
||||
$user = DB::table('iam_principal')->where('email_address', $request->email)->where('principal_type_xid', 1)->first();
|
||||
if (!$user) {
|
||||
return jsonResponseWithErrorMessage(__('auth.email'), 404);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,13 @@ class ManageContactUsController extends Controller
|
||||
$isReply = $request->query('is_reply');
|
||||
|
||||
if ($isReply == 1) {
|
||||
$queries = ManageContactUs::with('customer')->where('is_reply', 1)->orderBy('id','asc')->get();
|
||||
$queries = ManageContactUs::with('customer')->where('is_reply', 1)->orderBy('id','desc')->get();
|
||||
} elseif ($isReply == 0 && $isReply != null) {
|
||||
$queries = ManageContactUs::with('customer')->where('is_reply', 0)->orderBy('id','asc')->get();
|
||||
$queries = ManageContactUs::with('customer')->where('is_reply', 0)->orderBy('id','desc')->get();
|
||||
} else {
|
||||
$queries = ManageContactUs::with('customer')->orderBy('id','asc')->get();
|
||||
$queries = ManageContactUs::with('customer')->orderBy('id','desc')->get();
|
||||
}
|
||||
// return $queries;
|
||||
return view('Admin.pages.manage_contact_us.manage_contact', compact('queries'));
|
||||
}
|
||||
|
||||
@@ -36,36 +37,37 @@ class ManageContactUsController extends Controller
|
||||
* Created at : 10 June 2024
|
||||
* Use : To send reply.
|
||||
*/
|
||||
|
||||
public function sendReply(Request $request)
|
||||
{
|
||||
if (!$request->user_id || $request->user_id == null) {
|
||||
return response()->json(['error' => 'User not found'], 404);
|
||||
}
|
||||
$userId = $request->user_id;
|
||||
|
||||
|
||||
|
||||
$query = ManageContactus::find($userId);
|
||||
if (!$query) {
|
||||
return response()->json(['error' => 'Query not found'], 404);
|
||||
}
|
||||
|
||||
|
||||
$request->validate([
|
||||
'reply_message' => 'required|string',
|
||||
]);
|
||||
|
||||
|
||||
$query->reply_message = $request->input('reply_message');
|
||||
$query->is_reply = true;
|
||||
$query->save();
|
||||
|
||||
|
||||
try {
|
||||
Mail::to($query->email)->send(new \App\Mail\ReplyMail($query));
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => 'Failed to send email', 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
|
||||
return response()->json(['message' => 'Reply sent successfully']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Exports\CustomerExportSelected;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Barryvdh\DomPDF\PDF as DomPDFPDF;
|
||||
@@ -37,18 +38,28 @@ class ManageCustomerController extends Controller
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
// Eager load the state relationship for all customers
|
||||
$customers = IamPrincipal::where('principal_type_xid', 3)
|
||||
->with('state')
|
||||
$customers = IamPrincipal::with(['isSubscribed', 'state'])
|
||||
->where('principal_type_xid', 3)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$customer->is_subscribed = $customer->isSubscribed->contains(function ($subscription) use ($formattedDateTime) {
|
||||
return $subscription->status == 'complete' && $subscription->next_payment_date >= $formattedDateTime;
|
||||
});
|
||||
}
|
||||
|
||||
return view('Admin.pages.manage_users.manage_customer.customer', compact('customers'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("Manage Voucher Page Not Load " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
@@ -56,13 +67,14 @@ class ManageCustomerController extends Controller
|
||||
*/
|
||||
public function view_customer($id)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
$customers_data = IamPrincipal::with('state','contactMessages')->findOrFail($id);
|
||||
$customers_data = IamPrincipal::with('state', 'contactMessages', 'isSubscribed')->findOrFail($id);
|
||||
if ($customers_data->contactMessages->isEmpty()) {
|
||||
Log::info('No contact messages found for customer with ID: ' . $id);
|
||||
}
|
||||
if ($customers_data->isSubscribed->isEmpty()) {
|
||||
Log::info('No payment history found for customer with ID: ' . $id);
|
||||
}
|
||||
// return $customers_data;
|
||||
return view('Admin.pages.manage_users.manage_customer.view_customer_details', compact('customers_data'));
|
||||
} catch (Exception $e) {
|
||||
@@ -222,44 +234,45 @@ class ManageCustomerController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
Use : To Get Excel.
|
||||
*/
|
||||
|
||||
|
||||
public function exportSelectedCustomer(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
return Excel::download(new customer_export, 'Passport_data.xlsx');
|
||||
return Excel::download(new customer_export, 'customer_data.xlsx');
|
||||
}
|
||||
|
||||
|
||||
$ids = $request->selected_id;
|
||||
|
||||
|
||||
|
||||
if (empty($ids)) {
|
||||
return response()->json(['error' => 'No IDs provided for export.'], 400);
|
||||
}
|
||||
|
||||
|
||||
Log::info("Selected IDs for export: " . $ids);
|
||||
|
||||
|
||||
$fileName = 'selected_customer_data.xlsx';
|
||||
|
||||
|
||||
Log::info("Attempting to export selected customers to file: " . $fileName);
|
||||
|
||||
|
||||
return Excel::download(new customer_export_selected($ids), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Export failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
Use : To Deleted Data Restore.
|
||||
@@ -297,4 +310,113 @@ class ManageCustomerController extends Controller
|
||||
return response()->json(['error' => __('auth.something_went_wrong')], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 27 June 2024
|
||||
Use : To delete customer details.
|
||||
*/
|
||||
|
||||
public function deleteCustomerUser($id)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
$userId = $id;
|
||||
|
||||
// dd($id,$stripeSecret);
|
||||
|
||||
$getSubscriptionData = Subscriptions::where('iam_principal_xid', $userId)->where('subscription_status', 'active')->first();
|
||||
if ($getSubscriptionData) {
|
||||
$subscriptionId = $getSubscriptionData->subscription_id;
|
||||
|
||||
$cancelledSubscription = $stripe->subscriptions->update(
|
||||
$subscriptionId,
|
||||
['cancel_at_period_end' => true]
|
||||
);
|
||||
|
||||
$subscriptionFromDatabase = Subscriptions::where('subscription_id', $subscriptionId)->first();
|
||||
$subscriptionFromDatabase->cancelled_at = date('Y-m-d H:i:s', $cancelledSubscription->canceled_at);
|
||||
|
||||
$subscriptionFromDatabase->subscription_status = $cancelledSubscription->status;
|
||||
$subscriptionFromDatabase->is_cancelled_subscription = 1;
|
||||
$subscriptionFromDatabase->status = "cancelled";
|
||||
|
||||
$subscriptionFromDatabase->save();
|
||||
|
||||
|
||||
$getSubscription = $stripe->subscriptions->retrieve($subscriptionFromDatabase->subscription_id, []);
|
||||
|
||||
|
||||
$getSubscribeCustomer = $stripe->customers->retrieve(
|
||||
$subscriptionFromDatabase->stripe_customer_id,
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$deleteCustomer = IamPrincipal::find($userId);
|
||||
$deleteCustomer->delete();
|
||||
DB::commit();
|
||||
return response()->json(['sucess' => true, 'status' => 200]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("delete_passport function Load Failed " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
|
||||
public function unsubscibed($id)
|
||||
{
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
|
||||
// $stripeSecret = env('STRIPE_SECRET');
|
||||
|
||||
$stripe = new \Stripe\StripeClient($stripeSecret);
|
||||
$userId = $id;
|
||||
|
||||
// dd($id,$stripeSecret);
|
||||
|
||||
$getSubscriptionData = Subscriptions::where('iam_principal_xid', $userId)->where('subscription_status', 'active')->first();
|
||||
|
||||
$subscriptionId = $getSubscriptionData->subscription_id;
|
||||
|
||||
$cancelledSubscription = $stripe->subscriptions->update(
|
||||
$subscriptionId,
|
||||
['cancel_at_period_end' => true]
|
||||
);
|
||||
|
||||
$subscriptionFromDatabase = Subscriptions::where('subscription_id', $subscriptionId)->first();
|
||||
$subscriptionFromDatabase->cancelled_at = date('Y-m-d H:i:s', $cancelledSubscription->canceled_at);
|
||||
|
||||
$subscriptionFromDatabase->subscription_status = $cancelledSubscription->status;
|
||||
$subscriptionFromDatabase->is_cancelled_subscription = 1;
|
||||
$subscriptionFromDatabase->status = "cancelled";
|
||||
|
||||
$subscriptionFromDatabase->save();
|
||||
|
||||
|
||||
$getSubscription = $stripe->subscriptions->retrieve($subscriptionFromDatabase->subscription_id, []);
|
||||
|
||||
|
||||
$getSubscribeCustomer = $stripe->customers->retrieve(
|
||||
$subscriptionFromDatabase->stripe_customer_id,
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("delete_passport function Load Failed " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\TimeInterval;
|
||||
use Illuminate\Http\Request;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -17,9 +18,11 @@ class ManageLocationController extends Controller
|
||||
Created at : 07 June 2024
|
||||
Use : To get the page.
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
$location = ManageState::orderBy('id', 'asc')->get();
|
||||
$location = ManageState::with('timeInterval')->orderBy('id', 'asc')->get();
|
||||
// return $location;
|
||||
return view('Admin.pages.manage_states.manage_states', compact('location'));
|
||||
}
|
||||
/*
|
||||
@@ -31,8 +34,11 @@ class ManageLocationController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$request->validate([
|
||||
'location_name' => 'required|string|max:255'
|
||||
'location_name' => 'required|string|max:255',
|
||||
'timeHours' => 'required|numeric|min:1',
|
||||
'timeInterval' => 'required|in:day,week,month'
|
||||
]);
|
||||
|
||||
try {
|
||||
@@ -40,11 +46,19 @@ class ManageLocationController extends Controller
|
||||
return response()->json(['success' => false, 'error' => 'Location name already exists', 'status' => 422]);
|
||||
}
|
||||
|
||||
|
||||
// new location
|
||||
$location = new ManageState();
|
||||
$location->name = $request->location_name;
|
||||
$location->save();
|
||||
|
||||
// time interval
|
||||
$timeInterval = new TimeInterval();
|
||||
$timeInterval->manage_state_xid = $location->id;
|
||||
$timeInterval->time_hours = $request->timeHours;
|
||||
$timeInterval->time_interval = $request->timeInterval;
|
||||
$timeInterval->quantity = $request->timeQuantity;
|
||||
$timeInterval->save();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
@@ -52,6 +66,8 @@ class ManageLocationController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
@@ -107,24 +123,57 @@ class ManageLocationController extends Controller
|
||||
Created at : 07 June 2024
|
||||
Use : To update location.
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$location_data = ManageState::find($request->id);
|
||||
$location_data->name = $request->location_name;
|
||||
$location_data->save();
|
||||
public function update_location(Request $request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Failed to update location: " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
// Find the location data
|
||||
$location_data = ManageState::find($request->id);
|
||||
if (!$location_data) {
|
||||
return response()->json(['success' => false, 'error' => 'Location not found', 'status' => 404]);
|
||||
}
|
||||
|
||||
// Update the location data
|
||||
$location_data->name = $request->location_name;
|
||||
$location_data->save();
|
||||
|
||||
// Update or create the TimeInterval data
|
||||
$timeInterval = TimeInterval::where('manage_state_xid', $request->input('id'))->first();
|
||||
|
||||
if ($timeInterval) {
|
||||
// Update existing record
|
||||
$timeInterval->update([
|
||||
'manage_state_xid' => $request->input('id'),
|
||||
|
||||
'time_hours' => $request->input('time_hours'),
|
||||
'time_interval' => $request->input('time_interval'),
|
||||
'quantity' => $request->input('quantity'),
|
||||
]);
|
||||
} else {
|
||||
// Create new record
|
||||
TimeInterval::create([
|
||||
'manage_state_xid' => $request->input('id'),
|
||||
'time_hours' => $request->input('time_hours'),
|
||||
'time_interval' => $request->input('time_interval'),
|
||||
'quantity' => $request->input('quantity'),
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'message' => __('success.update_data'), 'status' => 200]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Failed to update location: " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'error' => __('auth.something_went_wrong'), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -78,49 +78,8 @@ class ManageNewsAndArticlesController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// public function update(Request $request)
|
||||
// {
|
||||
// try {
|
||||
|
||||
|
||||
// $update_news_article = NewsArticle::find($request->article_id);
|
||||
// $update_news_article->name = $request->input('article_name');
|
||||
// // dd( $update_news_article->name);
|
||||
// $update_news_article->description = $request->input('article_dis');
|
||||
// // dd($update_news_article->description);
|
||||
|
||||
// // if ($request->hasFile('article_image')) {
|
||||
// // if ($update_news_article->image) {
|
||||
// // Storage::disk('public')->delete($update_news_article->image);
|
||||
// // }
|
||||
|
||||
// // $uploadedFile = $request->file('article_image');
|
||||
// // $extension = $uploadedFile->getClientOriginalExtension();
|
||||
// // $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
// // $path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public');
|
||||
// // $update_news_article->image = $path;
|
||||
// // }
|
||||
|
||||
// if ($request->hasFile('article_thmb')) {
|
||||
// if ($update_news_article->image) {
|
||||
// Storage::disk('public')->delete($update_news_article->thumbnail_image);
|
||||
// }
|
||||
|
||||
// $uploadedFile = $request->file('article_thmb');
|
||||
// $extension = $uploadedFile->getClientOriginalExtension();
|
||||
// $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
// $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public');
|
||||
// $update_news_article->thumbnail_image = $path;
|
||||
// }
|
||||
|
||||
// $update_news_article->save();
|
||||
// // dd( $update_news_article);
|
||||
// return response()->json(['success' => true,'status'=>200]);
|
||||
// } catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 27 May 2024
|
||||
@@ -133,9 +92,7 @@ class ManageNewsAndArticlesController extends Controller
|
||||
$update_news_article = NewsArticle::find($request->article_id);
|
||||
$update_news_article->name = $request->input('article_name');
|
||||
$update_news_article->description = $request->input('article_dis');
|
||||
|
||||
|
||||
|
||||
$update_news_article->news_articles_category_xid = $request->input('category_xid');
|
||||
|
||||
if ($request->hasFile('article_thmb')) {
|
||||
if ($update_news_article->image) {
|
||||
@@ -197,90 +154,38 @@ class ManageNewsAndArticlesController extends Controller
|
||||
* Created at : 28 May 2024
|
||||
* Use : To insert.
|
||||
*/
|
||||
// public function insert(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// // Validate the incoming request
|
||||
// // $request->validate([
|
||||
// // // 'article_name' => 'required|string',
|
||||
// // // 'article_des' => 'required|string',
|
||||
// // 'article_thmb' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
// // 'category' => 'required|string', // Assuming 'category' is the field for category selection
|
||||
// // ]);
|
||||
|
||||
// DB::beginTransaction();
|
||||
|
||||
// // Handle thumbnail image upload
|
||||
// if ($request->hasFile('article_thmb')) {
|
||||
// $uploadedFile = $request->file('article_thmb');
|
||||
// $filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
// $path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public');
|
||||
// }
|
||||
// // Handle the image upload
|
||||
// if ($request->hasFile('article_image')) {
|
||||
// $image = $request->file('article_image');
|
||||
// $imageName = date('YmdHi') . '_' . str_replace(' ', '',$image->getClientOriginalName());
|
||||
// $image_path= $image->storeAs('uploads/news_article_image', $imageName, 'public');
|
||||
// }
|
||||
|
||||
// // Create a new instance of NewsArticle model and populate it with data
|
||||
// $blog = NewsArticle::create([
|
||||
// 'name' => $request->input('article_name'),
|
||||
// 'description' => $request->input('article_des'),
|
||||
// 'news_articles_category_xid' => $request->input('category'),
|
||||
// 'thumbnail_image' => $path, // Set thumbnail image path
|
||||
// 'image'=> $image_path
|
||||
// ]);
|
||||
// // dd( $blog);
|
||||
|
||||
// DB::commit();
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'status' => 200,
|
||||
// 'message' => 'News article added successfully',
|
||||
// ]);
|
||||
// } catch (\Exception $exception) {
|
||||
// DB::rollBack();
|
||||
// // Log the exception for further analysis
|
||||
// Log::error('Error in insert method: ' . $exception->getMessage() . ' at ' . $exception->getFile() . ':' . $exception->getLine());
|
||||
|
||||
// // Return an error response
|
||||
// return response()->json(['error' => 'Failed to add news article'], 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function insert(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$blog = new NewsArticle;
|
||||
$blog->name = $request->input('article_name');
|
||||
$blog->description = $request->input('article_des');
|
||||
$blog->news_articles_category_xid = $request->input('category');
|
||||
public function insert(Request $request)
|
||||
{
|
||||
|
||||
if ($request->hasFile('article_image')) {
|
||||
$uploadedFile = $request->file('article_image');
|
||||
$extension = $uploadedFile->getClientOriginalExtension();
|
||||
$filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
$path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public');
|
||||
$blog->image = $path;
|
||||
try {
|
||||
$blog = new NewsArticle;
|
||||
$blog->name = $request->input('article_name');
|
||||
$blog->description = $request->input('article_des');
|
||||
$blog->news_articles_category_xid = $request->input('category');
|
||||
|
||||
if ($request->hasFile('article_image')) {
|
||||
$uploadedFile = $request->file('article_image');
|
||||
$extension = $uploadedFile->getClientOriginalExtension();
|
||||
$filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
$path = $uploadedFile->storeAs('uploads/news_article', $filename, 'public');
|
||||
$blog->image = $path;
|
||||
}
|
||||
if ($request->hasFile('article_thmb')) {
|
||||
$uploadedFile = $request->file('article_thmb');
|
||||
$extension = $uploadedFile->getClientOriginalExtension();
|
||||
$filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
$path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public');
|
||||
$blog->thumbnail_image = $path;
|
||||
}
|
||||
$blog->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
// Handle the exception, you can log it or return an error response
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
}
|
||||
if ($request->hasFile('article_thmb')) {
|
||||
$uploadedFile = $request->file('article_thmb');
|
||||
$extension = $uploadedFile->getClientOriginalExtension();
|
||||
$filename = date('YmdHi') . '_' . str_replace(' ', '', $uploadedFile->getClientOriginalName());
|
||||
$path = $uploadedFile->storeAs('uploads/news_article_thumb', $filename, 'public');
|
||||
$blog->thumbnail_image = $path;
|
||||
}
|
||||
$blog->save();
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
} catch (\Exception $e) {
|
||||
// Handle the exception, you can log it or return an error response
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ManageNotificationsController extends Controller
|
||||
@@ -25,24 +26,30 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
if ($activeQuery == 4) { // for customer
|
||||
$notifications = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->where('is_schedule', 0)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 3);
|
||||
})
|
||||
->latest()
|
||||
->take(12)
|
||||
->get();
|
||||
// return $notifications;
|
||||
|
||||
} else if ($activeQuery == 3) { // for restaurant
|
||||
$notifications = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->where('is_schedule', 0)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 4);
|
||||
})
|
||||
->latest()
|
||||
->take(12)
|
||||
->get();
|
||||
|
||||
// return $notifications;
|
||||
} else {
|
||||
$notificationsOfType3 = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->where('is_schedule', 0)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 3);
|
||||
})
|
||||
@@ -51,6 +58,8 @@ class ManageNotificationsController extends Controller
|
||||
->get();
|
||||
|
||||
$notificationsOfType4 = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->where('is_schedule', 0)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 4);
|
||||
})
|
||||
@@ -60,14 +69,15 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
$notifications = $notificationsOfType3->merge($notificationsOfType4);
|
||||
}
|
||||
$scheduledNotifications = NotificationDetails::where('is_schedule', 1)->where('is_active', 1)->orderByDesc('id')->get();
|
||||
|
||||
return view('Admin.pages.manage_notification.manage_notification', compact('notifications'));
|
||||
return view('Admin.pages.manage_notification.manage_notification', compact('notifications', 'scheduledNotifications'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 10 June 2024
|
||||
* Use : To view notification details.s
|
||||
* Use : To view add notification.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@@ -78,11 +88,11 @@ class ManageNotificationsController extends Controller
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 10 June 2024
|
||||
* Use : To add notification .
|
||||
* Use : To store notification .
|
||||
*/
|
||||
public function store_notificaton_data(Request $request)
|
||||
|
||||
public function store_notification_data(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
$request->validate([
|
||||
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
@@ -90,75 +100,147 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
if (isset($request->image)) {
|
||||
$image = $request->image;
|
||||
$image_db = null;
|
||||
} else {
|
||||
$image = null;
|
||||
$image_db = $request->image;
|
||||
$imagePath = null;
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
$imagePath = saveSingleImageWithoutCrop($image, 'notification_images');
|
||||
$imagePath = ListingImageUrl('notification_images', $imagePath);
|
||||
}
|
||||
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
|
||||
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
|
||||
|
||||
|
||||
|
||||
|
||||
$allCustomerOneSignalIds = IamPrincipal::where('is_active', 1)
|
||||
$states = $request->states;
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$iamPrincipals = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->get();
|
||||
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
|
||||
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->where('state_xid', $request->state)
|
||||
->pluck('id');
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
$allRestaurantOneSignalIds = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->where('state_xid', $request->state)
|
||||
->pluck('id');
|
||||
$scheduled = false;
|
||||
|
||||
|
||||
// Find the remaining user data
|
||||
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
|
||||
$title = $request->title;
|
||||
$message = $request->description;
|
||||
$content_type = 'Notification';
|
||||
$imageUrl = $imagePath;
|
||||
|
||||
// FOR all customer
|
||||
if ($request->user_type == 1) {
|
||||
foreach ($UserData as $customerIdItem) {
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$title,
|
||||
$message,
|
||||
$content_type,
|
||||
$imageUrl,
|
||||
$id = null
|
||||
);
|
||||
$allCustomerOneSignalIds = $subscribe->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
|
||||
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
NotificationDetails::create([
|
||||
'user_type' => $request->user_type,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'state_ids' => json_encode($states),
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
foreach ($UserData as $customerIdItem) {
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
|
||||
}
|
||||
} elseif ($request->user_type == 2) {
|
||||
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)->pluck('id');
|
||||
$subscribedIds = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->pluck('iam_principal_xid');
|
||||
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
|
||||
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
|
||||
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
|
||||
|
||||
foreach ($restaurantData as $restIdItem) {
|
||||
|
||||
if ($restIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restIdItem->one_signal_player_id,
|
||||
$title,
|
||||
$message,
|
||||
$content_type,
|
||||
$imageUrl,
|
||||
$id = null
|
||||
);
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
NotificationDetails::create([
|
||||
'user_type' => $request->user_type,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'state_ids' => json_encode($states),
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
foreach ($restaurantData as $restaurantsData) {
|
||||
if ($restaurantsData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restaurantsData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
$request->title,
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
} elseif ($request->user_type == 3) {
|
||||
$userQuery = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states);
|
||||
|
||||
$allUserOneSignalIds = $userQuery->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
|
||||
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
NotificationDetails::create([
|
||||
'user_type' => $request->user_type,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'state_ids' => json_encode($states),
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
foreach ($UserData as $CustomerData) {
|
||||
if ($CustomerData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$CustomerData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restIdItem->id, $content_type, $title, $imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
||||
|
||||
if ($scheduled) {
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_scheduled'));
|
||||
} else {
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_immediate'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Notification send Failed " . $e->getMessage());
|
||||
@@ -170,11 +252,51 @@ class ManageNotificationsController extends Controller
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 10 June 2024
|
||||
* Use : To view notification details.s
|
||||
* Use : To view notification detail.
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$notification = NotificationDetails::with('notification')->findOrFail($id);
|
||||
return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$edit_notification = NotificationDetails::findOrFail($id);
|
||||
$states = ManageState::where('is_active', 1)->get();
|
||||
return view('Admin.pages.manage_notification.manage_notification_edit', compact('edit_notification', 'states'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
$notification = NotificationDetails::findOrFail($request->id);
|
||||
|
||||
$notification->type = $request->type;
|
||||
$notification->description = $request->description;
|
||||
$notification->delivery_schedule = $request->delivery_schedule;
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
$imagePath = saveSingleImageWithoutCrop($image, 'notification_images');
|
||||
$imagePath = ListingImageUrl('notification_images', $imagePath);
|
||||
$notification->image = $imagePath;
|
||||
}
|
||||
$notification->user_type = $request->user_type;
|
||||
$notification->state_ids = json_encode($request->state_ids);
|
||||
$notification->save();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_scheduled'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Notification update Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$data = NotificationDetails::find($id)->delete();
|
||||
return redirect()->back()->with('success', '');
|
||||
}
|
||||
}
|
||||
|
||||
64
app/Http/Controllers/Admin/ManageReferralController.php
Normal file
64
app/Http/Controllers/Admin/ManageReferralController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ManageReferralRule;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class ManageReferralController extends Controller
|
||||
{
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 22 July 2024
|
||||
* Use : To view Rules page.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$referral_rule = ManageReferralRule::all()->toArray();
|
||||
return view('Admin.pages.manage_rule.manage_referral', compact('referral_rule'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 22 July 2024
|
||||
* Use : To edit Rules.
|
||||
*/
|
||||
public function editReferral($id)
|
||||
{
|
||||
$referral_rule = ManageReferralRule::find($id);
|
||||
// dd($referral_rule);
|
||||
return view('Admin.pages.manage_rule.manage_referral_edit', compact('referral_rule'));
|
||||
}
|
||||
|
||||
|
||||
public function updateReferral(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
|
||||
'how_it_works' => 'required',
|
||||
'rules' => 'required',
|
||||
'what_is_referral' => 'required',
|
||||
|
||||
]);
|
||||
|
||||
$howItWorks = base64_decode($request->input('how_it_works'));
|
||||
$rules = base64_decode($request->input('rules'));
|
||||
$whatIsReferral = base64_decode($request->input('what_is_referral'));
|
||||
|
||||
|
||||
$update = ManageReferralRule::find($request->rule_id);
|
||||
$update->how_it_works= $howItWorks;
|
||||
$update->rules = $rules;
|
||||
$update->what_is_referral= $whatIsReferral;
|
||||
|
||||
$update->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,12 +4,84 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageState;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\ReportExports;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ReferralUsers;
|
||||
use App\Exports\ExportReports;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ManageReportsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('Admin.pages.manage_reports.manage_reports');
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 July 2024
|
||||
* Use : To get manage report page.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$states = ManageState::all();
|
||||
$restaurants = ManageRestaurant::all();
|
||||
return view('Admin.pages.manage_reports.manage_reports', compact('states', 'restaurants'));
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 July 2024
|
||||
* Use : To download the excel.
|
||||
*/
|
||||
|
||||
public function exportReport(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$reportType = $request->input('reportType');
|
||||
$states = $request->input('states');
|
||||
$restaurants = $request->input('restaurants', []);
|
||||
$startDate = \Carbon\Carbon::parse( $request->startDate)->format('Y-m-d');
|
||||
$endDate = \Carbon\Carbon::parse( $request->endDate)->format('Y-m-d');
|
||||
|
||||
|
||||
// Set the file name based on the report type
|
||||
$fileName = 'reports.xlsx'; // default file name
|
||||
|
||||
if ($reportType == 'Total Subscribed') {
|
||||
$fileName = 'total_subscribed_report.xlsx';
|
||||
} elseif ($reportType == 'Total Users') {
|
||||
$fileName = 'total_users_report.xlsx';
|
||||
} elseif ($reportType == 'Redemptions') {
|
||||
$fileName = 'redemptions_report.xlsx';
|
||||
} elseif ($reportType == 'Redemptions for Specific Restaurants') {
|
||||
$fileName = 'redemptions_specific_restaurants_report.xlsx';
|
||||
} elseif ($reportType == 'Subscriptions Cancelled') {
|
||||
$fileName = 'subscriptions_cancelled_report.xlsx';
|
||||
} elseif ($reportType == 'Referrals Made') {
|
||||
$fileName = 'referrals_made_report.xlsx';
|
||||
} elseif ($reportType == 'Referees Joined') {
|
||||
$fileName = 'referees_joined_report.xlsx';
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
return Excel::download(new ExportReports($reportType, $states, $startDate, $endDate, $restaurants), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Export failed: ' . $e->getMessage());
|
||||
Log::error('Stack trace: ' . $e->getTraceAsString());
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ use Exception;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\RestaurantClosedHour;
|
||||
use App\Models\RestaurantTimeInterval;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -28,11 +30,11 @@ class ManageRestrauntController extends Controller
|
||||
$activeQuery = $request->query('active');
|
||||
if ($activeQuery == 1) {
|
||||
|
||||
$restaurant = ManageRestaurant::where('is_active', 1)->latest()->get();
|
||||
$restaurant = ManageRestaurant::with('state')->where('is_active', 1)->latest()->get();
|
||||
} else if ($activeQuery == 0 && $activeQuery != null) {
|
||||
$restaurant = ManageRestaurant::where('is_active', 0)->latest()->get();
|
||||
$restaurant = ManageRestaurant::with('state')->where('is_active', 0)->latest()->get();
|
||||
} else {
|
||||
$restaurant = ManageRestaurant::latest()->get();
|
||||
$restaurant = ManageRestaurant::with('state')->latest()->get();
|
||||
}
|
||||
return view('Admin.pages.manage_restaurants.manage_restaurants', compact('restaurant'));
|
||||
}
|
||||
@@ -45,7 +47,7 @@ class ManageRestrauntController extends Controller
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$state = ManageState::where('is_active', 1)->get()->toArray();
|
||||
$state = ManageState::with('timeInterval')->where('is_active', 1)->get()->toArray();
|
||||
return view('Admin.pages.manage_restaurants.add_restaurant', compact('state'));
|
||||
}
|
||||
|
||||
@@ -86,17 +88,36 @@ class ManageRestrauntController extends Controller
|
||||
$restaurant->try_on_4 = $request->input('try_on_4');
|
||||
$restaurant->save();
|
||||
|
||||
foreach ($request->input('operating_hours') as $day => $hours) {
|
||||
OperatingHour::create([
|
||||
'manage_restaurant_xid' => $restaurant->id,
|
||||
// Storing operating hours
|
||||
// foreach ($request->input('operating_hours') as $day => $hours) {
|
||||
// OperatingHour::create([
|
||||
// 'manage_restaurant_xid' => $restaurant->id,
|
||||
// 'day_of_week' => $day,
|
||||
// 'start_time' => $hours['start_time'],
|
||||
// 'end_time' => $hours['end_time']
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// Storing restaurant time interval
|
||||
$restTimeInterval = new RestaurantTimeInterval();
|
||||
$restTimeInterval->manage_restaurants_xid = $restaurant->id;
|
||||
$restTimeInterval->time_hours = $request->timeHours;
|
||||
$restTimeInterval->time_interval = $request->timeInterval;
|
||||
$restTimeInterval->quantity = $request->timeQuantity;
|
||||
$restTimeInterval->save();
|
||||
if($request->filled('day_of_week')){
|
||||
foreach ($request->day_of_week as $index => $day) {
|
||||
RestaurantClosedHour::create([
|
||||
'restaurant_id' => $restaurant->id,
|
||||
'day_of_week' => $day,
|
||||
'start_time' => $hours['start_time'],
|
||||
'end_time' => $hours['end_time']
|
||||
'start_time' => $request->start_time[$index],
|
||||
'end_time' => $request->end_time[$index],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Sending notifications
|
||||
$imagePath = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
|
||||
$allCustomerOneSignalIds = IamPrincipal::select('id', 'one_signal_player_id')->where('is_active', 1)->where('notification_status', 1)->where('principal_type_xid', 3)->get();
|
||||
$title = "New " . $restaurant->name . " is added";
|
||||
$message = "New Restaurant is Now Live.";
|
||||
@@ -117,7 +138,6 @@ class ManageRestrauntController extends Controller
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
||||
} catch (Exception $e) {
|
||||
@@ -128,6 +148,7 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
@@ -136,8 +157,11 @@ class ManageRestrauntController extends Controller
|
||||
public function edit_restaurant(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week');
|
||||
$restaurantItem = ManageRestaurant::where('id', $id)->first();
|
||||
// $operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week');
|
||||
$restaurantItem = ManageRestaurant::with('timeInterval')->where('id', $id)->first();
|
||||
$restaurantClosedTime = RestaurantClosedHour::with('restaurant')->where('restaurant_id', $id)->get();
|
||||
$timeInterval = $restaurantItem->timeInterval->first();
|
||||
|
||||
$state = ManageState::where('is_active', 1)->get()->toArray();
|
||||
$restaurantItem['image'] = ListingImageUrl('restaurant_images', $restaurantItem['image']);
|
||||
return view(
|
||||
@@ -145,8 +169,10 @@ class ManageRestrauntController extends Controller
|
||||
compact(
|
||||
'restaurantItem',
|
||||
|
||||
'operating_hours',
|
||||
'state'
|
||||
// 'operating_hours',
|
||||
'state',
|
||||
'timeInterval',
|
||||
'restaurantClosedTime'
|
||||
)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
@@ -155,6 +181,7 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
@@ -191,24 +218,32 @@ class ManageRestrauntController extends Controller
|
||||
$restaurant->try_on_4 = $request->input('try_on_4');
|
||||
$restaurant->save();
|
||||
|
||||
foreach ($request->input('operating_hours') as $day => $hours) {
|
||||
$operatingHour = OperatingHour::where('manage_restaurant_xid', $restaurant->id)
|
||||
->where('day_of_week', $day)
|
||||
->first();
|
||||
$timeInterval = RestaurantTimeInterval::where('manage_restaurants_xid', $restaurant->id)->first();
|
||||
|
||||
if ($operatingHour) {
|
||||
// Update existing record
|
||||
$operatingHour->update([
|
||||
'start_time' => $hours['start_time'],
|
||||
'end_time' => $hours['end_time']
|
||||
]);
|
||||
} else {
|
||||
// Create new record
|
||||
OperatingHour::create([
|
||||
'manage_restaurant_xid' => $restaurant->id,
|
||||
if ($timeInterval) {
|
||||
$timeInterval->update([
|
||||
'time_hours' => $request->input('timeHours'),
|
||||
'time_interval' => $request->input('timeInterval'),
|
||||
'quantity' => $request->input('timeQuantity'),
|
||||
]);
|
||||
} else {
|
||||
RestaurantTimeInterval::create([
|
||||
'manage_restaurants_xid' => $restaurant->id,
|
||||
'time_hours' => $request->input('timeHours'),
|
||||
'time_interval' => $request->input('timeInterval'),
|
||||
'quantity' => $request->input('timeQuantity'),
|
||||
]);
|
||||
}
|
||||
|
||||
$closedTime = RestaurantClosedHour::where('restaurant_id', $restaurant->id)->delete();
|
||||
|
||||
if ($request->day_of_week) {
|
||||
foreach ($request->day_of_week as $index => $day) {
|
||||
RestaurantClosedHour::create([
|
||||
'restaurant_id' => $request->id,
|
||||
'day_of_week' => $day,
|
||||
'start_time' => $hours['start_time'],
|
||||
'end_time' => $hours['end_time']
|
||||
'start_time' => $request->start_time[$index],
|
||||
'end_time' => $request->end_time[$index],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -225,6 +260,9 @@ class ManageRestrauntController extends Controller
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
|
||||
56
app/Http/Controllers/Admin/ManageRulesController.php
Normal file
56
app/Http/Controllers/Admin/ManageRulesController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ManageRule;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageRulesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 19 June 2024
|
||||
* Use : To view Rules page.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = ManageRule::all()->toArray();
|
||||
return view('Admin.pages.manage_rule.manage_rule', compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 19 June 2024
|
||||
* Use : To edit Rules.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = ManageRule::find($id);
|
||||
return view('Admin.pages.manage_rule.manage_rules_edit', compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayli Raut
|
||||
* Created at : 19 June 2024
|
||||
* Use : To update Rules.
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
|
||||
'whats_inside' => 'required',
|
||||
'rules' => 'required',
|
||||
]);
|
||||
|
||||
$whatsInside = base64_decode($request->input('whats_inside'));
|
||||
$rules = base64_decode($request->input('rules'));
|
||||
|
||||
|
||||
$update = ManageRule::find($request->rule_id);
|
||||
$update->whats_inside = $whatsInside;
|
||||
$update->rules = $rules;
|
||||
$update->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,20 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\Add_Subadmin;
|
||||
|
||||
class ManageSubAdminController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
$sub_admins_module = ManageModule::latest()->get();
|
||||
$sub_admins_data = IamPrincipal::where('principal_type_xid', 2)->latest()->get();
|
||||
|
||||
return view('Admin.pages.manage_users.manage_sub_admin.manage_subadmin',compact('sub_admins_data','sub_admins_module'));
|
||||
return view('Admin.pages.manage_users.manage_sub_admin.manage_subadmin', compact('sub_admins_data', 'sub_admins_module'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
@@ -29,23 +34,40 @@ class ManageSubAdminController extends Controller
|
||||
return view('Admin.pages.manage_users.manage_sub_admin.create', compact('sub_admins_module'));
|
||||
}
|
||||
|
||||
public function store_subadmin(Request $request)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Created By : shailesh Gupta
|
||||
Created at : 29 May 2024
|
||||
Use : To store sub admin form and email
|
||||
*/
|
||||
public function store_subadmin(Request $request)
|
||||
{
|
||||
// Validation rules
|
||||
$rules = [
|
||||
'sub_admin_email' => 'required|string|email|max:100|unique:iam_principal,email_address,NULL,id,principal_type_xid,2',
|
||||
|
||||
];
|
||||
|
||||
// Custom error messages
|
||||
$messages = [
|
||||
'sub_admin_email.required' => 'Please enter this field',
|
||||
'sub_admin_email.email' => 'Please enter a valid email address',
|
||||
'sub_admin_email.unique' => 'This email is already registered',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// DB::beginTransaction();
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$sub_admin = new IamPrincipal();
|
||||
$sub_admin->first_name = $request->input('sub_admin_name');
|
||||
$sub_admin->last_name=$request->input('sub_admin_lname');
|
||||
$sub_admin->last_name = $request->input('sub_admin_lname');
|
||||
$sub_admin->user_name = 'sub_admin';
|
||||
$sub_admin->principal_type_xid = 2;
|
||||
$sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid;
|
||||
@@ -53,39 +75,36 @@ class ManageSubAdminController extends Controller
|
||||
$sub_admin->password = bcrypt($request->input('password'));
|
||||
$sub_admin->save();
|
||||
|
||||
|
||||
$moduleIds = $request->input('module_id');
|
||||
|
||||
foreach ($moduleIds as $moduleId) {
|
||||
|
||||
$sub_admin_permission = new ManageModuleLink;
|
||||
$sub_admin_permission->principal_xid = $sub_admin->id;
|
||||
$sub_admin_permission->manage_modules_xid = $moduleId;
|
||||
$sub_admin_permission->save();
|
||||
|
||||
}
|
||||
|
||||
$mailData =[
|
||||
'username'=>$request->input('sub_admin_name'),
|
||||
'password'=>$request->input('password'),
|
||||
$mailData = [
|
||||
'username' => $request->input('sub_admin_name'),
|
||||
'password' => $request->input('password'),
|
||||
];
|
||||
|
||||
Mail::to($sub_admin->email_address)->send(new Add_Subadmin($mailData));
|
||||
|
||||
|
||||
// Mail::to($sub_admin->email_address)->send(new Add_Subadmin($mailData));
|
||||
$mail = Mail::to($request->input('sub_admin_email'))->send(new Add_Subadmin($mailData));
|
||||
// dd($mail);
|
||||
|
||||
// DB::commit();
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
||||
// return response()->json(['status'=>200]);
|
||||
// return $voucher_data;
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("restaurant Store Page Load Failed " . $e->getMessage());
|
||||
Log::error("Store Subadmin Page Load Failed: " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
// dd($id);
|
||||
@@ -127,36 +146,63 @@ class ManageSubAdminController extends Controller
|
||||
Use : To update sub admin form.
|
||||
*/
|
||||
try {
|
||||
$userId = $request->sub_admin_id;
|
||||
$user = IamPrincipal::findOrFail($userId); // Fetch the user to update
|
||||
|
||||
$rules = [
|
||||
'sub_admin_email' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:100',
|
||||
Rule::unique('iam_principal', 'email_address')
|
||||
->ignore($userId) // Ignore the current user's ID
|
||||
->whereNull('deleted_at') // Ensure the record is not soft-deleted
|
||||
],
|
||||
];
|
||||
|
||||
$messages = [
|
||||
'sub_admin_email.required' => 'Please enter this field',
|
||||
'sub_admin_email.email' => 'Please enter a valid email address',
|
||||
'sub_admin_email.unique' => 'This email is already registered',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$sub_admin = IamPrincipal::find($request->sub_admin_id);
|
||||
$sub_admin->user_name = 'sub_admin';
|
||||
$sub_admin->first_name = $request->input('sub_admin_name');
|
||||
$sub_admin->last_name = $request->input('sub_admin_lname');
|
||||
$sub_admin->principal_type_xid = 2;
|
||||
$sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid;
|
||||
$sub_admin->email_address = $request->input('sub_admin_email');
|
||||
// $sub_admin->password = bcrypt($request->input('password'));
|
||||
$sub_admin->save();
|
||||
// Update user details
|
||||
$user->user_name = 'sub_admin';
|
||||
$user->first_name = $request->input('sub_admin_name');
|
||||
$user->last_name = $request->input('sub_admin_lname');
|
||||
$user->principal_type_xid = 2;
|
||||
$user->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid;
|
||||
$user->email_address = $request->input('sub_admin_email');
|
||||
// Uncomment and set the password if needed
|
||||
// $user->password = bcrypt($request->input('password'));
|
||||
$user->save();
|
||||
|
||||
// Update module links
|
||||
ManageModuleLink::where('principal_xid', $user->id)->delete();
|
||||
|
||||
$moduleIds = $request->input('module_id');
|
||||
// dd($moduleIds);
|
||||
$update_module = ManageModuleLink::where('principal_xid', $sub_admin->id)->delete();
|
||||
|
||||
foreach ($moduleIds as $moduleId) {
|
||||
$sub_admin_permission = new ManageModuleLink;
|
||||
$sub_admin_permission->principal_xid = $sub_admin->id;
|
||||
$sub_admin_permission->principal_xid = $user->id;
|
||||
$sub_admin_permission->manage_modules_xid = $moduleId;
|
||||
$sub_admin_permission->save();
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
||||
// return $voucher_data;
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("restaurant Store Page Load Failed " . $e->getMessage());
|
||||
Log::error("Update Sub Admin Failed: " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
@@ -188,6 +234,4 @@ class ManageSubAdminController extends Controller
|
||||
$test = ManageModuleLink::where('principal_xid', $testing_admin_id)->get('manage_modules_xid')->toArray();
|
||||
return response()->json(['success' => true, 'data' => $test]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,17 +9,7 @@ use App\Models\PrivacyPolicy;
|
||||
class PrivacyPolicyController extends Controller
|
||||
{
|
||||
|
||||
// public function index(){
|
||||
|
||||
// return view('Admin.pages.manage_cms.manage_privacy.manage_privacy');
|
||||
// }
|
||||
// public function index(){
|
||||
// $view_privacy_policy = PrivacyPolicy::get()->toArray();
|
||||
// // dd($view_privacy_policy);
|
||||
// return view('Admin.pages.manage_cms.manage_privacy.manage_privacy');
|
||||
// }
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 29 May 2024
|
||||
* Use : To get privacy policy page.
|
||||
@@ -77,3 +67,4 @@ class PrivacyPolicyController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class ReferralCodeController extends Controller
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ use App\Models\IamPrincipal;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Mail\RestUserApproval;
|
||||
use App\Models\IamPrincipalRestaurantRole;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\restaurant_export;
|
||||
use App\Exports\restaurant_export_selected;
|
||||
use App\Mail\RestUserDisapproval;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
@@ -22,10 +25,10 @@ class RestaurantAppController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To get restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To get restaturant user.
|
||||
*/
|
||||
public function index_restraunt_users(Request $request)
|
||||
{
|
||||
|
||||
@@ -51,12 +54,12 @@ class RestaurantAppController extends Controller
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
}
|
||||
|
||||
// return $restaurant_users;
|
||||
foreach ($restaurant_users as $user) {
|
||||
$restaurantIds = $user->getresturant->pluck('restaurant_xid')->toArray();
|
||||
|
||||
$user->restaurants = ManageRestaurant::whereIn('id', $restaurantIds)
|
||||
->select('id','restaurant_id', 'name', 'image', 'address', 'latitude', 'longtitude')
|
||||
->select('id', 'restaurant_id', 'name', 'image', 'address', 'latitude', 'longtitude')
|
||||
->get();
|
||||
|
||||
// Optionally, if you want to format the images as in the previous example
|
||||
@@ -76,22 +79,37 @@ class RestaurantAppController extends Controller
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To change the status restaturant user.
|
||||
*/
|
||||
// public function change_rest_user_status(Request $request)
|
||||
// {
|
||||
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
// $status = IamPrincipal::find($request->rest_user_id);
|
||||
// $status->is_active = $request->status;
|
||||
|
||||
// // Generate a random password
|
||||
// $randomPassword = \Str::random(8); // Adjust the length as per your requirements
|
||||
|
||||
// // Set the password
|
||||
// $status->password = bcrypt($randomPassword); // Make sure to hash the password
|
||||
// // Generate a random password if status is 1 (approved)
|
||||
// if ($request->status == 1) {
|
||||
// $randomPassword = \Str::random(8); // Adjust the length as per your requirements
|
||||
// $status->password = bcrypt($randomPassword); // Make sure to hash the password
|
||||
// } else {
|
||||
// $status->deleted_by_admin = 1;
|
||||
// $detail = [
|
||||
// 'first_name' => $status->first_name,
|
||||
// 'last_name' => $status->last_name,
|
||||
// 'email' => $status->email_address,
|
||||
// ];
|
||||
// Mail::to($status->email_address)->send(new RestUserDisapproval($detail));
|
||||
// }
|
||||
|
||||
// $status->save();
|
||||
|
||||
|
||||
|
||||
// if ($request->status == 1) {
|
||||
// // Fetch user data based on user ID
|
||||
// $user = IamPrincipal::find($request->rest_user_id);
|
||||
@@ -117,11 +135,7 @@ class RestaurantAppController extends Controller
|
||||
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To change the status restaturant user.
|
||||
*/
|
||||
|
||||
public function change_rest_user_status(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -133,50 +147,52 @@ class RestaurantAppController extends Controller
|
||||
if ($request->status == 1) {
|
||||
$randomPassword = \Str::random(8); // Adjust the length as per your requirements
|
||||
$status->password = bcrypt($randomPassword); // Make sure to hash the password
|
||||
|
||||
// Send approval email
|
||||
$data = [
|
||||
'first_name' => $status->first_name,
|
||||
'last_name' => $status->last_name,
|
||||
'email' => $status->email_address,
|
||||
'password' => $randomPassword, // Pass the random password to the email template
|
||||
];
|
||||
|
||||
Mail::to($status->email_address)->send(new RestUserApproval($data));
|
||||
} else {
|
||||
|
||||
$status->deleted_by_admin = 1;
|
||||
$detail = [
|
||||
'first_name'=> $status->first_name,
|
||||
'last_name' => $status->last_name,
|
||||
'email'=> $status->email_address,
|
||||
];
|
||||
Mail::to($status->email_address)->send(new RestUserDisapproval($detail));
|
||||
}
|
||||
|
||||
$status->save();
|
||||
|
||||
if ($request->status == 1) {
|
||||
// Fetch user data based on user ID
|
||||
$user = IamPrincipal::find($request->rest_user_id);
|
||||
|
||||
if ($user) {
|
||||
// Send email only if user exists
|
||||
$data = [
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
'email' => $user->email_address,
|
||||
'password' => $randomPassword, // Pass the random password to the email template
|
||||
];
|
||||
|
||||
Mail::to($user->email_address)->send(new RestUserApproval($data));
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
return response()->json(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Update Status function Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
return response()->json(['success' => false, 'message' => __('auth.something_went_wrong')], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To view restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To view restaturant user.
|
||||
*/
|
||||
|
||||
public function view_rest($id)
|
||||
{
|
||||
try {
|
||||
$restdata = IamPrincipalRestaurantRole::with('restaurant','customer')->where('principal_xid', $id)->first();
|
||||
$restdata = IamPrincipalRestaurantRole::with('restaurant', 'customer')->where('principal_xid', $id)->first();
|
||||
// return $restdata;
|
||||
|
||||
return view('Admin.pages.manage_users.restaurants_app.view_restaurant_users', compact('restdata'));
|
||||
@@ -189,10 +205,10 @@ class RestaurantAppController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To edit restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 03 June 2024
|
||||
* Use : To edit restaturant user.
|
||||
*/
|
||||
public function edit_Restaurant($id)
|
||||
{
|
||||
|
||||
@@ -205,67 +221,12 @@ class RestaurantAppController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// public function updateRest(Request $request)
|
||||
// {
|
||||
|
||||
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
// $rest_data = IamPrincipal::where('id', $request->rest_id)->first();
|
||||
// $rest_data->first_name = $request->input('name');
|
||||
// $rest_data->last_name = $request->input('last_name');
|
||||
|
||||
// $rest_data->phone_number = $request->input('phone');
|
||||
// $rest_data->email_address = $request->input('email_id');
|
||||
// $rest_data->save();
|
||||
// DB::commit();
|
||||
|
||||
// return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
// } catch (Exception $e) {
|
||||
// DB::rollBack();
|
||||
// Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage());
|
||||
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function updateRest(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
|
||||
// $rest_data = IamPrincipal::find($request->input('rest_id'));
|
||||
// if (!$rest_data) {
|
||||
// throw new Exception('Restaurant not found.');
|
||||
// }
|
||||
|
||||
// $rest_data->first_name = $request->input('restaurant_name');
|
||||
// $rest_data->description = $request->input('restaurant_des');
|
||||
// $rest_data->phone_number = $request->input('restaurant_phone');
|
||||
// $rest_data->email_address = $request->input('restaurant_email');
|
||||
// $rest_data->location = $request->input('restaurant_loc');
|
||||
// $rest_data->bio = $request->input('restaurant_bio');
|
||||
|
||||
// if ($request->hasFile('restaurant_image')) {
|
||||
// $imagePath = $request->file('restaurant_image')->store('images', 'public');
|
||||
// $rest_data->image_path = $imagePath;
|
||||
// }
|
||||
|
||||
// $rest_data->save();
|
||||
|
||||
// DB::commit();
|
||||
// return response()->json(['message' => __('success.update_data')], 200);
|
||||
// } catch (Exception $e) {
|
||||
// DB::rollBack();
|
||||
// Log::error("Update Restaurant Failed: " . $e->getMessage());
|
||||
// return response()->json(['message' => __('auth.something_went_wrong')], 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To update restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To update restaturant user.
|
||||
*/
|
||||
public function updateRest(Request $request)
|
||||
{
|
||||
|
||||
@@ -298,10 +259,10 @@ class RestaurantAppController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To delete restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To delete restaturant user.
|
||||
*/
|
||||
public function deleteRestaurantsUsers($id)
|
||||
{
|
||||
|
||||
@@ -322,10 +283,10 @@ class RestaurantAppController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To archieve restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To archieve restaturant user.
|
||||
*/
|
||||
public function archive_restaturant()
|
||||
{
|
||||
|
||||
@@ -339,10 +300,10 @@ class RestaurantAppController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To unarchieve restaturant user.
|
||||
*/
|
||||
* Created By : sayali parab
|
||||
* Created at : 04 June 2024
|
||||
* Use : To unarchieve restaturant user.
|
||||
*/
|
||||
|
||||
public function unarchive_rest($id)
|
||||
{
|
||||
@@ -360,4 +321,41 @@ class RestaurantAppController extends Controller
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 17 july 2024
|
||||
Use : To Get Excel.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
public function exportSelectedrestaurantApp(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
return Excel::download(new restaurant_export, 'restaurant_user_data.xlsx');
|
||||
}
|
||||
|
||||
// $ids = $request->selected_id;
|
||||
// dd($ids);
|
||||
$ids = $request->input('selected_id');
|
||||
|
||||
if (empty($ids)) {
|
||||
return response()->json(['error' => 'No IDs provided for export.'], 400);
|
||||
}
|
||||
|
||||
Log::info("Selected IDs for export: " . $ids);
|
||||
|
||||
$fileName = 'selected_restaurantusers_data.xlsx';
|
||||
|
||||
Log::info("Attempting to export selected customers to file: " . $fileName);
|
||||
|
||||
return Excel::download(new restaurant_export_selected($ids), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Export failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@ use App\Models\IamPrincipal;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Created By : sayli raut
|
||||
* Created at : 24 Jan 2024
|
||||
* Use : Json response with success message for API
|
||||
*/
|
||||
if (!function_exists('jsonResponseWithSuccessMessageApi')) {
|
||||
function jsonResponseWithSuccessMessageApi($message, $data = [], $statusCode = 200)
|
||||
{
|
||||
@@ -32,11 +30,7 @@ if (!function_exists('jsonResponseWithSuccessMessageApi')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : sayli raut
|
||||
* Created at : 24 jan 2024
|
||||
* Use : Json response with error message for API
|
||||
*/
|
||||
|
||||
if (!function_exists('jsonResponseWithErrorMessageApi')) {
|
||||
function jsonResponseWithErrorMessageApi($errorMessage, $statusCode = 500)
|
||||
{
|
||||
@@ -56,11 +50,29 @@ if (!function_exists('jsonResponseWithErrorMessageApi')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : sayli raut
|
||||
* Created at : 24 Jan 2024
|
||||
* Use : To return error json response for admin
|
||||
*/
|
||||
|
||||
if (!function_exists('jsonResponseWithDataErrorMessageApi')) {
|
||||
function jsonResponseWithDataErrorMessageApi($errorMessage, $data = [], $statusCode = 406)
|
||||
{
|
||||
// Set the HTTP status code
|
||||
http_response_code($statusCode);
|
||||
|
||||
// Prepare the response array
|
||||
$response = [
|
||||
'status' => 'error',
|
||||
'status_code' => $statusCode,
|
||||
'message' => $errorMessage,
|
||||
'data' => $data,
|
||||
|
||||
];
|
||||
return response()->json($response, $statusCode);
|
||||
|
||||
// Stop further execution (optional)
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('jsonResponseWithErrorMessage')) {
|
||||
function jsonResponseWithErrorMessage($errorMessage)
|
||||
{
|
||||
@@ -75,11 +87,7 @@ if (!function_exists('jsonResponseWithErrorMessage')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : sayli raut
|
||||
* Created at : 24 Jan 2024
|
||||
* Use : To return success json response for admin
|
||||
*/
|
||||
|
||||
if (!function_exists('jsonResponseWithSuccessMessage')) {
|
||||
function jsonResponseWithSuccessMessage($message, $data = [])
|
||||
{
|
||||
@@ -98,11 +106,7 @@ if (!function_exists('jsonResponseWithSuccessMessage')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : Pradyumn Dwivedi
|
||||
* Created On : 11-May-2022
|
||||
* Uses: This function will be used to full search data in api.
|
||||
*/
|
||||
|
||||
if (!function_exists('fullSearchQuery')) {
|
||||
function fullSearchQuery($query, $word, $columns)
|
||||
{
|
||||
@@ -116,11 +120,7 @@ if (!function_exists('fullSearchQuery')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : sayli raut
|
||||
* Created at : 24 Feb 2024
|
||||
* Use : To check and validate to customer token
|
||||
*/
|
||||
|
||||
if (!function_exists('readHeaderToken')) {
|
||||
function readHeaderToken()
|
||||
{
|
||||
@@ -143,11 +143,7 @@ if (!function_exists('readHeaderToken')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : sayli raut
|
||||
* Created at : 24 jan 2024
|
||||
* Use : To check and validate login restaurant user token
|
||||
*/
|
||||
|
||||
if (!function_exists('readRestHeaderToken')) {
|
||||
function readRestHeaderToken()
|
||||
{
|
||||
@@ -168,17 +164,145 @@ if (!function_exists('readRestHeaderToken')) {
|
||||
|
||||
if (!function_exists('generateOTP')) {
|
||||
|
||||
function generateOTP()
|
||||
{
|
||||
// Define the length of the OTP
|
||||
$otpLength = 4;
|
||||
function generateOTP()
|
||||
{
|
||||
// Define the length of the OTP
|
||||
$otpLength = 4;
|
||||
|
||||
// Generate a random OTP with $otpLength digits
|
||||
$otp = '';
|
||||
for ($i = 0; $i < $otpLength; $i++) {
|
||||
$otp .= rand(0, 9);
|
||||
// Generate a random OTP with $otpLength digits
|
||||
$otp = '';
|
||||
for ($i = 0; $i < $otpLength; $i++) {
|
||||
$otp .= rand(0, 9);
|
||||
}
|
||||
return $otp;
|
||||
}
|
||||
return $otp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by : Hritik RD
|
||||
* Created at : 12 July 2024
|
||||
* Use : To Get Opening hours of Restaurant By NAME based on Google Maps using Google Places APIs
|
||||
*/
|
||||
|
||||
if (!function_exists('getOpeningHoursOfRestaurant')) {
|
||||
function getOpeningHoursOfRestaurant($restaurantName)
|
||||
{
|
||||
|
||||
$googlePlaceApiKey = config('constants.googlePlaces.api_key'); // Your webhook secret key
|
||||
// dd($googlePlaceApiKey);
|
||||
|
||||
$client = new Client();
|
||||
$url = 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json';
|
||||
|
||||
$response = $client->get($url, [
|
||||
'query' => [
|
||||
'fields' => 'place_id',
|
||||
'input' => $restaurantName,
|
||||
'inputtype' => 'textquery',
|
||||
'key' => $googlePlaceApiKey
|
||||
]
|
||||
]);
|
||||
$placeData = json_decode($response->getBody(), true);
|
||||
|
||||
if (isset($placeData['candidates'][0]['place_id'])) {
|
||||
$placeId = $placeData['candidates'][0]['place_id'];
|
||||
// return $placeId;
|
||||
} else {
|
||||
$placeId = "N/A";
|
||||
// return response()->json($placeId);
|
||||
return $placeId;
|
||||
}
|
||||
|
||||
|
||||
// $placeId = 'ChIJT3dpYcy35zsRLxY5KTTMqhU'; // You can also pass this as a parameter if needed
|
||||
$client = new Client();
|
||||
$url = 'https://maps.googleapis.com/maps/api/place/details/json';
|
||||
|
||||
$response = $client->get($url, [
|
||||
'query' => [
|
||||
'fields' => 'name,rating,formatted_phone_number,opening_hours',
|
||||
'place_id' => $placeId,
|
||||
'key' => $googlePlaceApiKey
|
||||
]
|
||||
]);
|
||||
|
||||
$data = json_decode($response->getBody(), true);
|
||||
if (isset($data['result']['opening_hours']['weekday_text'])) {
|
||||
$hours = $data['result']['opening_hours']['weekday_text'];
|
||||
// return response()->json(['place_id' => $placeId]);
|
||||
} else {
|
||||
$hours = "N/A";
|
||||
}
|
||||
return $hours;
|
||||
// dd($data);
|
||||
// return response()->json($data);
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('getOperatingHours')) {
|
||||
|
||||
function getOperatingHours($placeName, $address)
|
||||
{
|
||||
$client = new Client();
|
||||
$googlePlaceApiKey = config('constants.googlePlaces.api_key');
|
||||
|
||||
$cacheKey = 'restaurant_hours_' . $placeName;
|
||||
$cacheKeyIsRestaurantOpen = 'is_restaurant_open_now_' . $placeName;
|
||||
|
||||
if (Cache::has($cacheKey)) {
|
||||
return [
|
||||
'operating_hours' => Cache::get($cacheKey),
|
||||
'is_open_now' => Cache::get($cacheKeyIsRestaurantOpen),
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
// Get place_id
|
||||
$placeResponse = $client->get('https://maps.googleapis.com/maps/api/place/findplacefromtext/json', [
|
||||
'query' => [
|
||||
'fields' => 'place_id',
|
||||
'input' => $placeName . ' ' . $address,
|
||||
'inputtype' => 'textquery',
|
||||
'key' => $googlePlaceApiKey
|
||||
]
|
||||
]);
|
||||
$placeData = json_decode($placeResponse->getBody(), true);
|
||||
|
||||
if (isset($placeData['candidates'][0]['place_id'])) {
|
||||
$placeId = $placeData['candidates'][0]['place_id'];
|
||||
|
||||
// Get operating hours
|
||||
$detailResponse = $client->get('https://maps.googleapis.com/maps/api/place/details/json', [
|
||||
'query' => [
|
||||
'fields' => 'opening_hours',
|
||||
'place_id' => $placeId,
|
||||
'key' => $googlePlaceApiKey
|
||||
]
|
||||
]);
|
||||
$detailData = json_decode($detailResponse->getBody(), true);
|
||||
|
||||
if (isset($detailData['result']['opening_hours']['weekday_text'])) {
|
||||
$hours = $detailData['result']['opening_hours']['weekday_text'];
|
||||
$isOpenNow = $detailData['result']['opening_hours']['open_now'];
|
||||
|
||||
Cache::put($cacheKey, $hours, now()->addHours(2));
|
||||
Cache::put($cacheKeyIsRestaurantOpen, $isOpenNow, now()->addHours(2));
|
||||
|
||||
return [
|
||||
'operating_hours' => $hours,
|
||||
'is_open_now' => $isOpenNow,
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Restaurant Get service failed : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return [
|
||||
'operating_hours' => "N/A",
|
||||
'is_open_now' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,19 +21,19 @@ class onesignalhelper
|
||||
'contents' => ['en' => $message],
|
||||
'headings' => ['en' => $title],
|
||||
'content_available' => true,
|
||||
'data' => [
|
||||
'content_type' => $content_type,
|
||||
'id' => $id,
|
||||
],
|
||||
// 'data' => [
|
||||
// 'content_type' => $content_type,
|
||||
// 'id' => $id,
|
||||
// ],
|
||||
'big_picture' => $imageUrl,
|
||||
|
||||
'external_id' => [$playerId]
|
||||
// 'external_id' => [$playerId],
|
||||
// 'authorization' => env('ONE_SIGNAL_AUTHORIZE')
|
||||
];
|
||||
|
||||
$result = OneSignal::sendPush($fields, null ,env('ONE_SIGNAL_APP_ID'));
|
||||
Log::info("Notification sending To " . $playerId);
|
||||
Log::info($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,13 +66,6 @@ class onesignalhelper
|
||||
try {
|
||||
$currentUtcTime = Carbon::now();
|
||||
|
||||
// $data = new NotificationDetails();
|
||||
// $data->principal_xid = $customerId;
|
||||
// $data->type = $type;
|
||||
// $data->date_added = $currentUtcTime;
|
||||
// $data->description = $description;
|
||||
// $data->save();
|
||||
|
||||
$newRecord = NotificationDetails::create([
|
||||
'principal_xid' => $customerId,
|
||||
'type' => $type,
|
||||
@@ -81,7 +74,9 @@ class onesignalhelper
|
||||
'image' => $imagePath,
|
||||
|
||||
]);
|
||||
Log::info('success'. $newRecord);
|
||||
} catch (\Exception $e) {
|
||||
Log::info('error'. $e);
|
||||
// Return response in case of error
|
||||
return response()->json([
|
||||
'status' => 500,
|
||||
|
||||
@@ -34,7 +34,7 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
// \App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
@@ -43,6 +43,14 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'webhook' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// Do not include the VerifyCsrfToken middleware here
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ class CheckStatus
|
||||
{
|
||||
|
||||
$admin = auth()->guard('admin')->user();
|
||||
Log::info($admin);
|
||||
// Log::info($admin);
|
||||
if ($admin && $admin->is_active == 1 && ($admin->principal_type_xid == 1 || $admin->principal_type_xid == 2)) {
|
||||
return $next($request);
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Session;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CustomerJwtMiddleware
|
||||
{
|
||||
@@ -32,9 +33,14 @@ class CustomerJwtMiddleware
|
||||
$user = JWTAuth::setToken($token)->authenticate();
|
||||
|
||||
// Check if authentication was successful and user type is correct
|
||||
if (!$user || $user->principal_type_xid !== 3) {
|
||||
|
||||
if (!$user || $user->principal_type_xid != 3) {
|
||||
return response()->json(['status' => 'error', 'status_code' => 401, 'message' => 'Unauthorized access'], 401);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Session::flash('vendorToken', $token);
|
||||
} catch (JWTException $e) {
|
||||
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Session;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
class RestaurantJwtMiddleware
|
||||
{
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class RestaurantJwtMiddleware
|
||||
$user = JWTAuth::setToken($token)->authenticate();
|
||||
|
||||
// Check if the user is of restaurant type
|
||||
if (!$user ||$user->principal_type_xid !== 4) {
|
||||
if (!$user ||$user->principal_type_xid != 4) {
|
||||
return response()->json(['status' => 'error', 'status_code' => 401, 'message' => 'Unauthorized access'], 401);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ class VerifyCsrfToken extends Middleware
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'stripe/webhook',
|
||||
'stripe-webhooks',
|
||||
'/stripe/webhook',
|
||||
'/stripe-webhooks'
|
||||
];
|
||||
}
|
||||
|
||||
68
app/Jobs/FetchOperatingHours.php
Normal file
68
app/Jobs/FetchOperatingHours.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
|
||||
class FetchOperatingHours implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
protected $restaurantName;
|
||||
protected $googlePlaceApiKey;
|
||||
|
||||
public function __construct($restaurantName, $googlePlaceApiKey)
|
||||
{
|
||||
$this->restaurantName = $restaurantName;
|
||||
$this->googlePlaceApiKey = $googlePlaceApiKey;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// $client = new Client();
|
||||
// $url = 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json';
|
||||
|
||||
// $response = $client->get($url, [
|
||||
// 'query' => [
|
||||
// 'fields' => 'place_id',
|
||||
// 'input' => $this->restaurantName,
|
||||
// 'inputtype' => 'textquery',
|
||||
// 'key' => $this->googlePlaceApiKey
|
||||
// ]
|
||||
// ]);
|
||||
// $placeData = json_decode($response->getBody(), true);
|
||||
|
||||
// if (isset($placeData['candidates'][0]['place_id'])) {
|
||||
// $placeId = $placeData['candidates'][0]['place_id'];
|
||||
|
||||
// $url = 'https://maps.googleapis.com/maps/api/place/details/json';
|
||||
// $response = $client->get($url, [
|
||||
// 'query' => [
|
||||
// 'fields' => 'opening_hours',
|
||||
// 'place_id' => $placeId,
|
||||
// 'key' => $this->googlePlaceApiKey
|
||||
// ]
|
||||
// ]);
|
||||
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// if (isset($data['result']['opening_hours']['weekday_text'])) {
|
||||
// $hours = $data['result']['opening_hours']['weekday_text'];
|
||||
// Cache::put('restaurant_hours_' . $this->restaurantName, $hours, now()->addHours(24));
|
||||
// } else {
|
||||
// Cache::put('restaurant_hours_' . $this->restaurantName, "N/A", now()->addHours(24));
|
||||
// }
|
||||
// } else {
|
||||
// Cache::put('restaurant_hours_' . $this->restaurantName, "N/A", now()->addHours(24));
|
||||
// }
|
||||
}
|
||||
}
|
||||
65
app/Mail/AccountRegister.php
Normal file
65
app/Mail/AccountRegister.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AccountRegister extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $restaurantuser;
|
||||
public $restaurantName;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param IamPrincipal $restaurantuser
|
||||
* @param string $restaurantName
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IamPrincipal $restaurantuser, $restaurantName)
|
||||
{
|
||||
$this->restaurantuser = $restaurantuser;
|
||||
$this->restaurantName = $restaurantName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('Admin.pages.mail.account_register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*
|
||||
* @return \Illuminate\Mail\Mailables\Envelope
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'New Account Registration Details',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ class Add_Subadmin extends Mailable
|
||||
public function build()
|
||||
{
|
||||
// $otp = $this->otp;
|
||||
return $this->subject('OTP From Cheers to the Session')->view('mail.subadmin');
|
||||
return $this->subject('OTP From Cheers to the Season')->view('mail.subadmin');
|
||||
}
|
||||
}
|
||||
|
||||
57
app/Mail/RestUserDisapproval.php
Normal file
57
app/Mail/RestUserDisapproval.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RestUserDisapproval extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $detail;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($detail)
|
||||
{
|
||||
$this->detail = $detail;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Rest User Disapproval',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$detail = $this->detail;
|
||||
// dd($data);
|
||||
return $this->subject('Rest User Approval')
|
||||
->view('Admin.pages.mail.rest_user_disapproval', ["content" => $detail]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
17
app/Models/CustomReferralCode.php
Normal file
17
app/Models/CustomReferralCode.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
class CustomReferralCode extends Model
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
protected $table = 'custom_referral_code';
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -13,6 +13,7 @@ use App\Models\admin\ManageFeedback;
|
||||
use App\Models\ManageModuleLink;
|
||||
use App\Models\ManageModule;
|
||||
use App\Models\OrderedPassport;
|
||||
use App\Models\ReferralUsers;
|
||||
|
||||
|
||||
class IamPrincipal extends Authenticatable implements JWTSubject
|
||||
@@ -24,6 +25,7 @@ class IamPrincipal extends Authenticatable implements JWTSubject
|
||||
// protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'one_signal_player_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
@@ -67,32 +69,7 @@ class IamPrincipal extends Authenticatable implements JWTSubject
|
||||
|
||||
|
||||
|
||||
// protected $fillable =
|
||||
// [
|
||||
// 'principal_type_xid',
|
||||
// 'principal_source_xid',
|
||||
// 'user_name',
|
||||
// 'password_hash',
|
||||
// 'pin',
|
||||
// 'first_name',
|
||||
// 'last_name',
|
||||
// 'gender',
|
||||
// 'date_of_birth',
|
||||
// 'phone_number',
|
||||
// 'other_phone_number',
|
||||
// 'email_address',
|
||||
// 'address_line1',
|
||||
// 'address_line2',
|
||||
// 'city_xid',
|
||||
// 'state_xid',
|
||||
// 'country_xid',
|
||||
// 'post_code',
|
||||
// 'last_login_datetime',
|
||||
// 'profile_photo',
|
||||
// 'referral_code',
|
||||
// 'description',
|
||||
// 'is_active'
|
||||
// ];
|
||||
|
||||
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
@@ -192,4 +169,13 @@ class IamPrincipal extends Authenticatable implements JWTSubject
|
||||
{
|
||||
return $this->hasMany(ManageContactus::class, 'principal_xid', 'id');
|
||||
}
|
||||
|
||||
public function isSubscribed()
|
||||
{
|
||||
return $this->hasMany(Subscriptions::class, 'iam_principal_xid', 'id');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
19
app/Models/ManageReferralRule.php
Normal file
19
app/Models/ManageReferralRule.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ManageReferralRule extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table='manage_referral_rules';
|
||||
protected $fillable=[
|
||||
'id ',
|
||||
'title',
|
||||
'message',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class ManageRestaurant extends Model
|
||||
protected $fillable = [
|
||||
'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio',
|
||||
'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longitude',
|
||||
'is_active', 'created_by', 'modified_by', 'phone_number'
|
||||
'is_active', 'created_by', 'modified_by', 'phone_number','time_hours','max_numb_day','max_numb_week','max_numb_month'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
@@ -55,5 +55,15 @@ class ManageRestaurant extends Model
|
||||
}
|
||||
|
||||
|
||||
public function timeInterval()
|
||||
{
|
||||
return $this->hasMany(RestaurantTimeInterval::class, 'manage_restaurants_xid', 'id');
|
||||
}
|
||||
|
||||
public function closedRestaurant()
|
||||
{
|
||||
return $this->hasMany(RestaurantClosedHour::class, 'restaurant_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
18
app/Models/ManageRule.php
Normal file
18
app/Models/ManageRule.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ManageRule extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'manage_rules';
|
||||
|
||||
protected $fillable = [
|
||||
'message'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -26,4 +26,9 @@ class ManageState extends Model
|
||||
'state_xid',
|
||||
|
||||
];
|
||||
|
||||
public function timeInterval()
|
||||
{
|
||||
return $this->hasMany(TimeInterval::class, 'manage_state_xid', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class NotificationDetails extends Model
|
||||
protected $table = "notification_details";
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'principal_xid', 'type', 'description', 'image', 'date_added'
|
||||
'principal_xid', 'type', 'description', 'image', 'date_added','is_schedule','delivery_schedule','is_active', 'user_type', 'state_ids'
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
@@ -20,4 +20,9 @@ class NotificationDetails extends Model
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'principal_xid', 'id');
|
||||
}
|
||||
|
||||
protected $casts = [
|
||||
'state_ids' => 'array',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class RedeemRestaurant extends Model
|
||||
'count',
|
||||
'redeem_date',
|
||||
'is_redeemption_undone',
|
||||
'state_xid',
|
||||
'redeemption_undone_date',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
|
||||
27
app/Models/ReferralUsers.php
Normal file
27
app/Models/ReferralUsers.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use app\Models\IamPrincipal;
|
||||
class ReferralUsers extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
protected $table = 'referral_users';
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function referredUser()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
|
||||
}
|
||||
|
||||
public function refeersUser()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'referred_user_xid', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Models/RestaurantClosedHour.php
Normal file
20
app/Models/RestaurantClosedHour.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RestaurantClosedHour extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'restaurant_closed_hours';
|
||||
|
||||
protected $fillable = ['restaurant_id', 'day_of_week', 'start_time', 'end_time'];
|
||||
|
||||
|
||||
public function restaurant()
|
||||
{
|
||||
return $this->belongsTo(ManageRestaurant::class);
|
||||
}
|
||||
}
|
||||
21
app/Models/RestaurantTimeInterval.php
Normal file
21
app/Models/RestaurantTimeInterval.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RestaurantTimeInterval extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'resaurant_time_intervals';
|
||||
|
||||
protected $fillable = [
|
||||
'manage_restaurants_xid',
|
||||
'time_hours',
|
||||
'time_interval',
|
||||
'is_active',
|
||||
'quantity'
|
||||
|
||||
];
|
||||
}
|
||||
31
app/Models/SubscriptionProducts.php
Normal file
31
app/Models/SubscriptionProducts.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscriptionProducts extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'subscription_products';
|
||||
protected $guarded = [];
|
||||
|
||||
protected $fillable =[
|
||||
'id',
|
||||
'product_name',
|
||||
'product_value',
|
||||
'product_details',
|
||||
'stripe_product_id',
|
||||
'stripe_price_id',
|
||||
'is_active',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'modified_by',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
32
app/Models/Subscriptions.php
Normal file
32
app/Models/Subscriptions.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subscriptions extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'subscriptions';
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function iamPrincipal()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
|
||||
}
|
||||
|
||||
public function subscriptionProduct()
|
||||
{
|
||||
return $this->belongsTo(SubscriptionProducts::class, 'subscription_product_xid', 'id');
|
||||
}
|
||||
}
|
||||
22
app/Models/TimeInterval.php
Normal file
22
app/Models/TimeInterval.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TimeInterval extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'time_intervals';
|
||||
|
||||
protected $fillable = [
|
||||
'manage_state_xid',
|
||||
'time_hours',
|
||||
'time_interval',
|
||||
'is_active',
|
||||
'quantity'
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
return Limit::perMinute(150)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
|
||||
@@ -54,11 +54,16 @@ class AuthServices
|
||||
DB::beginTransaction();
|
||||
|
||||
do {
|
||||
$referral_code = \Str::random(10);
|
||||
$referral_code = strtoupper($this->generateRandomString(10));
|
||||
} while (IamPrincipal::where('referral_code', $referral_code)->exists());
|
||||
|
||||
if ($request->one_signal_player_id == "null") {
|
||||
$playerId = null;
|
||||
} else {
|
||||
$playerId = $request->one_signal_player_id;
|
||||
}
|
||||
$user = IamPrincipal::create([
|
||||
'one_signal_player_id' => $request->one_signal_player_id,
|
||||
'one_signal_player_id' => $playerId,
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'email_address' => $request->email_address,
|
||||
@@ -89,10 +94,6 @@ class AuthServices
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function login($request)
|
||||
{
|
||||
try {
|
||||
@@ -118,8 +119,14 @@ class AuthServices
|
||||
Log::error('Customer Login Failed');
|
||||
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
|
||||
}
|
||||
Log::info($request->one_signal_player_id );
|
||||
if ($request->one_signal_player_id == "null") {
|
||||
$playerId = null;
|
||||
} else {
|
||||
$playerId = $request->one_signal_player_id;
|
||||
}
|
||||
|
||||
$isExistEmail->one_signal_player_id = $request->one_signal_player_id;
|
||||
$isExistEmail->one_signal_player_id = $playerId;
|
||||
$isExistEmail->save();
|
||||
$response = [
|
||||
'iam_principal_xid' => $isExistEmail->id,
|
||||
@@ -310,4 +317,36 @@ class AuthServices
|
||||
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchState($request)
|
||||
{
|
||||
try {
|
||||
$searchQuery = $request->input('search_data');
|
||||
|
||||
$query = ManageState::select('id', 'name')->where('is_active', 1);
|
||||
|
||||
if ($searchQuery) {
|
||||
$query->where(function ($q) use ($searchQuery) {
|
||||
$q->where('name', 'like', '%' . $searchQuery . '%');
|
||||
});
|
||||
}
|
||||
$restaurants = $query->get();
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), $restaurants, 200);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage());
|
||||
return response()->json(__('something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
function generateRandomString($length = 10)
|
||||
{
|
||||
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class ContactUsApiServices
|
||||
|
||||
//response data
|
||||
Log::info('Contact form data Created successfully');
|
||||
return jsonResponseWithSuccessMessageApi(__('success.save_data'), [], 201);
|
||||
return jsonResponseWithSuccessMessageApi(__('success.message_sent'), [], 201);
|
||||
} else {
|
||||
Log::error('Contact not found in addVendorContactForm.');
|
||||
return jsonResponseWithErrorMessageApi(__('auth.validation_failed'), 403);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Services\APIs\CustomerAPIs;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\Subscriptions;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -27,13 +28,21 @@ class CustomerApiServices
|
||||
'referral_code'
|
||||
)->find($user->id);
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
|
||||
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId)
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->exists();
|
||||
|
||||
if ($data->profile_photo) {
|
||||
$data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo);;
|
||||
$data->profile_photo = ListingImageUrl('profile_image', $data->profile_photo);
|
||||
} else {
|
||||
$data->profile_photo = asset('public/assets/img/blankProfile.png');
|
||||
}
|
||||
// $data['voucher_redeemed'] = MyPassportVoucher::where([['iam_principal_xid', $customerIamId], ['is_redeem', 1]])->count();
|
||||
|
||||
$data->is_subscribed = $isSubscribedUser;
|
||||
|
||||
return $data;
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Customer Get data service failed : ' . $ex->getMessage());
|
||||
@@ -42,6 +51,7 @@ class CustomerApiServices
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updateUserProfileDetailService($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
@@ -59,33 +69,28 @@ class CustomerApiServices
|
||||
$data->profile_photo = $tnormalImage;
|
||||
$data->save();
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
|
||||
if ($request->has('date_of_birth')) {
|
||||
$data->date_of_birth = $request->date_of_birth;
|
||||
$data->save();
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
if ($request->has('first_name')) {
|
||||
$data->first_name = $request->first_name;
|
||||
$data->save();
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
if ($request->has('last_name')) {
|
||||
$data->last_name = $request->last_name;
|
||||
$data->save();
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
|
||||
if ($request->has('phone_number')) {
|
||||
$data->phone_number = $request->phone_number;
|
||||
$data->save();
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
|
||||
if ($request->has('email_address')) {
|
||||
@@ -139,10 +144,20 @@ class CustomerApiServices
|
||||
}
|
||||
}
|
||||
|
||||
public function CheckSubscription($customerIamId)
|
||||
{
|
||||
try {
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$isSubscribedUser = Subscriptions::where('iam_principal_xid', $customerIamId)
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->exists();
|
||||
|
||||
|
||||
return $isSubscribedUser;
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Customer subscription Get data service failed : ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class FeedbackApiServices
|
||||
$feedback = ManageFeedback::create($feedbackData);
|
||||
|
||||
DB::commit();
|
||||
Log::info('Feedback added successfully');
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.feedback_store'), [], 200);
|
||||
} catch (Exception $ex) {
|
||||
DB::rollBack();
|
||||
|
||||
@@ -10,8 +10,16 @@ use App\Models\IamPrincipalRestaurantRole;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\RedeemRestaurant;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\RestaurantTimeInterval;
|
||||
use App\Models\TimeInterval;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Jobs\FetchOperatingHours;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Promise\Utils;
|
||||
|
||||
|
||||
|
||||
@@ -20,28 +28,71 @@ class RestaurantApiServices
|
||||
public function getCoordinates($customerIamId)
|
||||
{
|
||||
try {
|
||||
$restaurants = ManageRestaurant::with('operatingHours')->select(
|
||||
'id',
|
||||
'name',
|
||||
'image',
|
||||
'address',
|
||||
'short_id',
|
||||
'latitude',
|
||||
'longtitude'
|
||||
)
|
||||
->where('is_active', '1')
|
||||
->get()
|
||||
->toArray();
|
||||
// Fetch all active restaurants
|
||||
$restaurants = ManageRestaurant::with('closedRestaurant')
|
||||
->select('id', 'name', 'image', 'address', 'short_id', 'latitude', 'longtitude', 'state_xid')
|
||||
->where('is_active', '1')->get();
|
||||
|
||||
foreach ($restaurants as &$restaurant) {
|
||||
$restaurant['image'] = ListingImageUrl('restaurant_images', $restaurant['image']);
|
||||
|
||||
$isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
->where('restaurant_xid', $restaurant['id'])
|
||||
->exists();
|
||||
$restaurant['is_favourite'] = $isFavourite;
|
||||
|
||||
$hoursData = getOperatingHours($restaurant['name'], $restaurant['address']);
|
||||
$restaurant['operating_hours'] = $hoursData['operating_hours'];
|
||||
$restaurant['is_restaurant_open_now_as_per_google'] = $hoursData['is_open_now'];
|
||||
|
||||
|
||||
$lastRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('manage_restaurants_xid', $restaurant->id)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
$restTime = RestaurantTimeInterval::select('time_hours')->where('manage_restaurants_xid', $restaurant->id)->first();
|
||||
$stateTime = TimeInterval::select('time_hours')->where('manage_state_xid', $restaurant->state_xid)->first();
|
||||
|
||||
$restTimeHours = $restTime ? $restTime->time_hours : 0;
|
||||
$stateTimeHours = $stateTime ? $stateTime->time_hours : 0;
|
||||
|
||||
$restaurant['next_redeem_time'] = "Now";
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
|
||||
if ($lastRedeem) {
|
||||
$lastRedeemTime = Carbon::parse($lastRedeem->redeem_date);
|
||||
|
||||
$restAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($restTimeHours));
|
||||
$stateAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
if ($currentTime < $restAllowedRedeemTime) {
|
||||
$restaurant['next_redeem_time'] = $restAllowedRedeemTime->toDateTimeString();
|
||||
} else if ($currentTime < $stateAllowedRedeemTime) {
|
||||
$restaurant['next_redeem_time'] = $stateAllowedRedeemTime->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
// Include logic for preventing redemption in the same state
|
||||
if ($restaurant['next_redeem_time'] === "Now") {
|
||||
// Fetch the last redeem time for any restaurant in the same state
|
||||
$lastStateRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('state_xid', $restaurant->state_xid)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
if ($lastStateRedeem) {
|
||||
$lastStateRedeemTime = Carbon::parse($lastStateRedeem->redeem_date);
|
||||
$stateAllowedRedeemTime = $lastStateRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
if ($currentTime < $stateAllowedRedeemTime) {
|
||||
$restaurant['next_redeem_time'] = $stateAllowedRedeemTime->toDateTimeString();
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $restaurants, 200);
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Restaurant Get service failed : ' . $ex->getMessage());
|
||||
@@ -49,6 +100,10 @@ class RestaurantApiServices
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function addToFavourite($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
@@ -83,19 +138,29 @@ class RestaurantApiServices
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function listFavRestaurant($customerIamId)
|
||||
{
|
||||
try {
|
||||
$list = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)->get()->toArray();
|
||||
// Get list of favorite restaurant IDs
|
||||
$customerFavouriteRestaurants = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
->pluck('restaurant_xid')
|
||||
->toArray();
|
||||
|
||||
$restaurants = ManageRestaurant::with('operatingHours')->where('is_active', '1')->whereIn('id', $customerFavouriteRestaurants)->get();
|
||||
// Fetch the restaurant details
|
||||
$restaurants = ManageRestaurant::with('closedRestaurant')->where('is_active', '1')
|
||||
->whereIn('id', $customerFavouriteRestaurants)
|
||||
->get();
|
||||
|
||||
|
||||
|
||||
foreach ($restaurants as &$res) {
|
||||
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
|
||||
|
||||
// Fetch operating hours and open status using the helper function
|
||||
$data = getOperatingHours($res->name, $res->address);
|
||||
|
||||
$res['operating_hours'] = $data['operating_hours'];
|
||||
$res['is_restaurant_open_now_as_per_google'] = $data['is_open_now'];
|
||||
}
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_updated_successfully'), $restaurants, 200);
|
||||
@@ -106,10 +171,164 @@ class RestaurantApiServices
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// public function DetailRestaurant($customerIamId, $id)
|
||||
// {
|
||||
// try {
|
||||
// $rest = ManageRestaurant::with('closedRestaurant')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'state_xid')
|
||||
// ->where('short_id', $id)
|
||||
// ->where('is_active', '1')
|
||||
// ->first();
|
||||
|
||||
// if ($rest) {
|
||||
// $rest->image = ListingImageUrl('restaurant_images', $rest->image);
|
||||
|
||||
// $isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
// ->where('restaurant_xid', $rest->id)
|
||||
// ->exists();
|
||||
|
||||
// $rest->is_favourite = $isFavourite;
|
||||
|
||||
// $redeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
// ->where('manage_restaurants_xid', $rest->id)
|
||||
// ->where('is_redeem', "1")
|
||||
// ->first();
|
||||
|
||||
// $restTime = RestaurantTimeInterval::where('manage_restaurants_xid', $rest->id)->first();
|
||||
// $restTimeHours = $restTime ? $restTime->time_hours : 0;
|
||||
|
||||
// // Initialize Guzzle HTTP client
|
||||
// $client = new Client();
|
||||
// $googlePlaceApiKey = config('constants.googlePlaces.api_key');
|
||||
|
||||
// // Cache key for operating hours
|
||||
// $cacheKey = 'restaurant_hours_' . $rest->name;
|
||||
// $cacheKeyIsRestaurantOpen = 'is_restaurant_open_now_' . $rest->name;
|
||||
|
||||
// if (Cache::has($cacheKey)) {
|
||||
// $rest->operating_hours = Cache::get($cacheKey);
|
||||
// $rest->is_restaurant_open_now_as_per_google = Cache::get($cacheKeyIsRestaurantOpen);
|
||||
// } else {
|
||||
// // Prepare the first request to get the place_id
|
||||
// $placeResponse = $client->get('https://maps.googleapis.com/maps/api/place/findplacefromtext/json', [
|
||||
// 'query' => [
|
||||
// 'fields' => 'place_id',
|
||||
// 'input' => $rest->name . ' ' . $rest->address,
|
||||
// 'inputtype' => 'textquery',
|
||||
// 'key' => $googlePlaceApiKey
|
||||
// ]
|
||||
// ]);
|
||||
// $placeData = json_decode($placeResponse->getBody(), true);
|
||||
|
||||
// if (isset($placeData['candidates'][0]['place_id'])) {
|
||||
// $placeId = $placeData['candidates'][0]['place_id'];
|
||||
|
||||
// // Prepare the second request to get the operating hours
|
||||
// $detailResponse = $client->get('https://maps.googleapis.com/maps/api/place/details/json', [
|
||||
// 'query' => [
|
||||
// 'fields' => 'opening_hours',
|
||||
// 'place_id' => $placeId,
|
||||
// 'key' => $googlePlaceApiKey
|
||||
// ]
|
||||
// ]);
|
||||
// $detailData = json_decode($detailResponse->getBody(), true);
|
||||
|
||||
// if (isset($detailData['result']['opening_hours']['weekday_text'])) {
|
||||
// $hours = $detailData['result']['opening_hours']['weekday_text'];
|
||||
// $isOpenNow = $detailData['result']['opening_hours']['open_now'];
|
||||
// Cache::put($cacheKey, $hours, now()->addHours(2));
|
||||
// Cache::put($cacheKeyIsRestaurantOpen, $isOpenNow, now()->addHours(2));
|
||||
|
||||
// $rest->operating_hours = $hours;
|
||||
// $rest->is_restaurant_open_now_as_per_google = $isOpenNow;
|
||||
// } else {
|
||||
// $rest->operating_hours = "N/A";
|
||||
|
||||
// $rest->is_restaurant_open_now_as_per_google = false;
|
||||
|
||||
// }
|
||||
// } else {
|
||||
// $rest->operating_hours = "N/A";
|
||||
// $rest->is_restaurant_open_now_as_per_google = false;
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($redeem) {
|
||||
// $rest->is_Redeemed = true;
|
||||
// $rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours(intval($restTimeHours))->toDateTimeString();
|
||||
// } else {
|
||||
// $rest->is_Redeemed = false;
|
||||
// $rest->redeem_date = null;
|
||||
// }
|
||||
|
||||
// // Calculate next redemption time
|
||||
// $lastRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
// ->where('manage_restaurants_xid', $rest->id)
|
||||
// ->where('is_redeem', 1)
|
||||
// ->orderBy('redeem_date', 'desc')
|
||||
// ->first();
|
||||
|
||||
// $stateTime = TimeInterval::select('time_hours')->where('manage_state_xid', $rest->state_xid)->first();
|
||||
// $stateTimeHours = $stateTime ? $stateTime->time_hours : 0;
|
||||
|
||||
// $currentTime = Carbon::now();
|
||||
// $nextRedeemTime = "Now";
|
||||
|
||||
// if ($lastRedeem) {
|
||||
// $lastRedeemTime = Carbon::parse($lastRedeem->redeem_date);
|
||||
|
||||
// $restAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($restTimeHours));
|
||||
// $stateAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
// if ($currentTime < $restAllowedRedeemTime) {
|
||||
// $nextRedeemTime = $restAllowedRedeemTime->toDateTimeString();
|
||||
// } else if ($currentTime < $stateAllowedRedeemTime) {
|
||||
// $nextRedeemTime = $stateAllowedRedeemTime->toDateTimeString();
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Include logic for preventing redemption in the same state
|
||||
// if ($nextRedeemTime === "Now") {
|
||||
// $lastStateRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
// ->where('state_xid', $rest->state_xid)
|
||||
// ->where('is_redeem', 1)
|
||||
// ->orderBy('redeem_date', 'desc')
|
||||
// ->first();
|
||||
|
||||
// if ($lastStateRedeem) {
|
||||
// $lastStateRedeemTime = Carbon::parse($lastStateRedeem->redeem_date);
|
||||
// $stateAllowedRedeemTime = $lastStateRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
// if ($currentTime < $stateAllowedRedeemTime) {
|
||||
// $nextRedeemTime = $stateAllowedRedeemTime->toDateTimeString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// $rest->next_redeem_time = $nextRedeemTime;
|
||||
// }
|
||||
|
||||
// if (!$rest) {
|
||||
// return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404);
|
||||
// }
|
||||
|
||||
// return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $rest, 200);
|
||||
// } catch (Exception $e) {
|
||||
// Log::error("Error fetching restaurant data: " . $e->getMessage());
|
||||
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
// }
|
||||
// }
|
||||
public function DetailRestaurant($customerIamId, $id)
|
||||
{
|
||||
try {
|
||||
$rest = ManageRestaurant::with('operatingHours')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude')->where('short_id', $id)->where('is_active', '1')->first();
|
||||
$rest = ManageRestaurant::with('closedRestaurant')
|
||||
->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'state_xid')
|
||||
->where('short_id', $id)
|
||||
->where('is_active', '1')
|
||||
->first();
|
||||
|
||||
if ($rest) {
|
||||
$rest->image = ListingImageUrl('restaurant_images', $rest->image);
|
||||
@@ -124,15 +343,70 @@ class RestaurantApiServices
|
||||
->where('is_redeem', "1")
|
||||
->first();
|
||||
|
||||
$hoursData = getOperatingHours($rest->name, $rest->address);
|
||||
$rest->operating_hours = $hoursData['operating_hours'];
|
||||
$rest->is_restaurant_open_now_as_per_google = $hoursData['is_open_now'];
|
||||
|
||||
|
||||
|
||||
|
||||
$restTime = RestaurantTimeInterval::where('manage_restaurants_xid', $rest->id)->first();
|
||||
$restTimeHours = $restTime ? $restTime->time_hours : 0;
|
||||
if ($redeem) {
|
||||
$rest->is_Redeemed = true;
|
||||
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours(4)->toDateTimeString();
|
||||
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours(intval($restTimeHours))->toDateTimeString();
|
||||
} else {
|
||||
$rest->is_Redeemed = false;
|
||||
$rest->redeem_date = null;
|
||||
}
|
||||
|
||||
$lastRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('manage_restaurants_xid', $rest->id)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
$stateTime = TimeInterval::select('time_hours')->where('manage_state_xid', $rest->state_xid)->first();
|
||||
$stateTimeHours = $stateTime ? $stateTime->time_hours : 0;
|
||||
|
||||
$currentTime = Carbon::now();
|
||||
$nextRedeemTime = "Now";
|
||||
|
||||
if ($lastRedeem) {
|
||||
$lastRedeemTime = Carbon::parse($lastRedeem->redeem_date);
|
||||
|
||||
$restAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($restTimeHours));
|
||||
$stateAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
if ($currentTime < $restAllowedRedeemTime) {
|
||||
$nextRedeemTime = $restAllowedRedeemTime->toDateTimeString();
|
||||
} else if ($currentTime < $stateAllowedRedeemTime) {
|
||||
$nextRedeemTime = $stateAllowedRedeemTime->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
// Include logic for preventing redemption in the same state
|
||||
if ($nextRedeemTime === "Now") {
|
||||
$lastStateRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('state_xid', $rest->state_xid)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
if ($lastStateRedeem) {
|
||||
$lastStateRedeemTime = Carbon::parse($lastStateRedeem->redeem_date);
|
||||
$stateAllowedRedeemTime = $lastStateRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
|
||||
if ($currentTime < $stateAllowedRedeemTime) {
|
||||
$nextRedeemTime = $stateAllowedRedeemTime->toDateTimeString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rest->next_redeem_time = $nextRedeemTime;
|
||||
}
|
||||
|
||||
|
||||
if (!$rest) {
|
||||
return jsonResponseWithErrorMessage(__('auth.restaurant_data_not_found'), 404);
|
||||
}
|
||||
@@ -144,6 +418,7 @@ class RestaurantApiServices
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function removeFromFavourite($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
@@ -177,12 +452,13 @@ class RestaurantApiServices
|
||||
public function searchFromFavourite($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
// Get list of favorite restaurant IDs
|
||||
$customerFavouriteRestaurants = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
->pluck('restaurant_xid')
|
||||
->toArray();
|
||||
|
||||
$restaurantsQuery = ManageRestaurant::with('operatingHours')
|
||||
->where('is_active', '1')
|
||||
// Fetch the restaurant details
|
||||
$restaurantsQuery = ManageRestaurant::with('closedRestaurant')->where('is_active', '1')
|
||||
->whereIn('id', $customerFavouriteRestaurants);
|
||||
|
||||
$searchData = $request->input('search_data');
|
||||
@@ -191,15 +467,23 @@ class RestaurantApiServices
|
||||
$restaurantsQuery->where(function ($query) use ($searchData) {
|
||||
$query->where('name', 'like', "%$searchData%")
|
||||
->orWhere('description', 'like', "%$searchData%")
|
||||
->orWhere('address', 'like', "%$searchData%");
|
||||
->orWhere('address', 'like', "%$searchData%")
|
||||
->orWhereHas('state', function ($stateQuery) use ($searchData) {
|
||||
$stateQuery->where('name', 'like', "%$searchData%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$restaurants = $restaurantsQuery->get();
|
||||
|
||||
foreach ($restaurants as &$res) {
|
||||
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
|
||||
}
|
||||
|
||||
$data = getOperatingHours($res->name, $res->address);
|
||||
|
||||
$res['operating_hours'] = $data['operating_hours'];
|
||||
$res['is_restaurant_open_now_as_per_google'] = $data['is_open_now'];
|
||||
}
|
||||
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.restaurant_search'), $restaurants, 200);
|
||||
} catch (Exception $ex) {
|
||||
@@ -211,100 +495,232 @@ class RestaurantApiServices
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function redeemRestaurant($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
$restaurantId = $request->id;
|
||||
{
|
||||
try {
|
||||
$restaurantId = $request->id;
|
||||
|
||||
$restaurant = ManageRestaurant::with('operatingHours')->where('short_id', $restaurantId)->first();
|
||||
$restaurant = ManageRestaurant::with('operatingHours')->where('short_id', $restaurantId)->first();
|
||||
if (!$restaurant) {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.restaurant_not_found'), 404);
|
||||
}
|
||||
|
||||
if (!$restaurant) {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.restaurant_not_found'), 404);
|
||||
}
|
||||
// Check if the restaurant has already been redeemed
|
||||
$restaurantExist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)
|
||||
->where('iam_principal_xid', $customerIamId)
|
||||
->where('is_redeem', 1)
|
||||
->first();
|
||||
|
||||
// Check if the restaurant has already been redeemed
|
||||
$restaurantExist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId)
|
||||
->where('is_redeem', 1)
|
||||
->first();
|
||||
|
||||
if ($restaurantExist) {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.restaurant_already_redeemed'), 400);
|
||||
}
|
||||
if ($restaurantExist) {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.restaurant_already_redeemed'), 403);
|
||||
}
|
||||
|
||||
// Check if there's an existing entry for the restaurant and update it
|
||||
$restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId)->first();
|
||||
if ($restexist) {
|
||||
$restexist->is_redeem = 1;
|
||||
$restexist->redeem_date = now();
|
||||
$restexist->is_redeemption_undone = 0;
|
||||
$restexist->redeemption_undone_date = null;
|
||||
$restexist->save();
|
||||
return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $restexist, 200);
|
||||
}
|
||||
$stateLimitation = TimeInterval::where('manage_state_xid', $restaurant->state_xid)->first();
|
||||
$stateMaxLimitation = $stateLimitation ? $stateLimitation->quantity : 0;
|
||||
$stateMaxIntervalLimitation = $stateLimitation ? $stateLimitation->time_interval : "month";
|
||||
|
||||
// Create a new redeem entry if it doesn't exist
|
||||
$redeemRestaurant = new RedeemRestaurant();
|
||||
$redeemRestaurant->iam_principal_xid = $customerIamId;
|
||||
$redeemRestaurant->manage_restaurants_xid = $restaurant->id;
|
||||
$redeemRestaurant->is_redeem = 1; // Redeem restaurant
|
||||
$redeemRestaurant->redeem_date = now();
|
||||
$redeemRestaurant->is_redeemption_undone = 0;
|
||||
$redeemRestaurant->redeemption_undone_date = null;
|
||||
$redeemRestaurant->save();
|
||||
$restaurantLimitation = RestaurantTimeInterval::where('manage_restaurants_xid', $restaurant->id)->first();
|
||||
$restaurantMaxLimitation = $restaurantLimitation ? $restaurantLimitation->quantity : 0;
|
||||
$restaurantMaxIntervalLimitation = $restaurantLimitation ? $restaurantLimitation->time_interval : "month";
|
||||
|
||||
|
||||
// Calculate the state interval start date
|
||||
$stateIntervalStartDate = $this->calculateIntervalStartDate($stateMaxIntervalLimitation);
|
||||
|
||||
// Count the redeems within the state interval
|
||||
$redeemCountState = RedeemRestaurant::where('state_xid', $restaurant->state_xid)
|
||||
->where('iam_principal_xid', $customerIamId)
|
||||
->count();
|
||||
|
||||
if ($redeemCountState >= $stateMaxLimitation) {
|
||||
return jsonResponseWithDataErrorMessageApi(__('limitexceed'), ('You have reached the maximum limit for redeeming vouchers.'));
|
||||
}
|
||||
|
||||
// Calculate the restaurant interval start date
|
||||
$restaurantIntervalStartDate = $this->calculateIntervalStartDate($restaurantMaxIntervalLimitation);
|
||||
|
||||
// Count the redeems within the restaurant interval
|
||||
$redeemCountRestaurant = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)
|
||||
->where('is_redeem', 1)
|
||||
->where('iam_principal_xid', $customerIamId)
|
||||
->count();
|
||||
|
||||
if ($redeemCountRestaurant >= $restaurantMaxLimitation) {
|
||||
return jsonResponseWithDataErrorMessageApi(__('limitexceed'), ('You have reached the maximum limit for redeeming vouchers.'));
|
||||
}
|
||||
|
||||
// Get the last redeem time
|
||||
$lastRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('state_xid', $restaurant->state_xid)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
$restTime = RestaurantTimeInterval::select('time_hours')->where('manage_restaurants_xid', $restaurant->id)->first();
|
||||
$stateTime = TimeInterval::select('time_hours')->where('manage_state_xid', $restaurant->state_xid)->first();
|
||||
|
||||
$restTimeHours = $restTime ? $restTime->time_hours : 0;
|
||||
$stateTimeHours = $stateTime ? $stateTime->time_hours : 0;
|
||||
|
||||
|
||||
|
||||
$imagePath = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
if ($lastRedeem) {
|
||||
$lastRedeemTime = Carbon::parse($lastRedeem->redeem_date);
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
$customerTitle = "Your Redemption was successful for " . $restaurant->name;
|
||||
$customerMessage = $restaurant->name . " Voucher Redeemed Successfully";
|
||||
$customerContentType = 'Voucher_Redemption';
|
||||
$customerImageUrl = $imagePath;
|
||||
$stateAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($stateTimeHours));
|
||||
$restAllowedRedeemTime = $lastRedeemTime->copy()->addHours(intval($restTimeHours));
|
||||
|
||||
$customerData = IamPrincipal::where('id', $customerIamId)->where('notification_status', 1)->where('principal_type_xid', 3)->first();
|
||||
$restaurants = IamPrincipalRestaurantRole::select('id', 'principal_xid')->where('restaurant_xid', $restaurant->id)->get();
|
||||
if ($currentTime < $stateAllowedRedeemTime) {
|
||||
$remainingTime = $currentTime->diff($stateAllowedRedeemTime);
|
||||
$hours = $remainingTime->h;
|
||||
$minutes = $remainingTime->i;
|
||||
return jsonResponseWithDataErrorMessageApi(__('limitexceed'), ('Please wait before redeeming the next voucher.' . " {$hours} hours and {$minutes} minutes remaining."));
|
||||
}
|
||||
|
||||
foreach ($restaurants as $restaurant) {
|
||||
$restUser = IamPrincipal::where('id', $restaurant->principal_xid)->where('notification_status', 1)->where('principal_type_xid', 4)->first();
|
||||
if ($currentTime < $restAllowedRedeemTime) {
|
||||
$remainingTime = $currentTime->diff($restAllowedRedeemTime);
|
||||
$hours = $remainingTime->h;
|
||||
$minutes = $remainingTime->i;
|
||||
return jsonResponseWithDataErrorMessageApi(__('limitexceed'), ('Please wait before redeeming the next voucher.' . " {$hours} hours and {$minutes} minutes remaining."));
|
||||
}
|
||||
}
|
||||
|
||||
if ($restUser) {
|
||||
$restImagePath = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
$restTitle = "New redemption for " . $restaurant->name;
|
||||
$restMessage = $restaurant->name . " new voucher Redeemed Successfully";
|
||||
$restContent_type = 'Voucher_Redemption';
|
||||
$restImageUrl = $restImagePath;
|
||||
|
||||
// Sending notification to restaurant
|
||||
$pushNotificationToRestaurant = onesignalhelper::restSendNotificationApi(
|
||||
$restUser->one_signal_player_id,
|
||||
$restTitle,
|
||||
$restMessage,
|
||||
$restContent_type,
|
||||
$restImageUrl,
|
||||
|
||||
// Create a new redeem entry if it doesn't exist
|
||||
$redeemRestaurant = new RedeemRestaurant();
|
||||
$redeemRestaurant->iam_principal_xid = $customerIamId;
|
||||
$redeemRestaurant->manage_restaurants_xid = $restaurant->id;
|
||||
$redeemRestaurant->state_xid = $restaurant->state_xid;
|
||||
$redeemRestaurant->is_redeem = 1; // Redeem restaurant
|
||||
$redeemRestaurant->redeem_date = now();
|
||||
$redeemRestaurant->is_redeemption_undone = 0;
|
||||
$redeemRestaurant->redeemption_undone_date = null;
|
||||
$redeemRestaurant->save();
|
||||
|
||||
$imagePath = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
|
||||
$customerTitle = "Your Redemption was successful for " . $restaurant->name;
|
||||
$customerMessage = $restaurant->name . " Voucher Redeemed Successfully";
|
||||
$customerContentType = 'Voucher_Redemption';
|
||||
$customerImageUrl = $imagePath;
|
||||
|
||||
$customerData = IamPrincipal::where('id', $customerIamId)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->first();
|
||||
|
||||
$restaurants = IamPrincipalRestaurantRole::select('id', 'principal_xid')
|
||||
->where('restaurant_xid', $restaurant->id)
|
||||
->get();
|
||||
|
||||
foreach ($restaurants as $restaurantRole) {
|
||||
$restUser = IamPrincipal::where('id', $restaurantRole->principal_xid)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 4)
|
||||
->first();
|
||||
|
||||
if ($restUser) {
|
||||
$restImagePath = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
$restTitle = "New redemption for " . $restaurant->name;
|
||||
$restMessage = $restaurant->name . " new voucher Redeemed Successfully";
|
||||
$restContent_type = 'Voucher_Redemption';
|
||||
$restImageUrl = $restImagePath;
|
||||
|
||||
// Sending notification to restaurant
|
||||
onesignalhelper::restSendNotificationApi(
|
||||
$restUser->one_signal_player_id,
|
||||
$restTitle,
|
||||
$restMessage,
|
||||
$restContent_type,
|
||||
$restImageUrl,
|
||||
$id = null
|
||||
);
|
||||
onesignalhelper::StoreNotificationDetails($restUser->id, $restContent_type, $restTitle, $restImageUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if ($customerData) {
|
||||
// Sending notification to customer
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerData->one_signal_player_id,
|
||||
$customerTitle,
|
||||
$customerMessage,
|
||||
$customerContentType,
|
||||
$customerImageUrl,
|
||||
$id = null
|
||||
);
|
||||
onesignalhelper::StoreNotificationDetails($restUser->id, $restContent_type, $restTitle, $restImageUrl);
|
||||
onesignalhelper::StoreNotificationDetails($customerData->id, $customerContentType, $customerTitle, $customerImageUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if ($customerData) {
|
||||
// Sending notification to customer
|
||||
$pushNotificationToCustomer = onesignalhelper::sendNotificationApi(
|
||||
$customerData->one_signal_player_id,
|
||||
$customerTitle,
|
||||
$customerMessage,
|
||||
$customerContentType,
|
||||
$customerImageUrl,
|
||||
$id = null
|
||||
);
|
||||
|
||||
onesignalhelper::StoreNotificationDetails($customerData->id, $customerContentType, $customerTitle, $customerImageUrl);
|
||||
return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $redeemRestaurant, 200);
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Restaurant Redeem service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateIntervalStartDate($interval)
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
switch ($interval) {
|
||||
case 'day':
|
||||
return $now->copy()->subDay();
|
||||
case 'week':
|
||||
return $now->copy()->subWeek();
|
||||
case 'month':
|
||||
default:
|
||||
return $now->copy()->subMonth();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function searchRestaurant($customerIamId, $request)
|
||||
{
|
||||
try {
|
||||
$restaurantsQuery = ManageRestaurant::with('state', 'closedRestaurant')
|
||||
->where('is_active', '1');
|
||||
|
||||
$searchData = $request->input('search_data');
|
||||
|
||||
if (!empty($searchData)) {
|
||||
$restaurantsQuery->where(function ($query) use ($searchData) {
|
||||
$query->where('name', 'like', "%$searchData%")
|
||||
->orWhere('description', 'like', "%$searchData%")
|
||||
->orWhere('address', 'like', "%$searchData%")
|
||||
->orWhereHas('state', function ($stateQuery) use ($searchData) {
|
||||
$stateQuery->where('name', 'like', "%$searchData%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$restaurants = $restaurantsQuery->get();
|
||||
|
||||
foreach ($restaurants as &$restaurant) {
|
||||
$restaurant['image'] = ListingImageUrl('restaurant_images', $restaurant['image']);
|
||||
|
||||
$isFavourite = CustomerFavouriteRestaurant::where('principal_xid', $customerIamId)
|
||||
->where('restaurant_xid', $restaurant['id'])
|
||||
->exists();
|
||||
$restaurant['is_favourite'] = $isFavourite;
|
||||
|
||||
$data = getOperatingHours($restaurant->name, $restaurant->address);
|
||||
|
||||
$restaurant['operating_hours'] = $data['operating_hours'];
|
||||
$restaurant['is_restaurant_open_now_as_per_google'] = $data['is_open_now'];
|
||||
}
|
||||
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.restaurant_search'), $restaurants, 200);
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Search restaurant service failed: ' . $ex->getMessage());
|
||||
return response()->json([
|
||||
'message' => __('auth.something_went_wrong')
|
||||
], 500);
|
||||
}
|
||||
return jsonResponseWithSuccessMessageApi(__('success.restaurant_redeem'), $redeemRestaurant, 200);
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Restaurant Redeem service failed: ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
41
app/Services/APIs/CustomerAPIs/RulesApiServices.php
Normal file
41
app/Services/APIs/CustomerAPIs/RulesApiServices.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\APIs\CustomerAPIs;
|
||||
|
||||
use App\Models\ManageReferralRule;
|
||||
use App\Models\ManageRule;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use Exception;
|
||||
|
||||
class RulesApiServices
|
||||
{
|
||||
public function getVoucherRules()
|
||||
{
|
||||
try {
|
||||
$data = ManageRule::select('id', 'whats_inside', 'rules')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getReferralRules()
|
||||
{
|
||||
try {
|
||||
$data = ManageReferralRule::select('id', 'how_it_works', 'rules','what_is_referral')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
} catch (Exception $ex) {
|
||||
Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class RedeemApiService
|
||||
public function undoRedemption($restIamId, $request)
|
||||
{
|
||||
try {
|
||||
$voucherDetail = RedeemRestaurant::where('id', $request->voucher_id)->first();
|
||||
$voucherDetail = RedeemRestaurant::where('id', $request->voucher_id)->where('is_redeem', 1)->first();
|
||||
$rest = ManageRestaurant::where('id', $voucherDetail->manage_restaurants_xid)->first();
|
||||
if ($voucherDetail) {
|
||||
$voucherDetail->update([
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\APIs\RestaurantService;
|
||||
|
||||
use App\Mail\AccountRegister;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ManageVoucherModel;
|
||||
use Exception;
|
||||
@@ -79,10 +80,11 @@ class RestAuthApiService
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
$adminEmail = config('constants.ADMIN_EMAIL');
|
||||
|
||||
// $token = auth()->login($restaurantuser);
|
||||
Mail::to($adminEmail)->send(new \App\Mail\AccountRegister($restaurantuser, $selectedRestaurant->name));
|
||||
|
||||
// Return response with user details, access token, and status
|
||||
// Prepare the response data
|
||||
$response = [
|
||||
'user' => $restaurantuser,
|
||||
// 'restaurant_details' => $restaurantId,
|
||||
@@ -94,12 +96,13 @@ class RestAuthApiService
|
||||
} catch (QueryException $e) {
|
||||
// Rollback transaction in case of an error
|
||||
DB::rollBack();
|
||||
Log::error('Restaurant Registration Failed ' . $e->getMessage());
|
||||
Log::error('Restaurant Registration Failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function login($request)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -104,8 +104,8 @@ class RestCMSService
|
||||
public function RestNewsArticles()
|
||||
{
|
||||
try {
|
||||
$data['customer'] = NewsArticle::select('id', 'news_articles_category_xid','name', 'description', 'thumbnail_image', 'image',)
|
||||
->where([['is_active', '0'], ['news_articles_category_xid', '1']])
|
||||
$data['customer'] = NewsArticle::select('id', 'name', 'description', 'thumbnail_image', 'image')
|
||||
->where([['is_active', '1'], ['news_articles_category_xid', '1']])
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
$item['description'] = strip_tags($item['description']);
|
||||
@@ -114,7 +114,7 @@ class RestCMSService
|
||||
->toArray();
|
||||
|
||||
$data['restaurant'] = NewsArticle::select('id', 'news_articles_category_xid','name', 'description', 'thumbnail_image', 'image')
|
||||
->where([['is_active', '0'], ['news_articles_category_xid', '2']])
|
||||
->where([['is_active', '1'], ['news_articles_category_xid', '2']])
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
$item['description'] = strip_tags($item['description']);
|
||||
@@ -162,7 +162,7 @@ class RestCMSService
|
||||
|
||||
//response data
|
||||
Log::info('Contact form data Created successfully');
|
||||
return jsonResponseWithSuccessMessageApi(__('success.save_data'), [], 201);
|
||||
return jsonResponseWithSuccessMessageApi(__('success.message_sent'), [], 201);
|
||||
} else {
|
||||
Log::error('Contact not found in addVendorContactForm.');
|
||||
return jsonResponseWithErrorMessageApi(__('auth.validation_failed'), 403);
|
||||
|
||||
@@ -41,27 +41,41 @@ class RestaurantApi_Service
|
||||
->get();
|
||||
|
||||
// $restaurantDetails = [];
|
||||
$isActive = true;
|
||||
$inactiveMessage = "";
|
||||
|
||||
foreach ($restaurantRoles as $restaurantRole) {
|
||||
$restaurant = ManageRestaurant::select('id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'phone_number', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'is_active', 'created_by', 'modified_by', 'deleted_at', 'created_at', 'updated_at')
|
||||
->where('id', $restaurantRole->restaurant_xid)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if ($restaurant) {
|
||||
$restaurant->image = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
$restaurant->description = strip_tags($restaurant->description);
|
||||
|
||||
// $restaurantDetails[] = $restaurant;
|
||||
if ($restaurant->is_active == 0) {
|
||||
$isActive = false;
|
||||
$inactiveMessage = "Your restaurant is currently not participating in Cheers to the Season. Please reach out to contact@cheerstotheseason.com to re-enroll.";
|
||||
}
|
||||
|
||||
// Add restaurant details to the array
|
||||
$restaurantDetails = $restaurant;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct response
|
||||
$response = [
|
||||
'user_detail' => $userDetail,
|
||||
'restaurant_details' => $restaurant,
|
||||
'restaurant_details' => $restaurantDetails,
|
||||
'is_active' => $isActive,
|
||||
'message' => "",
|
||||
|
||||
];
|
||||
|
||||
if (!$isActive) {
|
||||
$response['message'] = $inactiveMessage;
|
||||
}
|
||||
|
||||
// Return JSON response with success message
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.User_details_fetch'), $response, 200);
|
||||
} catch (Exception $ex) {
|
||||
@@ -74,6 +88,7 @@ class RestaurantApi_Service
|
||||
|
||||
|
||||
|
||||
|
||||
public function updateRestaurantDetail($restIamId, $request)
|
||||
{
|
||||
try {
|
||||
@@ -94,6 +109,11 @@ class RestaurantApi_Service
|
||||
DB::rollBack();
|
||||
return jsonResponseWithErrorMessageApi(__('error_message.restaurant_data_not_found'), 404);
|
||||
}
|
||||
if ($request->has('image')) {
|
||||
$image = $request->image;
|
||||
$tnormalImage = saveSingleImageWithoutCrop($image, 'restaurant_images', null);
|
||||
$restaurant->update(['image' => $tnormalImage]);
|
||||
}
|
||||
|
||||
$restaurant->update([
|
||||
'name' => $request['name'],
|
||||
@@ -105,6 +125,7 @@ class RestaurantApi_Service
|
||||
'try_on_3' => $request['try_on_3'],
|
||||
'try_on_4' => $request['try_on_4'],
|
||||
|
||||
|
||||
]);
|
||||
$restaurant->description = strip_tags($restaurant->description);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
})
|
||||
->withSchedule(function (Schedule $schedule) {
|
||||
$schedule->command('app:reinstate-restaurant')->everyMinute();
|
||||
$schedule->command('app:sent-schedule-notification')->everyMinute();
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
//
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"livewire/livewire": "^3.0",
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"maatwebsite/excel": "3.1.55",
|
||||
"phpoffice/phpspreadsheet": "1.29.0",
|
||||
"stripe/stripe-php": "^15.0",
|
||||
"tymon/jwt-auth": "^2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
1108
composer.lock
generated
1108
composer.lock
generated
File diff suppressed because it is too large
Load Diff
33
config/constants.php
Normal file
33
config/constants.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* created by : Chandan Yadav
|
||||
* Created On : 03-November-2023
|
||||
* Uses : To display message on admin panel
|
||||
*/
|
||||
return [
|
||||
'UTF8_ENABLED' => TRUE,
|
||||
'DIMENTIONS' => [
|
||||
"THUMBNAIL" => "300*160 pixels (3:2), Max Size 2MB and .jpg format image",
|
||||
],
|
||||
'SIZE' => [
|
||||
"THUMBNAIL" => "7168"
|
||||
],
|
||||
'PLATFORM' => ['ios', 'android', 'web'],
|
||||
|
||||
|
||||
|
||||
'subscription' => [
|
||||
'stripe_private_key' => env('STRIPE_KEY'),
|
||||
'stripe_secret_key' => env('STRIPE_SECRET'),
|
||||
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
|
||||
],
|
||||
|
||||
'googlePlaces'=>[
|
||||
'api_key'=>env('GOOGLE_PLACE_API_KEY')
|
||||
],
|
||||
|
||||
// 'ADMIN_EMAIL' => env('ADMIN_EMAIL', 'sayliraut@yopmail.com'),
|
||||
'ADMIN_EMAIL' => env('ADMIN_EMAIL', 'contact@cheerstotheseason.com'),
|
||||
|
||||
|
||||
];
|
||||
@@ -15,19 +15,19 @@ return new class extends Migration
|
||||
Schema::create('manage_restaurants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('short_id')->unique();
|
||||
$table->string('name',255)->nullable();
|
||||
$table->string('name', 255)->nullable();
|
||||
$table->longText('description')->nullable();
|
||||
$table->string('phone_number', 15)->nullable();
|
||||
$table->bigInteger('state_xid')->nullable();
|
||||
$table->string('restaurant_id')->nullable();
|
||||
$table->string('address',255)->nullable();
|
||||
$table->string('address', 255)->nullable();
|
||||
$table->string('image')->nullable();
|
||||
$table->string('bio')->nullable();
|
||||
$table->text('try_on_1')->nullable();
|
||||
$table->text('try_on_2')->nullable();
|
||||
$table->text('try_on_3')->nullable();
|
||||
$table->text('try_on_4')->nullable();
|
||||
$table->string('exclusion',255)->nullable();
|
||||
$table->string('exclusion', 255)->nullable();
|
||||
$table->string('latitude');
|
||||
$table->string('longtitude');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
|
||||
@@ -13,11 +13,15 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('notification_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('principal_xid');
|
||||
$table->unsignedBigInteger('principal_xid')->nullable();
|
||||
$table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
|
||||
$table->string('type');
|
||||
$table->longText('description');
|
||||
$table->string('image')->nullable();
|
||||
$table->string('user_type')->nullable();
|
||||
$table->boolean('is_schedule')->default(0)->comment('1=specific time, 0=immediate');
|
||||
$table->dateTime('delivery_schedule')->nullable();
|
||||
$table->json('state_ids')->nullable();
|
||||
$table->timestamp('date_added')->useCurrent();
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->integer('created_by')->nullable();
|
||||
|
||||
@@ -17,6 +17,7 @@ return new class extends Migration
|
||||
$table->foreign('iam_principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
|
||||
$table->unsignedBigInteger('manage_restaurants_xid');
|
||||
$table->foreign('manage_restaurants_xid')->references('id')->on('manage_restaurants')->onDelete('cascade');
|
||||
$table->bigInteger('state_xid');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->boolean('is_redeem')->default(0)->comment('1=Redeem, 0=Not Redeem');
|
||||
$table->integer('count')->default(0);
|
||||
|
||||
@@ -16,7 +16,7 @@ return new class extends Migration
|
||||
|
||||
foreach ($users as $user) {
|
||||
do {
|
||||
$referral_code = \Str::random(10);
|
||||
$referral_code = strtoupper($this->generateRandomString(10));
|
||||
} while (DB::table('iam_principal')->where('referral_code', $referral_code)->exists());
|
||||
|
||||
DB::table('iam_principal')
|
||||
@@ -25,6 +25,17 @@ return new class extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
function generateRandomString($length = 10)
|
||||
{
|
||||
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('manage_rules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->longtext('whats_inside')->nullable();
|
||||
$table->longtext('rules')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('manage_rules');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('time_intervals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('manage_state_xid');
|
||||
$table->foreign('manage_state_xid')->references('id')->on('manage_states')->onDelete('cascade');
|
||||
$table->integer('time_hours');
|
||||
$table->integer('quantity');
|
||||
$table->enum('time_interval', ['day', 'week', 'month'])->default('day');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('time_intervals');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('resaurant_time_intervals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('manage_restaurants_xid');
|
||||
$table->foreign('manage_restaurants_xid')->references('id')->on('manage_restaurants')->onDelete('cascade');
|
||||
$table->integer('time_hours');
|
||||
$table->integer('quantity');
|
||||
$table->enum('time_interval', ['day', 'week', 'month'])->default('day');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('resaurant_time_intervals');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
Schema::create('subscription_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('product_name')->nullable();
|
||||
$table->string('product_value')->nullable();
|
||||
$table->longText('product_details')->nullable();
|
||||
|
||||
$table->string('stripe_product_id')->nullable();
|
||||
$table->string('stripe_price_id')->nullable();
|
||||
|
||||
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
Schema::dropIfExists('subscription_products');
|
||||
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('subscriptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('subscription_product_xid');
|
||||
$table->unsignedBigInteger('iam_principal_xid');
|
||||
|
||||
$table->foreign('subscription_product_xid')->references('id')->on('subscription_products')->onDelete('cascade');
|
||||
$table->foreign('iam_principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
|
||||
|
||||
$table->string('amount')->nullable();
|
||||
$table->string('stripe_customer_id')->nullable();
|
||||
$table->string('payment_intent_id')->nullable();
|
||||
$table->string('payment_intent_client_secret')->nullable();
|
||||
$table->string('subscription_id')->nullable();
|
||||
$table->string('subscription_status')->nullable();
|
||||
$table->dateTime('current_period_start')->nullable();
|
||||
$table->dateTime('current_period_end')->nullable();
|
||||
$table->string('status')->nullable();
|
||||
$table->dateTime('next_payment_date')->nullable();
|
||||
$table->boolean('is_cancelled_subscription')->default(0)->comment('1=Cancelled, 0=Not Cancelled');
|
||||
$table->dateTime('cancelled_at')->nullable();
|
||||
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('subscriptions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('referral_users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('iam_principal_xid');
|
||||
$table->unsignedBigInteger('referred_user_xid');
|
||||
|
||||
$table->foreign('iam_principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
|
||||
$table->foreign('referred_user_xid')->references('id')->on('iam_principal')->onDelete('cascade');
|
||||
|
||||
$table->dateTime('referred_date_time')->nullable();
|
||||
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('referral_users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('restaurant_closed_hours', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('restaurant_id');
|
||||
$table->unsignedTinyInteger('day_of_week'); // 0 = Sunday, 1 = Monday
|
||||
$table->time('start_time');
|
||||
$table->time('end_time');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('restaurant_id')->references('id')->on('manage_restaurants')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('restaurant_closed_hours');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('manage_referral_rules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->longtext('how_it_works')->nullable();
|
||||
$table->longtext('rules')->nullable();
|
||||
$table->longtext('what_is_referral')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('manage_referral_rules');
|
||||
}
|
||||
};
|
||||
1
error_log
Normal file
1
error_log
Normal file
@@ -0,0 +1 @@
|
||||
[16-Jul-2024 11:48:12 UTC] PHP Deprecated: Optional parameter $message declared before required parameter $appId is implicitly treated as a required parameter in /home/cheers/public_html/vendor/ladumor/one-signal/src/OneSignalManager.php on line 44
|
||||
@@ -1,5 +1,9 @@
|
||||
/*# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlcyI6WyJjdXN0b20uc2NzcyJdLCJzb3VyY2VzQ29udGVudCI6WyIiXSwiZmlsZSI6ImN1c3RvbS5jc3MifQ== */
|
||||
|
||||
.arrow-icon-spacing {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.notification-scroll h2 {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
@@ -1177,6 +1181,23 @@ div#zero-config_filter {
|
||||
font-weight: 700;
|
||||
gap: 3px;
|
||||
}
|
||||
.download-btn-cancel {
|
||||
cursor: pointer;
|
||||
color: #000;
|
||||
padding: 10px;
|
||||
background: #fb2020;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
gap: 3px;
|
||||
}
|
||||
.download-btn-cancel:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.download-btn-custom img {
|
||||
width: 17px;
|
||||
@@ -1373,7 +1394,7 @@ label {
|
||||
/* to change error class color */
|
||||
label#email-error ,label#password-error {
|
||||
color: red;
|
||||
}
|
||||
font-weight: 600;}
|
||||
|
||||
|
||||
.error-message {
|
||||
@@ -1560,3 +1581,48 @@ a.download-btn.reply-button:hover {
|
||||
width: fit-content !important;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
/*
|
||||
.random_cl li {
|
||||
list-style: circle !important;
|
||||
} */
|
||||
.random_cl li a {
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10.2px 16px 10.2px 24px;
|
||||
margin-left: 34px;
|
||||
font-size: 15px;
|
||||
color: #000;
|
||||
}
|
||||
.random_cl li a:before {
|
||||
content: "";
|
||||
background-color: #000;
|
||||
position: absolute;
|
||||
height: 7px;
|
||||
width: 7px;
|
||||
top: 15px;
|
||||
left: 5px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.random_cl li a:hover {
|
||||
color: #fff;
|
||||
background: #05244d;
|
||||
}
|
||||
|
||||
.sidebar-links {
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.radio-btn input {
|
||||
width: fit-content;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.radio-btn {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.radio-btn label.label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Login js
|
||||
$(document).on("click", "#admin_login_btn", function (e) {
|
||||
$("#admin_login_form").validate({
|
||||
$(document).on("click", "#admin_login_btn", function(e) {
|
||||
$('#admin_login_form').validate({
|
||||
rules: {
|
||||
email: {
|
||||
required: true,
|
||||
},
|
||||
password: {
|
||||
required: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
email: {
|
||||
@@ -15,150 +15,153 @@ $(document).on("click", "#admin_login_btn", function (e) {
|
||||
},
|
||||
password: {
|
||||
required: "Please enter the password.",
|
||||
},
|
||||
}
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
submitHandler: function(form) {
|
||||
e.preventDefault();
|
||||
let base_url = url_path;
|
||||
var formData = new FormData(form);
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
|
||||
"content"
|
||||
),
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + "/check_login",
|
||||
type: "POST",
|
||||
url: base_url + '/check_login',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
beforeSend: function () {
|
||||
$("#admin_login_btn").text("Please wait...");
|
||||
$("#admin_login_btn").attr("disabled", true);
|
||||
beforeSend: function() {
|
||||
$('#admin_login_btn').text('Please wait...');
|
||||
$('#admin_login_btn').attr('disabled', true);
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
if (response.status == 200) {
|
||||
$("#admin_login_btn").prop("disabled", false);
|
||||
$("#admin_login_btn").text("Login");
|
||||
window.location.href = base_url + "/dashboard";
|
||||
}
|
||||
if (response.status == 401) {
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$('#admin_login_btn').prop('disabled', false);
|
||||
$('#admin_login_btn').text('Login');
|
||||
|
||||
if (response.status_code == 200) {
|
||||
toastr.success(response.message);
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/dashboard";
|
||||
}, 2000);
|
||||
} else if (response.status_code == 401) {
|
||||
toastr.error(response.message);
|
||||
form.reset();
|
||||
$("#admin_login_btn").prop("disabled", false);
|
||||
$("#admin_login_btn").text("Sign In");
|
||||
} else {
|
||||
toastr.error(response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error('An unexpected error occurred.');
|
||||
$('#admin_login_btn').prop('disabled', false);
|
||||
$('#admin_login_btn').text('Sign In');
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// forgot password js
|
||||
$(document).on("click", "#forgot_password_btn", function (e) {
|
||||
let base_url = url_path;
|
||||
$("#forgot_pass_form").validate({
|
||||
$('#forgot_pass_form').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
email: {
|
||||
required: true,
|
||||
},
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
email: {
|
||||
required: "Please Enter email",
|
||||
},
|
||||
required: "Please Enter email"
|
||||
}
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
var formData = new FormData(form);
|
||||
e.preventDefault(),
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
|
||||
"content"
|
||||
),
|
||||
},
|
||||
});
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + "/send_otp",
|
||||
type: "POST",
|
||||
url: base_url + '/send_otp',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
if (response.status == 200) {
|
||||
if (response.status_code == 200) {
|
||||
form.reset();
|
||||
toastr.success("Otp send it your mail id please check");
|
||||
setTimeout(function () {
|
||||
// toastr.info('Please check your email to reset your password. The link is valid for 5 minutes.');
|
||||
toastr.success('An OTP has been sent to your email address');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/otp";
|
||||
}, 1000);
|
||||
} else if (response.status == 404) {
|
||||
toastr.error("This email id is not exits");
|
||||
} else {
|
||||
toastr.error("Something went wrong");
|
||||
}, 2000);
|
||||
}else if (response.status == 404) {
|
||||
toastr.error('This email id is not exits');
|
||||
}
|
||||
else {
|
||||
toastr.error(response.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// otp varification
|
||||
$(document).on("click", "#otp_verify_button", function (e) {
|
||||
$(document).on('click', '#otp_verify_button', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Get base URL
|
||||
let base_url = url_path;
|
||||
|
||||
// Get admin ID
|
||||
var id = $("#admin_otp_id").val();
|
||||
var id = $('#admin_otp_id').val();
|
||||
|
||||
// Get OTP by concatenating values of all OTP input fields
|
||||
var otp = $(".otp")
|
||||
.map(function () {
|
||||
return this.value;
|
||||
})
|
||||
.get()
|
||||
.join("");
|
||||
var otp = $('.otp').map(function() {
|
||||
return this.value;
|
||||
}).get().join('');
|
||||
|
||||
if (otp === '') {
|
||||
toastr.error('Please enter OTP');
|
||||
return;
|
||||
}
|
||||
// Send AJAX request for OTP verification
|
||||
$.ajax({
|
||||
url: base_url + "/otp_verify",
|
||||
type: "POST",
|
||||
url: base_url + '/otp_verify',
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id,
|
||||
otp: otp,
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
'_token': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.status == 200) {
|
||||
if (response.status_code == 200) {
|
||||
// Display success message
|
||||
toastr.success("Otp Verify Successfully");
|
||||
toastr.success('Otp Verify Successfully');
|
||||
// Redirect to the dashboard after a delay
|
||||
setTimeout(function () {
|
||||
window.location.href = base_url + "/password_reset";
|
||||
}, 1000);
|
||||
} else if (response.status == 401) {
|
||||
// Display error message for invalid OTP or expired
|
||||
toastr.error(response.message);
|
||||
} else {
|
||||
// Display error message for other issues
|
||||
toastr.error("Something went wrong");
|
||||
toastr.error(response.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("input", ".otp", function () {
|
||||
this.value = this.value.replace(/[^0-9]/g, "");
|
||||
$(document).on('input', '.otp', function() {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
|
||||
if (this.value.length >= this.maxLength) {
|
||||
$(this).next(".otp").focus();
|
||||
$(this).next('.otp').focus();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -224,15 +227,44 @@ $(document).on("click", "#password_reset", function (e) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#passwordToggle").click(function () {
|
||||
var passwordInput = $("#password");
|
||||
var eyeIcon = $("#passwordToggle");
|
||||
$('#passwordToggle').click(function() {
|
||||
var passwordInput = $('#password');
|
||||
var eyeIcon = $('#passwordToggle');
|
||||
|
||||
if (passwordInput.attr("type") === "password") {
|
||||
passwordInput.attr("type", "text");
|
||||
eyeIcon.removeClass("fa-eye-slash").addClass("fa-eye");
|
||||
if (passwordInput.attr('type') === 'password') {
|
||||
passwordInput.attr('type', 'text');
|
||||
eyeIcon.removeClass('fa-eye-slash').addClass('fa-eye');
|
||||
} else {
|
||||
passwordInput.attr("type", "password");
|
||||
eyeIcon.removeClass("fa-eye").addClass("fa-eye-slash");
|
||||
passwordInput.attr('type', 'password');
|
||||
eyeIcon.removeClass('fa-eye').addClass('fa-eye-slash');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.getElementById('togglePassword').addEventListener('click', function() {
|
||||
var passwordField = document.getElementById('password');
|
||||
var icon = document.getElementById('togglePassword');
|
||||
if (passwordField.type === 'password') {
|
||||
passwordField.type = 'text';
|
||||
icon.classList.remove('fa-eye-slash');
|
||||
icon.classList.add('fa-eye');
|
||||
} else {
|
||||
passwordField.type = 'password';
|
||||
icon.classList.remove('fa-eye');
|
||||
icon.classList.add('fa-eye-slash');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('toggleConfirmPassword').addEventListener('click', function() {
|
||||
var confirmPasswordField = document.getElementById('confirm_password');
|
||||
var icon = document.getElementById('toggleConfirmPassword');
|
||||
if (confirmPasswordField.type === 'password') {
|
||||
confirmPasswordField.type = 'text';
|
||||
icon.classList.remove('fa-eye-slash');
|
||||
icon.classList.add('fa-eye');
|
||||
} else {
|
||||
confirmPasswordField.type = 'password';
|
||||
icon.classList.remove('fa-eye');
|
||||
icon.classList.add('fa-eye-slash');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
$('#zero-config').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
$('#zero-config2').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$.validator.addMethod("lettersOnly", function(value, element) {
|
||||
return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
|
||||
}, "Please enter only alphabets");
|
||||
|
||||
$.validator.addMethod("numbersOnly", function(value, element) {
|
||||
return this.optional(element) || /^[0-9]+$/.test(value);
|
||||
}, "Please enter only numbers");
|
||||
|
||||
$('#create_custom_referral_code').validate({
|
||||
rules: {
|
||||
referral_code: {
|
||||
required: true,
|
||||
},
|
||||
|
||||
},
|
||||
messages: {
|
||||
referral_code: {
|
||||
required: "Please enter Referral Code.",
|
||||
},
|
||||
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function(form) {
|
||||
let b_url = url_path;
|
||||
$("#create_custom_code").html("Please Wait...");
|
||||
$("#create_custom_code").prop("disabled", true);
|
||||
let base_url = url_path;
|
||||
|
||||
var formData = new FormData(form);
|
||||
$.ajax({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
|
||||
"content"),
|
||||
},
|
||||
type: "post",
|
||||
url: base_url + '/create-update-referral-code',
|
||||
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(result) {
|
||||
|
||||
console.log("result", result);
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Referral code submitted successfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = b_url +
|
||||
"/dashboard";
|
||||
}, 2000);
|
||||
} else if (result.status_code == 500) {
|
||||
toastr.error(result.message);
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
$('#create_custom_code').attr('disabled', false);
|
||||
$('#create_custom_code').text('Submit');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(function(e) {
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#download-selected", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var allIds = [];
|
||||
|
||||
// Iterate over each page of the DataTable
|
||||
var table = $('#zero-config').DataTable();
|
||||
for (var i = 0; i < table.page.info().pages; i++) {
|
||||
table.page(i).draw(false); // Switch to page i
|
||||
$('#zero-config tbody input:checked').each(function() {
|
||||
allIds.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if (allIds.length > 0) {
|
||||
// If there are selected customers
|
||||
$('#ids').prop('disabled', false);
|
||||
$('#all_id').prop('disabled', true);
|
||||
$('#ids').val(allIds);
|
||||
// Now submit the form or perform download action
|
||||
$('#customer-form').submit(); // Or perform your download action here
|
||||
} else {
|
||||
// No customers selected
|
||||
toastr.error("Please select at least one customer to download.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on("click", "#download_all", function(e) {
|
||||
$('#all_id').prop('disabled', false);
|
||||
$('#ids').prop('disabled', true);
|
||||
})
|
||||
});
|
||||
|
||||
$(document).on("click", ".more", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// $('<button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online"><h3>Export</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a></div><div class="dropdown-item"><a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a></div></div></li></ul></button>')
|
||||
// .insertBefore("#zero-config_filter label");
|
||||
$('<button>' +
|
||||
'<ul class="navbar-item flex-row ms-lg-auto ms-0">' +
|
||||
'<li class="nav-item dropdown action-dropdown order-lg-0 order-1">' +
|
||||
'<a href="javascript:void(0);" class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
|
||||
'<div class="avatar-container">' +
|
||||
'<div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online">' +
|
||||
'<h3>Export</h3>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</a>' +
|
||||
'<div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown">' +
|
||||
'<div class="dropdown-item">' +
|
||||
'<a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a>' +
|
||||
'</div>' +
|
||||
'<div class="dropdown-item">' +
|
||||
'<a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</li>' +
|
||||
'</ul>' +
|
||||
'</button>').insertBefore("#zero-config_filter label");
|
||||
|
||||
|
||||
$("#zero-config").on("click", ".sub_admin_permission", function() {
|
||||
var Name = $(this).data('name');
|
||||
var Price = $(this).data('price');
|
||||
var SubID = $(this).data('subscription-id');
|
||||
var CustID = $(this).data('customer-id');
|
||||
var SubStatus = $(this).data('subscription-status');
|
||||
var startDate = $(this).data('start-date');
|
||||
var endDate = $(this).data('end-date');
|
||||
var nextDate = $(this).data('next-date');
|
||||
var formattedPrice = '$' + Price;
|
||||
|
||||
$('.subadmin-option span').eq(0).text(Name);
|
||||
$('.subadmin-option span').eq(1).text(formattedPrice);
|
||||
$('.subadmin-option span').eq(2).text(SubID);
|
||||
$('.subadmin-option span').eq(3).text(CustID);
|
||||
$('.subadmin-option span').eq(4).text(SubStatus);
|
||||
$('.subadmin-option span').eq(5).text(startDate);
|
||||
$('.subadmin-option span').eq(6).text(endDate);
|
||||
$('.subadmin-option span').eq(7).text(nextDate); // Corrected index for next-date
|
||||
});
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const viewButtons = document.querySelectorAll('.btn-view-details');
|
||||
|
||||
viewButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const row = this.closest('tr');
|
||||
const user = JSON.parse(row.dataset.user);
|
||||
const referredUsers = JSON.parse(row.dataset.referredUsers);
|
||||
|
||||
// Populate the modal fields
|
||||
document.querySelector(
|
||||
'#referral-user-details-modal .referral-user-inn-div:nth-child(1) span')
|
||||
.innerText = `${user.first_name} ${user.last_name}`;
|
||||
document.querySelector(
|
||||
'#referral-user-details-modal .referral-user-inn-div:nth-child(2) span')
|
||||
.innerText = user.email_address;
|
||||
// document.querySelector(
|
||||
// '#referral-user-details-modal .referral-user-inn-div:nth-child(3) span')
|
||||
// .innerText = user.referral_code;
|
||||
|
||||
// Clear previous referred users
|
||||
const referredUsersDiv = document.querySelector(
|
||||
'#referral-user-details-modal .referral-user-inn-div.referred-users');
|
||||
referredUsersDiv.innerHTML = '';
|
||||
|
||||
referredUsers.forEach(referredUser => {
|
||||
const p = document.createElement('p');
|
||||
p.innerText =
|
||||
`${referredUser.first_name} ${referredUser.last_name} (${referredUser.email_address}) (${referredUser.id})`;
|
||||
referredUsersDiv.appendChild(p);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user