df commited on
Commit
40dca3b
·
1 Parent(s): 99fcd1f

test-laravel

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .env +44 -0
  2. .env.example +44 -0
  3. .gitattributes +2 -0
  4. Dockerfile +28 -14
  5. app/Console/Commands/GenSiteMap.php +35 -0
  6. app/Console/Kernel.php +35 -0
  7. app/Console/customCmd.php +18 -0
  8. app/Exceptions/Handler.php +60 -0
  9. app/Helpers/CommonHelper.php +86 -0
  10. app/Http/Controllers/AjaxControllers/V1/Backend/ChapterController.php +128 -0
  11. app/Http/Controllers/AjaxControllers/V1/Backend/HashtagController.php +42 -0
  12. app/Http/Controllers/AjaxControllers/V1/Frontend/ChapterController.php +31 -0
  13. app/Http/Controllers/Auth/ForgotPasswordController.php +32 -0
  14. app/Http/Controllers/Auth/LoginController.php +81 -0
  15. app/Http/Controllers/Auth/LogoutController.php +13 -0
  16. app/Http/Controllers/Auth/RegisterController.php +89 -0
  17. app/Http/Controllers/Auth/ResetPasswordController.php +39 -0
  18. app/Http/Controllers/BaseController.php +51 -0
  19. app/Http/Controllers/WebControllers/V1/Backend/ArtistController.php +11 -0
  20. app/Http/Controllers/WebControllers/V1/Backend/AuthorController.php +11 -0
  21. app/Http/Controllers/WebControllers/V1/Backend/ChapterController.php +27 -0
  22. app/Http/Controllers/WebControllers/V1/Backend/ComicController.php +154 -0
  23. app/Http/Controllers/WebControllers/V1/Backend/ContentImageController.php +11 -0
  24. app/Http/Controllers/WebControllers/V1/Backend/GenreController.php +20 -0
  25. app/Http/Controllers/WebControllers/V1/Backend/HashtagController.php +115 -0
  26. app/Http/Controllers/WebControllers/V1/Backend/LandingController.php +25 -0
  27. app/Http/Controllers/WebControllers/V1/Backend/LikeController.php +11 -0
  28. app/Http/Controllers/WebControllers/V1/Backend/PublisherController.php +11 -0
  29. app/Http/Controllers/WebControllers/V1/Backend/SummaryContentController.php +11 -0
  30. app/Http/Controllers/WebControllers/V1/Backend/TaggedController.php +11 -0
  31. app/Http/Controllers/WebControllers/V1/Backend/UserController.php +11 -0
  32. app/Http/Controllers/WebControllers/V1/Backend/ViewController.php +11 -0
  33. app/Http/Controllers/WebControllers/V1/Frontend/ChapterController.php +46 -0
  34. app/Http/Controllers/WebControllers/V1/Frontend/ComicController.php +44 -0
  35. app/Http/Controllers/WebControllers/V1/Frontend/LandingController.php +33 -0
  36. app/Http/Controllers/WebControllers/V1/Frontend/UserController.php +11 -0
  37. app/Http/Kernel.php +73 -0
  38. app/Http/Middleware/Authenticate.php +17 -0
  39. app/Http/Middleware/ConvertIdMiddleware.php +24 -0
  40. app/Http/Middleware/EncryptCookies.php +17 -0
  41. app/Http/Middleware/GzipMiddleware.php +29 -0
  42. app/Http/Middleware/PreventRequestsDuringMaintenance.php +17 -0
  43. app/Http/Middleware/RedirectIfAuthenticated.php +30 -0
  44. app/Http/Middleware/TrafficMiddleware.php +28 -0
  45. app/Http/Middleware/TrimStrings.php +19 -0
  46. app/Http/Middleware/TrustHosts.php +20 -0
  47. app/Http/Middleware/TrustProxies.php +28 -0
  48. app/Http/Middleware/ValidateSignature.php +22 -0
  49. app/Http/Middleware/VerifyCsrfToken.php +17 -0
  50. app/Http/Requests/ApiChapterRequest.php +71 -0
.env ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ APP_NAME=Laravel
2
+ APP_ENV=local
3
+ APP_KEY= base64:qKieeboLsDmpW8qISpXunQoiPW2iyBr5/whnGIstu1A=
4
+ APP_DEBUG=true
5
+ APP_URL=https://localhost
6
+
7
+ LOG_CHANNEL=stack
8
+
9
+ DB_CONNECTION=pgsql
10
+ DB_HOST=localhost
11
+ DB_PORT=5432
12
+ DB_DATABASE=your_database_name
13
+ DB_USERNAME=homestead
14
+ DB_PASSWORD=secret
15
+
16
+ BROADCAST_DRIVER=log
17
+ CACHE_DRIVER=file
18
+ QUEUE_CONNECTION=sync
19
+ SESSION_DRIVER=file
20
+ SESSION_LIFETIME=120
21
+
22
+ REDIS_HOST=127.0.0.1
23
+ REDIS_PASSWORD=null
24
+ REDIS_PORT=6379
25
+
26
+ MAIL_DRIVER=smtp
27
+ MAIL_HOST=smtp.mailtrap.io
28
+ MAIL_PORT=2525
29
+ MAIL_USERNAME=null
30
+ MAIL_PASSWORD=null
31
+ MAIL_ENCRYPTION=null
32
+
33
+ AWS_ACCESS_KEY_ID=
34
+ AWS_SECRET_ACCESS_KEY=
35
+ AWS_DEFAULT_REGION=us-east-1
36
+ AWS_BUCKET=
37
+
38
+ PUSHER_APP_ID=
39
+ PUSHER_APP_KEY=
40
+ PUSHER_APP_SECRET=
41
+ PUSHER_APP_CLUSTER=mt1
42
+
43
+ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
44
+ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
.env.example ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ APP_NAME=Laravel
2
+ APP_ENV=local
3
+ APP_KEY=
4
+ APP_DEBUG=true
5
+ APP_URL=http://localhost
6
+
7
+ LOG_CHANNEL=stack
8
+
9
+ DB_CONNECTION=pgsql
10
+ DB_HOST=localhost
11
+ DB_PORT=5432
12
+ DB_DATABASE=your_database_name
13
+ DB_USERNAME=homestead
14
+ DB_PASSWORD=secret
15
+
16
+ BROADCAST_DRIVER=log
17
+ CACHE_DRIVER=file
18
+ QUEUE_CONNECTION=sync
19
+ SESSION_DRIVER=file
20
+ SESSION_LIFETIME=120
21
+
22
+ REDIS_HOST=127.0.0.1
23
+ REDIS_PASSWORD=null
24
+ REDIS_PORT=6379
25
+
26
+ MAIL_DRIVER=smtp
27
+ MAIL_HOST=smtp.mailtrap.io
28
+ MAIL_PORT=2525
29
+ MAIL_USERNAME=null
30
+ MAIL_PASSWORD=null
31
+ MAIL_ENCRYPTION=null
32
+
33
+ AWS_ACCESS_KEY_ID=
34
+ AWS_SECRET_ACCESS_KEY=
35
+ AWS_DEFAULT_REGION=us-east-1
36
+ AWS_BUCKET=
37
+
38
+ PUSHER_APP_ID=
39
+ PUSHER_APP_KEY=
40
+ PUSHER_APP_SECRET=
41
+ PUSHER_APP_CLUSTER=mt1
42
+
43
+ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
44
+ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
37
+ *.png filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -54,14 +54,14 @@ RUN apt-get install -y nginx && \
54
  rm -rf /var/lib/apt/lists/*
55
 
56
  RUN mkdir -p /run/php && \
57
- mkdir -p /var/www/html/ && \
58
  mkdir -p /etc/nginx/sites-available/ && \
59
  chmod -R 777 /var/www/html && \
60
  chmod -R 777 /run/php && \
61
  chown -R ubuntu:ubuntu /run/php && \
62
- chown -R ubuntu:ubuntu /var/www
 
63
 
64
-
65
  RUN chmod -R 777 /var/lib
66
 
67
 
@@ -93,6 +93,8 @@ RUN mv composer.phar /usr/local/bin/composer
93
  #RUN cp -r /node-v20.17.0-linux-x64/bin /node-v20.17.0-linux-x64/include /node-v20.17.0-linux-x64/lib /node-v20.17.0-linux-x64/share /usr/
94
 
95
 
 
 
96
  ENV GOSU_VERSION 1.17
97
  RUN set -eux; \
98
  savedAptMark="$(apt-mark showmanual)"; \
@@ -163,23 +165,35 @@ ENV MYSQL_DATABASE=firecomic_db
163
  RUN echo "mysql-server mysql-server/root_password password sa" | debconf-set-selections && \
164
  echo "mysql-server mysql-server/root_password_again password sa" | debconf-set-selections
165
 
 
 
 
 
 
 
166
 
167
- RUN composer create-project laravel/laravel example-app
168
- RUN cd example-app
169
- WORKDIR /example-app
170
- # Verificar que archivos necesitan acceso de escritura o carpetas
171
- RUN ls -la
172
- RUN chmod 706 -R /example-app/bootstrap/cache
173
- RUN chmod 760 -R /example-app/storage
174
- RUN chmod 706 /example-app/database/database.sqlite
175
- RUN chown -R ubuntu:ubuntu /example-app
 
 
 
 
 
 
 
 
176
  #RUN apt-get install -y mariadb-server sudo
177
  #RUN usermod -aG sudo ubuntu
178
  #USER root:root
179
  #RUN sudo service mariadb start; service --status-all
180
 
181
- ADD public /public
182
-
183
  ADD start.sh /start.sh
184
 
185
  RUN mkdir /docker-entrypoint-initdb.d
 
54
  rm -rf /var/lib/apt/lists/*
55
 
56
  RUN mkdir -p /run/php && \
57
+ mkdir -p /var/www/html && \
58
  mkdir -p /etc/nginx/sites-available/ && \
59
  chmod -R 777 /var/www/html && \
60
  chmod -R 777 /run/php && \
61
  chown -R ubuntu:ubuntu /run/php && \
62
+ chown -R ubuntu:ubuntu /var/www/html
63
+
64
 
 
65
  RUN chmod -R 777 /var/lib
66
 
67
 
 
93
  #RUN cp -r /node-v20.17.0-linux-x64/bin /node-v20.17.0-linux-x64/include /node-v20.17.0-linux-x64/lib /node-v20.17.0-linux-x64/share /usr/
94
 
95
 
96
+ #---------------------
97
+
98
  ENV GOSU_VERSION 1.17
99
  RUN set -eux; \
100
  savedAptMark="$(apt-mark showmanual)"; \
 
165
  RUN echo "mysql-server mysql-server/root_password password sa" | debconf-set-selections && \
166
  echo "mysql-server mysql-server/root_password_again password sa" | debconf-set-selections
167
 
168
+ #---------------------
169
+
170
+ ENV APP_ENV production
171
+ ENV APP_DEBUG false
172
+ ENV LOG_CHANNEL stderr
173
+ ENV APP_KEY base64:qKieeboLsDmpW8qISpXunQoiPW2iyBr5/whnGIstu1A=
174
 
175
+ RUN mkdir -p /var/firecomic
176
+
177
+ USER ubuntu
178
+ COPY . /var/firecomic/
179
+
180
+ USER root
181
+ RUN chmod -R 777 /var/firecomic && \
182
+ chown -R ubuntu:ubuntu /var/firecomic
183
+
184
+ #RUN composer create-project laravel/laravel example-app
185
+ #RUN cd example-app
186
+ #WORKDIR /example-app
187
+ #RUN ls -la
188
+ #RUN chmod 706 -R /example-app/bootstrap/cache
189
+ #RUN chmod 760 -R /example-app/storage
190
+ #RUN chmod 706 /example-app/database/database.sqlite
191
+ #RUN chown -R ubuntu:ubuntu /example-app
192
  #RUN apt-get install -y mariadb-server sudo
193
  #RUN usermod -aG sudo ubuntu
194
  #USER root:root
195
  #RUN sudo service mariadb start; service --status-all
196
 
 
 
197
  ADD start.sh /start.sh
198
 
199
  RUN mkdir /docker-entrypoint-initdb.d
app/Console/Commands/GenSiteMap.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Console\Commands;
4
+
5
+ use Illuminate\Console\Command;
6
+ use Spatie\Sitemap\SitemapGenerator;
7
+
8
+ class GenSiteMap extends Command
9
+ {
10
+ /**
11
+ * The console command name.
12
+ *
13
+ * @var string
14
+ */
15
+ protected $signature = 'sitemap:generate';
16
+
17
+ /**
18
+ * The console command description.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $description = 'Generate the sitemap.';
23
+
24
+ /**
25
+ * Execute the console command.
26
+ *
27
+ * @return mixed
28
+ */
29
+ public function handle()
30
+ {
31
+ // modify this to your own needs
32
+ SitemapGenerator::create(config('app.url'))
33
+ ->writeToFile(public_path('sitemap.xml'));
34
+ }
35
+ }
app/Console/Kernel.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Console;
4
+
5
+ use Illuminate\Console\Scheduling\Schedule;
6
+ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7
+ use App\Console\customCmd;
8
+
9
+ class Kernel extends ConsoleKernel
10
+ {
11
+
12
+ protected $commands = [
13
+
14
+ \App\Console\Commands\GenSiteMap::class,
15
+
16
+ ];
17
+
18
+ /**
19
+ * Define the application's command schedule.
20
+ */
21
+ protected function schedule(Schedule $schedule): void
22
+ {
23
+ // $schedule->command('inspire')->hourly();
24
+ }
25
+
26
+ /**
27
+ * Register the commands for the application.
28
+ */
29
+ protected function commands(): void
30
+ {
31
+ $this->load(__DIR__.'/Commands');
32
+
33
+ require base_path('routes/console.php');
34
+ }
35
+ }
app/Console/customCmd.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Console;
4
+
5
+ use Illuminate\Foundation\Console\ServeCommand;
6
+
7
+ class customCmd extends ServeCommand
8
+ {
9
+ /**
10
+ * Execute the console command.
11
+ *
12
+ * @return void
13
+ */
14
+ public function handle()
15
+ {
16
+ // Do not output anything here
17
+ }
18
+ }
app/Exceptions/Handler.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Exceptions;
4
+
5
+ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6
+ use Illuminate\Session\TokenMismatchException;
7
+ use Illuminate\Support\Facades\Auth;
8
+ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
+ use Throwable;
10
+
11
+ class Handler extends ExceptionHandler
12
+ {
13
+ /**
14
+ * A list of exception types with their corresponding custom log levels.
15
+ *
16
+ * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
17
+ */
18
+ protected $levels = [
19
+ //
20
+ ];
21
+
22
+ /**
23
+ * A list of the exception types that are not reported.
24
+ *
25
+ * @var array<int, class-string<\Throwable>>
26
+ */
27
+ protected $dontReport = [
28
+ //
29
+ ];
30
+
31
+ /**
32
+ * A list of the inputs that are never flashed to the session on validation exceptions.
33
+ *
34
+ * @var array<int, string>
35
+ */
36
+ protected $dontFlash = [
37
+ 'current_password',
38
+ 'password',
39
+ 'password_confirmation',
40
+ ];
41
+
42
+ /**
43
+ * Register the exception handling callbacks for the application.
44
+ */
45
+ public function register(): void
46
+ {
47
+ $this->reportable(function (Throwable $e) {
48
+ //
49
+ });
50
+ }
51
+
52
+ public function render($request, Throwable $exception)
53
+ {
54
+ if ((env('APP_ENV') == 'production') && !str_contains($request->fullUrl(), '/admin')) {
55
+ return redirect()->route('landingPage');
56
+ }
57
+
58
+ return parent::render($request, $exception);
59
+ }
60
+ }
app/Helpers/CommonHelper.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use Illuminate\Support\Facades\Validator;
4
+ use Carbon\Carbon;
5
+ use Illuminate\Support\MessageBag;
6
+ use Illuminate\Support\Collection;
7
+
8
+ function getInformationDataTable($pagination)
9
+ {
10
+ return trans('project.data_table.information', [
11
+ 'first_item' => $pagination->firstItem(),
12
+ 'last_item' => $pagination->lastItem(),
13
+ 'total' => $pagination->total()
14
+ ]);
15
+
16
+ }
17
+
18
+ function getArray($modal)
19
+ {
20
+ if ($modal instanceof Collection) {
21
+ $arrays = [];
22
+ $modal->each(function ($item) use (&$arrays) {
23
+ $arrays[] = $item->id;
24
+ });
25
+ return $arrays;
26
+ }
27
+ return null;
28
+ }
29
+
30
+
31
+ function getLinkSpinImg()
32
+ {
33
+ return asset('assets/images/loadspinner.svg');
34
+ }
35
+
36
+ function getPaginationArrays($paginator)
37
+ {
38
+ $currentPage = $paginator->currentPage();
39
+ $lastPage = $paginator->lastPage();
40
+ $min = 0;
41
+ $max = $lastPage + 1;
42
+ $tmp_min = $currentPage - 2;
43
+ $tmp_max = $currentPage + 2;
44
+ // next
45
+ if ($currentPage - 1 <= $min) {
46
+ $tmp_max++;
47
+ }
48
+ if ($currentPage - 2 <= $min) {
49
+ $tmp_max++;
50
+ }
51
+
52
+ if ($currentPage + 1 >= $max) {
53
+ $tmp_min--;
54
+ }
55
+ if ($currentPage + 2 >= $max) {
56
+ $tmp_min--;
57
+ }
58
+ $tmp_min = $tmp_min <= $min ? 1 : $tmp_min;
59
+ $tmp_max = $tmp_max > $lastPage ? $lastPage : $tmp_max;
60
+ return [$tmp_min, $tmp_max];
61
+ }
62
+
63
+ function convertComicIdtoString($comicId)
64
+ {
65
+ return convertString($comicId, config('settings.arrray_keys_convert_id'));
66
+ }
67
+
68
+ function convertString($input, $keyArray)
69
+ {
70
+ $output = '';
71
+ foreach (str_split($input) as $char) {
72
+ $position = array_search($char, $keyArray);
73
+ $output .= $position;
74
+ }
75
+ return $output;
76
+ }
77
+
78
+ function reverseConvert($input, $keyArray)
79
+ {
80
+ $output = '';
81
+ foreach (str_split($input) as $num) {
82
+ $char = $keyArray[$num];
83
+ $output .= $char;
84
+ }
85
+ return $output;
86
+ }
app/Http/Controllers/AjaxControllers/V1/Backend/ChapterController.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\AjaxControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Http\Requests\ApiChapterRequest;
7
+ use App\Services\ChapterServices;
8
+ use App\Services\ComicServices;
9
+ use App\Tranformers\ChapterResource\ChapterDetailResource;
10
+ use App\Tranformers\ChapterResource\ChapterListResource;
11
+ use Illuminate\Http\Request;
12
+ use Illuminate\Support\Facades\DB;
13
+
14
+ class ChapterController extends BaseController
15
+ {
16
+ private $chapterServices;
17
+ private $comicServices;
18
+ public function __construct(ChapterServices $chapterServices,ComicServices $comicServices)
19
+ {
20
+ $this->comicServices = $comicServices;
21
+ $this->chapterServices = $chapterServices;
22
+ parent::__construct();
23
+ }
24
+
25
+ /**
26
+ * Display a listing of the resource.
27
+ */
28
+ public function index(Request $request)
29
+ {
30
+ $comic = $this->chapterServices->index($request);
31
+ return (new ChapterListResource($comic))->additional([
32
+ 'total' => $comic->total(),
33
+ 'lastPage' => $comic->lastPage(),
34
+ 'currentPage' => $comic->currentPage(),
35
+ 'perPage' => (int)$comic->perPage(),
36
+ ]);
37
+ }
38
+
39
+ /**
40
+ * Show the form for creating a new resource.
41
+ */
42
+ public function create()
43
+ {
44
+ }
45
+
46
+ /**
47
+ * Store a newly created resource in storage.
48
+ */
49
+ public function store(ApiChapterRequest $request)
50
+ {
51
+ $comic = $request->only([
52
+ 'publish_at',
53
+ 'free_at',
54
+ 'status',
55
+ 'chapter_number',
56
+ 'next_chapter_id',
57
+ 'prv_chapter_id',
58
+ 'comic_id',
59
+ 'chapter_name',
60
+ ]);
61
+
62
+ try{
63
+ $this->chapterServices->uploadGGDrive($request,$comic);
64
+ }catch(\Exception $e){
65
+ return $this->responseJson( trans('chapter.msg_content.msg_edit_fail'),500,$e->getMessage());
66
+ }
67
+
68
+ return $this->chapterServices->save($request,$comic);
69
+ }
70
+
71
+
72
+ /**
73
+ * Display the specified resource.
74
+ */
75
+ public function show(string $id)
76
+ {
77
+ return $this->responseJson('ok',200);
78
+ }
79
+
80
+ /**
81
+ * Show the form for editing the specified resource.
82
+ */
83
+ public function edit(Request $request,string $comic_code,string $id)
84
+ {
85
+ $chapters = $this->chapterServices->show($id);
86
+ return new ChapterDetailResource($chapters);
87
+ }
88
+
89
+ /**
90
+ * Update the specified resource in storage.
91
+ */
92
+ public function update(Request $request,string $comic_code, string $id)
93
+ {
94
+ $comic = $request->only([
95
+ 'publish_at',
96
+ 'free_at',
97
+ 'status',
98
+ 'chapter_number',
99
+ 'next_chapter_id',
100
+ 'prv_chapter_id',
101
+ 'comic_id',
102
+ 'chapter_name',
103
+ 'content_images_id',
104
+ 'id'
105
+ ]);
106
+ $comic['comic_code'] = $comic_code;
107
+
108
+ try{
109
+ $this->chapterServices->uploadGGDrive($request,$comic);
110
+ }catch(\Exception $e){
111
+ return $this->responseJson( trans('chapter.msg_content.msg_edit_fail'),500,$e->getMessage());
112
+ }
113
+
114
+ return $this->chapterServices->save($request,$comic);
115
+ }
116
+
117
+ /**
118
+ * Remove the specified resource from storage.
119
+ */
120
+ public function destroy(Request $request,string $comic_code, string $id)
121
+ {
122
+ $result = $this->chapterServices->delete($id);
123
+ if (!$result) {
124
+ return $this->responseJson( trans('chapter.msg_content.msg_delete_fail'),500,'');
125
+ }
126
+ return $this->responseJson( trans('chapter.msg_content.msg_delete_success'),200,['redirect'=>route('comics.edit',['code'=>$comic_code])]);
127
+ }
128
+ }
app/Http/Controllers/AjaxControllers/V1/Backend/HashtagController.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\AjaxControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\HashtagServices;
7
+ use App\Services\TaggedServices;
8
+ use App\Tranformers\ChapterResource\ChapterDetailResource;
9
+ use Illuminate\Http\Request;
10
+ use Illuminate\Support\Facades\DB;
11
+
12
+ class HashtagController extends BaseController
13
+ {
14
+ private $taggedServices;
15
+
16
+ public function __construct(TaggedServices $taggedServices)
17
+ {
18
+ $this->taggedServices = $taggedServices;
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * Update the specified resource in storage.
24
+ */
25
+ public function update(Request $request,string $comic_id, string $hashtag_id)
26
+ {
27
+ $attributes['comic_id'] = $comic_id;
28
+ $attributes['hashtag_id'] = $hashtag_id;
29
+ $attributes['is_main_tag'] = 1;
30
+ DB::beginTransaction();
31
+ try {
32
+ $result =$this->taggedServices->save($attributes);
33
+ DB::commit();
34
+
35
+ return $this->responseJson( trans('chapter.msg_content.msg_edit_success'),200,'');
36
+ } catch (\Exception $e) {
37
+ DB::rollback();
38
+ return $this->responseJson( trans('chapter.msg_content.msg_edit_fail'),500,$e->getMessage());
39
+ }
40
+ }
41
+
42
+ }
app/Http/Controllers/AjaxControllers/V1/Frontend/ChapterController.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\AjaxControllers\V1\Frontend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Http\Requests\ApiChapterRequest;
7
+ use App\Services\ChapterServices;
8
+ use App\Services\ComicServices;
9
+ use App\Services\ContentImageServices;
10
+ use App\Tranformers\ContentImageResource\ContentImageListResource;
11
+ use App\Tranformers\ChapterResource\ChapterListResource;
12
+ use Illuminate\Http\Request;
13
+ use Illuminate\Support\Facades\DB;
14
+
15
+ class ChapterController extends BaseController
16
+ {
17
+ private $contentImageServices;
18
+ public function __construct(ContentImageServices $contentImageServices)
19
+ {
20
+ $this->contentImageServices = $contentImageServices;
21
+ parent::__construct();
22
+ }
23
+
24
+
25
+ public function show(Request $request,$comic_code,$id)
26
+ {
27
+ $contentImages = $this->contentImageServices->findByChapterId($request,$id);
28
+ return new ContentImageListResource($contentImages);
29
+ }
30
+
31
+ }
app/Http/Controllers/Auth/ForgotPasswordController.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\Auth;
4
+
5
+ use App\Http\Controllers\Controller;
6
+ use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7
+
8
+ class ForgotPasswordController extends Controller
9
+ {
10
+ /*
11
+ |--------------------------------------------------------------------------
12
+ | Password Reset Controller
13
+ |--------------------------------------------------------------------------
14
+ |
15
+ | This controller is responsible for handling password reset emails and
16
+ | includes a trait which assists in sending these notifications from
17
+ | your application to your users. Feel free to explore this trait.
18
+ |
19
+ */
20
+
21
+ use SendsPasswordResetEmails;
22
+
23
+ /**
24
+ * Create a new controller instance.
25
+ *
26
+ * @return void
27
+ */
28
+ public function __construct()
29
+ {
30
+ $this->middleware('guest');
31
+ }
32
+ }
app/Http/Controllers/Auth/LoginController.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\Auth;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+
7
+ use App\Http\Requests\LoginRequest;
8
+ use Illuminate\Support\Facades\Auth;
9
+ use Illuminate\Http\Request;
10
+ use App\Http\Controllers\WebControllers\V1\Backend\LandingController;
11
+ use Illuminate\Foundation\Auth\AuthenticatesUsers;
12
+
13
+ class LoginController extends BaseController
14
+ {
15
+ /*
16
+ |--------------------------------------------------------------------------
17
+ | Login Controller
18
+ |--------------------------------------------------------------------------
19
+ |
20
+ | This controller handles authenticating users for the application and
21
+ | redirecting them to your home screen. The controller uses a trait
22
+ | to conveniently provide its functionality to your applications.
23
+ |
24
+ */
25
+
26
+
27
+ /**
28
+ * Where to redirect users after login.
29
+ *
30
+ * @var string
31
+ */
32
+ protected $redirectTo = '/home';
33
+
34
+ /**
35
+ * Create a new controller instance.
36
+ *
37
+ * @return void
38
+ */
39
+ public function __construct()
40
+ {
41
+ $this->middleware('guest', ['except' => 'logout']);
42
+ parent::__construct();
43
+ }
44
+
45
+ public function logout(){
46
+ auth()->logout();
47
+ return view('Backend.auth.login');
48
+ }
49
+
50
+ public function getLogin()
51
+ {
52
+ if (Auth::guard()->check()) {
53
+ return back();
54
+ }
55
+ return view('Backend.auth.login');
56
+ }
57
+
58
+ public function login(LoginRequest $request)
59
+ {
60
+
61
+ $remember = $request->get('remember');
62
+
63
+ $data = $request->only([
64
+ 'email',
65
+ 'password',
66
+ ]);
67
+
68
+ if (Auth::attempt(
69
+ [
70
+ 'email' => $data['email'],
71
+ 'password' => $data['password'],
72
+ ], $remember)
73
+ ) {
74
+
75
+ return redirect()->intended(action([LandingController::class,'index']));
76
+ }
77
+ return redirect()
78
+ ->action('Auth\LoginController@getLogin')
79
+ ->with('msg_fail', trans('auth.failed'));
80
+ }
81
+ }
app/Http/Controllers/Auth/LogoutController.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers;
4
+
5
+ use Illuminate\Support\Facades\Auth;
6
+
7
+ class LogoutController extends Controller
8
+ {
9
+ public function postLogout() {
10
+ Auth::logout();
11
+ return redirect()->route('login');
12
+ }
13
+ }
app/Http/Controllers/Auth/RegisterController.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\Auth;
4
+
5
+
6
+ use App\Http\Controllers\WebControllers\V1\Backend\LandingController;
7
+ use App\Models\User;
8
+
9
+ use Illuminate\Support\Facades\Auth;
10
+ use App\Http\Controllers\BaseController;
11
+ use Illuminate\Support\Facades\Hash;
12
+ use Illuminate\Support\Facades\Validator;
13
+ use Illuminate\Http\Request;
14
+ //use App\Http\Controllers\Auth\RegisterController;
15
+
16
+ class RegisterController extends BaseController
17
+ {
18
+ /*
19
+ |--------------------------------------------------------------------------
20
+ | Register Controller
21
+ |--------------------------------------------------------------------------
22
+ |
23
+ | This controller handles the registration of new users as well as their
24
+ | validation and creation. By default this controller uses a trait to
25
+ | provide this functionality without requiring any additional code.
26
+ |
27
+ */
28
+
29
+
30
+ /**
31
+ * Where to redirect users after registration.
32
+ *
33
+ * @var string
34
+ */
35
+ protected $redirectTo = '/';
36
+
37
+ /**
38
+ * Create a new controller instance.
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ $this->middleware('guest');
45
+ parent::__construct();
46
+ }
47
+
48
+ public function getRegister()
49
+ {
50
+ if (Auth::guard()->check()) {
51
+ return redirect()->intended(action([LandingController::class,'index']));
52
+ }
53
+
54
+ return view('Backend.auth.register');
55
+ }
56
+
57
+ public function register(Request $request)
58
+ {
59
+ $data = $request->only([
60
+ 'name',
61
+ 'email',
62
+ 'password'
63
+ ]);
64
+
65
+ $input = [
66
+ 'name' => $data['name'],
67
+ 'email' => $data['email'],
68
+ 'password' => $data['password'],
69
+ ];
70
+ $user = $this->create($input);
71
+ if ($user) {
72
+ Auth::login($user);
73
+ return redirect()->intended(action([LandingController::class,'index']));
74
+ }
75
+
76
+ return redirect()
77
+ ->action([RegisterController::class,'getRegister'])
78
+ ->with('message', trans('message.register_fail'));
79
+
80
+ }
81
+ protected function create( $data)
82
+ {
83
+ return User::create([
84
+ 'name' => $data['name'],
85
+ 'email' => $data['email'],
86
+ 'password' => Hash::make($data['password']),
87
+ ]);
88
+ }
89
+ }
app/Http/Controllers/Auth/ResetPasswordController.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\Auth;
4
+
5
+ use App\Http\Controllers\Controller;
6
+ use Illuminate\Foundation\Auth\ResetsPasswords;
7
+
8
+ class ResetPasswordController extends Controller
9
+ {
10
+ /*
11
+ |--------------------------------------------------------------------------
12
+ | Password Reset Controller
13
+ |--------------------------------------------------------------------------
14
+ |
15
+ | This controller is responsible for handling password reset requests
16
+ | and uses a simple trait to include this behavior. You're free to
17
+ | explore this trait and override any methods you wish to tweak.
18
+ |
19
+ */
20
+
21
+ use ResetsPasswords;
22
+
23
+ /**
24
+ * Where to redirect users after resetting their password.
25
+ *
26
+ * @var string
27
+ */
28
+ protected $redirectTo = '/home';
29
+
30
+ /**
31
+ * Create a new controller instance.
32
+ *
33
+ * @return void
34
+ */
35
+ public function __construct()
36
+ {
37
+ $this->middleware('guest');
38
+ }
39
+ }
app/Http/Controllers/BaseController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers;
4
+
5
+ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6
+ use Illuminate\Foundation\Validation\ValidatesRequests;
7
+ use Illuminate\Routing\Controller;
8
+
9
+ class BaseController extends Controller
10
+ {
11
+ use AuthorizesRequests, ValidatesRequests;
12
+ public function __construct()
13
+ {
14
+ }
15
+
16
+ protected function responseJson($message, $code = 200, $data=null)
17
+ {
18
+ return response()->json([
19
+ 'code' => $code,
20
+ 'message' => $message,
21
+ 'data' => $data
22
+ ], $code);
23
+ }
24
+
25
+ protected function responseSuccessMobileJson($message, $code = 200, $data=null)
26
+ {
27
+ return response()->json([
28
+ 'code' => $code,
29
+ 'message_mobile' => $message,
30
+ 'error_mobiles' => []
31
+ ], $code);
32
+ }
33
+
34
+ protected function responseErrorJson($message, $errors, $code = 200)
35
+ {
36
+ return response()->json([
37
+ 'code' => $code,
38
+ 'message' => $message,
39
+ 'errors' => $errors
40
+ ], $code);
41
+ }
42
+
43
+ protected function responseErrorMobileJson($message, $errors, $code = 200)
44
+ {
45
+ return response()->json([
46
+ 'code' => $code,
47
+ 'message_mobile' => $message,
48
+ 'error_mobiles' => $errors
49
+ ], $code);
50
+ }
51
+ }
app/Http/Controllers/WebControllers/V1/Backend/ArtistController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class ArtistController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/AuthorController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class AuthorController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/ChapterController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ChapterServices;
7
+ use Illuminate\Http\Request;
8
+
9
+ class ChapterController extends BaseController
10
+ {
11
+ private $chapterServices;
12
+
13
+ public function __construct(ChapterServices $chapterServices)
14
+ {
15
+ $this->chapterServices = $chapterServices;
16
+ parent::__construct();
17
+ }
18
+
19
+ public function index(Request $request)
20
+ {
21
+ }
22
+
23
+ public function show($comic_code,$chapterNumber)
24
+ {
25
+
26
+ }
27
+ }
app/Http/Controllers/WebControllers/V1/Backend/ComicController.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ChapterServices;
7
+ use App\Services\ComicServices;
8
+ use App\Services\HashtagServices;
9
+ use Google_Service_Drive_DriveFile;
10
+ use Google_Service_Drive_Permission;
11
+ use Illuminate\Http\Request;
12
+ use Illuminate\Support\Facades\DB;
13
+ use Illuminate\Support\Facades\Storage;
14
+ use App\Http\Requests\ComicRequest;
15
+ class ComicController extends BaseController
16
+ {
17
+ private $comicService;
18
+ private $chapterServices;
19
+ private $hashtagServices;
20
+ public function __construct(ComicServices $comicService,
21
+ ChapterServices $chapterServices,
22
+ HashtagServices $hashtagServices)
23
+ {
24
+ $this->hashtagServices = $hashtagServices;
25
+ $this->chapterServices = $chapterServices;
26
+ $this->comicService = $comicService;
27
+ parent::__construct();
28
+ }
29
+
30
+ /**
31
+ * Display a listing of the resource.
32
+ */
33
+ public function index(Request $request)
34
+ {
35
+ $request['isBackend'] = true;
36
+ $request['loading_hashtag']= true;
37
+ $request['loading_tagged']= true;
38
+ $comics = $this->comicService->index($request);
39
+ $comics = $this->comicService->prepareHashtags($comics);
40
+ $param = ($request->except(['page']));
41
+ return view('Backend.pages.comics.list', compact('comics','param'));
42
+ }
43
+
44
+ /**
45
+ * Show the form for creating a new resource.
46
+ */
47
+ public function create(Request $request)
48
+ {
49
+ $hashtags = $this->hashtagServices->index($request);
50
+ return view('Backend.pages.comics.add',compact('hashtags'));
51
+ }
52
+
53
+ /**
54
+ * Store a newly created resource in storage.
55
+ */
56
+ public function store(ComicRequest $request)
57
+ {
58
+ $comic = $request->only([
59
+ 'comic_name',
60
+ 'bg_color',
61
+ 'tranfer_color',
62
+ 'summary_contents',
63
+ 'tagged'
64
+ ]);
65
+ try {
66
+ $this->comicService->uploadGGDrive($request,$comic);
67
+ }catch (\Exception $e){
68
+ $request->session()->flash('msgFail', $e->getMessage());
69
+ return back()->with(['comic' => $comic]);
70
+ }
71
+
72
+ DB::beginTransaction();
73
+ try {
74
+ $result = $this->comicService->save($comic);
75
+ DB::commit();
76
+
77
+ $request->session()->flash('msgSuccess', trans('comic.msg_content.msg_add_success'));
78
+ return redirect()->route('comics.edit', ['code' => $result->comic_code]);
79
+ } catch (\Exception $e) {
80
+ DB::rollback();
81
+ $request->session()->flash('msgFail', $e->getMessage());
82
+ return back()->with(['comic' => $comic]);
83
+ }
84
+ }
85
+
86
+
87
+ /**
88
+ * Display the specified resource.
89
+ */
90
+ public function show(string $id)
91
+ {
92
+ //
93
+ }
94
+
95
+ /**
96
+ * Show the form for editing the specified resource.
97
+ */
98
+ public function edit(Request $request,string $id)
99
+ {
100
+ $comic = $this->comicService->show($id);
101
+ $chapters = $this->chapterServices->findByComics($request,$comic->id);
102
+ $param= $request->except(['page']);
103
+ $hashtags = $this->hashtagServices->index($request);
104
+ return view('Backend.pages.comics.edit', compact('comic','chapters','param','hashtags'));
105
+ }
106
+
107
+ /**
108
+ * Update the specified resource in storage.
109
+ */
110
+ public function update(Request $request, string $id)
111
+ {
112
+ $comic = $request->only([
113
+ 'comic_name',
114
+ 'bg_color',
115
+ 'tranfer_color',
116
+ 'summary_contents',
117
+ 'tagged'
118
+ ]);
119
+ $comic['comic_code'] = $id;
120
+
121
+ try {
122
+ $this->comicService->uploadGGDrive($request,$comic);
123
+ }catch (\Exception $e){
124
+ $request->session()->flash('msgFail', $e->getMessage());
125
+ return back()->with(['comic' => $comic]);
126
+ }
127
+
128
+ DB::beginTransaction();
129
+ try {
130
+
131
+ $result = $this->comicService->save($comic);
132
+ DB::commit();
133
+
134
+ $request->session()->flash('msgSuccess', trans('comic.msg_content.msg_edit_success'));
135
+ return redirect()->route('comics.edit', ['code' => $result->comic_code]);
136
+ } catch (\Exception $e) {
137
+ DB::rollback();
138
+ $request->session()->flash('msgFail', $e->getMessage());
139
+ return back()->with(['comic' => $comic]);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Remove the specified resource from storage.
145
+ */
146
+ public function destroy(Request $request, string $id)
147
+ {
148
+ $result = $this->comicService->delete($id);
149
+ if (!$result) {
150
+ $request->session()->flash('msgFail', trans('comic.msg_content.msg_delete_fail'));
151
+ }
152
+ return redirect()->route('comics.list') ;
153
+ }
154
+ }
app/Http/Controllers/WebControllers/V1/Backend/ContentImageController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class ContentImageController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/GenreController.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ChapterServices;
7
+ use App\Services\GenreServices;
8
+ use Illuminate\Http\Request;
9
+
10
+ class GenreController extends BaseController
11
+ {
12
+ private $genreServices;
13
+
14
+ public function __construct(GenreServices $genreServices)
15
+ {
16
+ $this->genreServices = $genreServices;
17
+ parent::__construct();
18
+ }
19
+
20
+ }
app/Http/Controllers/WebControllers/V1/Backend/HashtagController.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\HashtagServices;
7
+ use Illuminate\Http\Request;
8
+ use Illuminate\Support\Facades\DB;
9
+
10
+ class HashtagController extends BaseController
11
+ {
12
+ private $hashtagServices;
13
+
14
+ public function __construct(HashtagServices $hashtagServices)
15
+ {
16
+ $this->hashtagServices = $hashtagServices;
17
+ parent::__construct();
18
+ }
19
+
20
+ /**
21
+ * Display a listing of the resource.
22
+ */
23
+ public function index(Request $request)
24
+ {
25
+ $hashtags = $this->hashtagServices->index($request);
26
+ return view('Backend.pages.hashtags.list', compact('hashtags'));
27
+ }
28
+
29
+ /**
30
+ * Show the form for creating a new resource.
31
+ */
32
+ public function create()
33
+ {
34
+ return view('Backend.pages.hashtags.add');
35
+ }
36
+
37
+ /**
38
+ * Store a newly created resource in storage.
39
+ */
40
+ public function store(Request $request)
41
+ {
42
+ $hashtag= $request->only([
43
+ 'name',
44
+ ]);
45
+
46
+ DB::beginTransaction();
47
+ try {
48
+
49
+ $result = $this->hashtagServices->save($hashtag);
50
+ DB::commit();
51
+
52
+ $request->session()->flash('msgSuccess', trans('hashtag.msg_content.msg_add_success'));
53
+ return redirect()->route('hashtags.edit', ['id' => $result->id]);
54
+ } catch (\Exception $e) {
55
+ DB::rollback();
56
+ $request->session()->flash('msgFail', $e->getMessage());
57
+ return back()->with(['hashtags' => $hashtag]);
58
+ }
59
+ }
60
+
61
+
62
+ /**
63
+ * Display the specified resource.
64
+ */
65
+ public function show(string $id)
66
+ {
67
+ //
68
+ }
69
+
70
+ /**
71
+ * Show the form for editing the specified resource.
72
+ */
73
+ public function edit(Request $request,string $id)
74
+ {
75
+ $hashtag = $this->hashtagServices->show($id);
76
+ return view('Backend.pages.hashtags.edit', compact('hashtag'));
77
+ }
78
+
79
+ /**
80
+ * Update the specified resource in storage.
81
+ */
82
+ public function update(Request $request, string $id)
83
+ {
84
+ $hashtag = $request->only([
85
+ 'id',
86
+ 'name',
87
+ ]);
88
+
89
+ DB::beginTransaction();
90
+ try {
91
+
92
+ $result = $this->hashtagServices->save($hashtag);
93
+ DB::commit();
94
+
95
+ $request->session()->flash('msgSuccess', trans('hashtag.msg_content.msg_edit_success'));
96
+ return redirect()->route('hashtags.edit', ['id' => $result->id]);
97
+ } catch (\Exception $e) {
98
+ DB::rollback();
99
+ $request->session()->flash('msgFail', $e->getMessage());
100
+ return back()->with(['hashtag' => $hashtag]);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Remove the specified resource from storage.
106
+ */
107
+ public function destroy(Request $request, string $id)
108
+ {
109
+ $result = $this->hashtagServices->delete($id);
110
+ if (!$result) {
111
+ $request->session()->flash('msgFail', trans('hashtag.msg_content.msg_delete_fail'));
112
+ }
113
+ return redirect()->route('hashtags.list');
114
+ }
115
+ }
app/Http/Controllers/WebControllers/V1/Backend/LandingController.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ComicServices;
7
+ use App\Services\GenreServices;
8
+ use Illuminate\Http\Request;
9
+
10
+ class LandingController extends BaseController
11
+ {
12
+ private $comicService;
13
+ private $genreService;
14
+ public function __construct(ComicServices $comicService, GenreServices $genreService)
15
+ {
16
+ $this->genreService = $genreService;
17
+ $this->comicService = $comicService;
18
+ parent::__construct();
19
+ }
20
+
21
+ public function index(Request $request)
22
+ {
23
+ return view('Backend.pages.dashboard.index');
24
+ }
25
+ }
app/Http/Controllers/WebControllers/V1/Backend/LikeController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class LikeController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/PublisherController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class PublisherController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/SummaryContentController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class SummaryContentController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/TaggedController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class TaggedController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/UserController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class UserController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Backend/ViewController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Backend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class ViewController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Controllers/WebControllers/V1/Frontend/ChapterController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Frontend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Models\ContentImage;
7
+ use App\Services\ChapterServices;
8
+ use App\Services\ComicServices;
9
+ use App\Services\ContentImageServices;
10
+ use Illuminate\Http\Request;
11
+
12
+ class ChapterController extends BaseController
13
+ {
14
+ private $chapterServices;
15
+ private $contentImageServices;
16
+ private $comicServices;
17
+
18
+ public function __construct(ChapterServices $chapterServices, ContentImageServices $contentImageServices, ComicServices $comicServices)
19
+ {
20
+ $this->comicServices = $comicServices;
21
+ $this->contentImageServices = $contentImageServices;
22
+ $this->chapterServices = $chapterServices;
23
+ parent::__construct();
24
+ }
25
+
26
+ public function index(Request $request)
27
+ {
28
+ return view('Frontend.pages.comics.index');
29
+ }
30
+
31
+ public function show(Request $request,$slug1, $comic_code,$slug2, $id)
32
+ {
33
+ $comic_code = $request->get('comic_code');
34
+ $comic = $this->chapterServices->findByComicCodeAndChapterId($comic_code, $id);
35
+ if ($comic) {
36
+ $relations = $this->comicServices->getRelationComic($comic_code);
37
+ $contentImages = $comic ? $this->contentImageServices->findByChapterId($request, $comic->id) : [];
38
+ $comic ?->with('nextChapter', 'prvChapter');
39
+ return view('Frontend.pages.chapters.index', compact('comic', 'contentImages', 'relations', 'comic_code'));
40
+ } else {
41
+ return redirect()->back();
42
+ }
43
+
44
+ }
45
+
46
+ }
app/Http/Controllers/WebControllers/V1/Frontend/ComicController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Frontend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ComicServices;
7
+ use App\Services\HashtagServices;
8
+ use App\Services\TaggedServices;
9
+ use Illuminate\Http\Request;
10
+
11
+ class ComicController extends BaseController
12
+ {
13
+ private $comicServices;
14
+ private $hashtagServices;
15
+ public function __construct(ComicServices $comicServices, HashtagServices $hashtagServices)
16
+ {
17
+ $this->hashtagServices= $hashtagServices;
18
+ $this->comicServices = $comicServices;
19
+ parent::__construct();
20
+ }
21
+
22
+ public function index(Request $request)
23
+ {
24
+ $comics = $this->comicServices->index($request);
25
+ $param = ($request->except(['page']));
26
+ return view('Frontend.pages.comics.search',compact('comics','param'));
27
+ }
28
+
29
+ public function searchByhashTag(Request $request,$hashtag)
30
+ {
31
+ $request['hashtag'] = $hashtag;
32
+ $comics = $this->comicServices->index($request);
33
+ return view('Frontend.pages.comics.search',compact('comics'));
34
+ }
35
+
36
+ public function show(Request $request,$slug)
37
+ {
38
+ $comic_code = $request->get('comic_code');
39
+ $relations = $this->comicServices->getRelationComic($comic_code);
40
+ $main_tag = $this->hashtagServices->findByComicIdandIsMain($comic_code);
41
+ $comic = $this->comicServices->show($comic_code);
42
+ return view('Frontend.pages.comics.detail',compact('comic','relations','main_tag'));
43
+ }
44
+ }
app/Http/Controllers/WebControllers/V1/Frontend/LandingController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Frontend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use App\Services\ComicServices;
7
+ use App\Services\GenreServices;
8
+ use Google_Service_Drive_DriveFile;
9
+ use Google_Service_Drive_Permission;
10
+ use Illuminate\Support\Facades\Storage;
11
+ use Illuminate\Http\Request;
12
+
13
+ class LandingController extends BaseController
14
+ {
15
+ private $comicService;
16
+ private $genreService;
17
+ public function __construct(ComicServices $comicService, GenreServices $genreService)
18
+ {
19
+ $this->genreService = $genreService;
20
+ $this->comicService = $comicService;
21
+ parent::__construct();
22
+ }
23
+
24
+ public function index(Request $request)
25
+ {
26
+ $genres = $this->genreService->index($request);
27
+ $comics = $this->comicService->index($request);
28
+ $param = ($request->except(['page']));
29
+ return view('Frontend.pages.landing.index',compact('genres','comics','param'));
30
+ }
31
+
32
+
33
+ }
app/Http/Controllers/WebControllers/V1/Frontend/UserController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Controllers\WebControllers\V1\Frontend;
4
+
5
+ use App\Http\Controllers\BaseController;
6
+ use Illuminate\Http\Request;
7
+
8
+ class UserController extends BaseController
9
+ {
10
+ //
11
+ }
app/Http/Kernel.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http;
4
+
5
+ use Illuminate\Foundation\Http\Kernel as HttpKernel;
6
+
7
+ class Kernel extends HttpKernel
8
+ {
9
+ /**
10
+ * The application's global HTTP middleware stack.
11
+ *
12
+ * These middleware are run during every request to your application.
13
+ *
14
+ * @var array<int, class-string|string>
15
+ */
16
+ protected $middleware = [
17
+ // \App\Http\Middleware\TrustHosts::class,
18
+ \App\Http\Middleware\TrustProxies::class,
19
+ \Illuminate\Http\Middleware\HandleCors::class,
20
+ \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
21
+ \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
22
+ \App\Http\Middleware\TrimStrings::class,
23
+ \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
24
+
25
+ ];
26
+
27
+ /**
28
+ * The application's route middleware groups.
29
+ *
30
+ * @var array<string, array<int, class-string|string>>
31
+ */
32
+ protected $middlewareGroups = [
33
+ 'web' => [
34
+ \App\Http\Middleware\EncryptCookies::class,
35
+ \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
36
+ \Illuminate\Session\Middleware\StartSession::class,
37
+ \Illuminate\View\Middleware\ShareErrorsFromSession::class,
38
+ \App\Http\Middleware\VerifyCsrfToken::class,
39
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
40
+ //\App\Http\Middleware\GzipMiddleware::class,
41
+
42
+ ],
43
+
44
+ 'api' => [
45
+ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
46
+ \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
47
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
48
+ ],
49
+ ];
50
+
51
+ /**
52
+ * The application's middleware aliases.
53
+ *
54
+ * Aliases may be used to conveniently assign middleware to routes and groups.
55
+ *
56
+ * @var array<string, class-string|string>
57
+ */
58
+ protected $middlewareAliases = [
59
+ 'auth' => \App\Http\Middleware\Authenticate::class,
60
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
61
+ 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
62
+ 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
63
+ 'can' => \Illuminate\Auth\Middleware\Authorize::class,
64
+ 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
65
+ 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
66
+ 'signed' => \App\Http\Middleware\ValidateSignature::class,
67
+ 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
68
+ 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
69
+ 'viewed'=> \App\Http\Middleware\TrafficMiddleware::class,
70
+ 'convertId'=> \App\Http\Middleware\ConvertIdMiddleware::class,
71
+
72
+ ];
73
+ }
app/Http/Middleware/Authenticate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Auth\Middleware\Authenticate as Middleware;
6
+ use Illuminate\Http\Request;
7
+
8
+ class Authenticate extends Middleware
9
+ {
10
+ /**
11
+ * Get the path the user should be redirected to when they are not authenticated.
12
+ */
13
+ protected function redirectTo(Request $request): ?string
14
+ {
15
+ return $request->expectsJson() ? null : route('login');
16
+ }
17
+ }
app/Http/Middleware/ConvertIdMiddleware.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use App\Services\ComicServices;
6
+ use Closure;
7
+ use Illuminate\Http\Request;
8
+ use Symfony\Component\HttpFoundation\Response;
9
+
10
+ class ConvertIdMiddleware
11
+ {
12
+ // private $keyArray = ['9', '1', '6', '4', '0', '8', '3', '2', '5', '7'];
13
+
14
+ public function handle($request, Closure $next)
15
+ {
16
+ $id = $request->route('comic_code');
17
+ if($id){
18
+ $reversedString = reverseConvert($id, config('settings.arrray_keys_convert_id'));
19
+ $request->offsetSet('comic_code', 'COMIC-'.$reversedString);
20
+ }
21
+
22
+ return $next($request);
23
+ }
24
+ }
app/Http/Middleware/EncryptCookies.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
6
+
7
+ class EncryptCookies extends Middleware
8
+ {
9
+ /**
10
+ * The names of the cookies that should not be encrypted.
11
+ *
12
+ * @var array<int, string>
13
+ */
14
+ protected $except = [
15
+ //
16
+ ];
17
+ }
app/Http/Middleware/GzipMiddleware.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace App\Http\Middleware;
3
+
4
+ use Closure;
5
+
6
+
7
+ class GzipMiddleware
8
+ {
9
+ /**
10
+ * Handle an incoming request.
11
+ *
12
+ * @param \Illuminate\Http\Request $request
13
+ * @param \Closure $next
14
+ * @return mixed
15
+ */
16
+ public function handle($request, Closure $next)
17
+ {
18
+ $response = $next($request);
19
+ $content = $response->content();
20
+ $data = gzencode($content, 9);
21
+
22
+ return response($data)->withHeaders([
23
+ 'Access-Control-Allow-Origin' => '*',
24
+ 'Access-Control-Allow-Methods'=> 'GET',
25
+ 'Content-Length'=> strlen($data),
26
+ 'Content-Encoding' => 'gzip'
27
+ ]);
28
+ }
29
+ }
app/Http/Middleware/PreventRequestsDuringMaintenance.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
6
+
7
+ class PreventRequestsDuringMaintenance extends Middleware
8
+ {
9
+ /**
10
+ * The URIs that should be reachable while maintenance mode is enabled.
11
+ *
12
+ * @var array<int, string>
13
+ */
14
+ protected $except = [
15
+ //
16
+ ];
17
+ }
app/Http/Middleware/RedirectIfAuthenticated.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use App\Providers\RouteServiceProvider;
6
+ use Closure;
7
+ use Illuminate\Http\Request;
8
+ use Illuminate\Support\Facades\Auth;
9
+ use Symfony\Component\HttpFoundation\Response;
10
+
11
+ class RedirectIfAuthenticated
12
+ {
13
+ /**
14
+ * Handle an incoming request.
15
+ *
16
+ * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
17
+ */
18
+ public function handle(Request $request, Closure $next, string ...$guards): Response
19
+ {
20
+ $guards = empty($guards) ? [null] : $guards;
21
+
22
+ foreach ($guards as $guard) {
23
+ if (Auth::guard($guard)->check()) {
24
+ return redirect(RouteServiceProvider::HOME);
25
+ }
26
+ }
27
+
28
+ return $next($request);
29
+ }
30
+ }
app/Http/Middleware/TrafficMiddleware.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use App\Services\ComicServices;
6
+ use Closure;
7
+ use Illuminate\Http\Request;
8
+ use Symfony\Component\HttpFoundation\Response;
9
+
10
+ class TrafficMiddleware
11
+ {
12
+
13
+ public function handle($request, Closure $next)
14
+ {
15
+ $comicServices = app()->make(ComicServices::class);
16
+ $comic_code = $request['comic_code'];
17
+
18
+ if($comic_code){
19
+ $entity = $comicServices->findByComicCode($comic_code);
20
+ if($entity){
21
+ ++$entity->total_view;
22
+ $entity->save();
23
+ }
24
+ }
25
+
26
+ return $next($request);
27
+ }
28
+ }
app/Http/Middleware/TrimStrings.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
6
+
7
+ class TrimStrings extends Middleware
8
+ {
9
+ /**
10
+ * The names of the attributes that should not be trimmed.
11
+ *
12
+ * @var array<int, string>
13
+ */
14
+ protected $except = [
15
+ 'current_password',
16
+ 'password',
17
+ 'password_confirmation',
18
+ ];
19
+ }
app/Http/Middleware/TrustHosts.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Http\Middleware\TrustHosts as Middleware;
6
+
7
+ class TrustHosts extends Middleware
8
+ {
9
+ /**
10
+ * Get the host patterns that should be trusted.
11
+ *
12
+ * @return array<int, string|null>
13
+ */
14
+ public function hosts(): array
15
+ {
16
+ return [
17
+ $this->allSubdomainsOfApplicationUrl(),
18
+ ];
19
+ }
20
+ }
app/Http/Middleware/TrustProxies.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Http\Middleware\TrustProxies as Middleware;
6
+ use Illuminate\Http\Request;
7
+
8
+ class TrustProxies extends Middleware
9
+ {
10
+ /**
11
+ * The trusted proxies for this application.
12
+ *
13
+ * @var array<int, string>|string|null
14
+ */
15
+ protected $proxies;
16
+
17
+ /**
18
+ * The headers that should be used to detect proxies.
19
+ *
20
+ * @var int
21
+ */
22
+ protected $headers =
23
+ Request::HEADER_X_FORWARDED_FOR |
24
+ Request::HEADER_X_FORWARDED_HOST |
25
+ Request::HEADER_X_FORWARDED_PORT |
26
+ Request::HEADER_X_FORWARDED_PROTO |
27
+ Request::HEADER_X_FORWARDED_AWS_ELB;
28
+ }
app/Http/Middleware/ValidateSignature.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
6
+
7
+ class ValidateSignature extends Middleware
8
+ {
9
+ /**
10
+ * The names of the query string parameters that should be ignored.
11
+ *
12
+ * @var array<int, string>
13
+ */
14
+ protected $except = [
15
+ // 'fbclid',
16
+ // 'utm_campaign',
17
+ // 'utm_content',
18
+ // 'utm_medium',
19
+ // 'utm_source',
20
+ // 'utm_term',
21
+ ];
22
+ }
app/Http/Middleware/VerifyCsrfToken.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Middleware;
4
+
5
+ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
6
+
7
+ class VerifyCsrfToken extends Middleware
8
+ {
9
+ /**
10
+ * The URIs that should be excluded from CSRF verification.
11
+ *
12
+ * @var array<int, string>
13
+ */
14
+ protected $except = [
15
+ '/github-webhook'
16
+ ];
17
+ }
app/Http/Requests/ApiChapterRequest.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace App\Http\Requests;
4
+
5
+ use Illuminate\Contracts\Validation\Validator;
6
+ use Illuminate\Foundation\Http\FormRequest;
7
+ use Illuminate\Http\Exceptions\HttpResponseException;
8
+ use Illuminate\Http\Response;
9
+
10
+ class ApiChapterRequest extends FormRequest
11
+ {
12
+ private $error_messages = array();
13
+ private $error_mobiles = [];
14
+
15
+ public function rules()
16
+ {
17
+ return [
18
+ 'chapter_name'=> 'required'
19
+ ];
20
+ }
21
+
22
+ /**
23
+ * Determine if the user is authorized to make this request.
24
+ *
25
+ * @return bool
26
+ */
27
+ public function authorize()
28
+ {
29
+ return true;
30
+ }
31
+
32
+ protected function prepareForValidation()
33
+ {
34
+ }
35
+
36
+ protected function failedValidation(Validator $validator)
37
+ {
38
+ throw new HttpResponseException(
39
+ response()->json([
40
+ 'errors' => $this->error_messages,
41
+ 'code' => Response::HTTP_UNPROCESSABLE_ENTITY,
42
+ 'message' => "fails",
43
+ 'error_mobiles' => $this->error_mobiles
44
+ ], Response::HTTP_UNPROCESSABLE_ENTITY)
45
+ );
46
+ }
47
+
48
+ public function withValidator(Validator $validator)
49
+ {
50
+ $validator->after(function ($validator) {
51
+ if ($validator->failed()) {
52
+ $this->error_messages = $validator->messages()->getMessages();
53
+ foreach ($this->error_messages as $key => $value) {
54
+ $item = [
55
+ 'field' => $key,
56
+ 'message' => $value[0]
57
+ ];
58
+ array_push($this->error_mobiles, $item);
59
+ }
60
+ return;
61
+ }
62
+ });
63
+ }
64
+
65
+ public function messages()
66
+ {
67
+ return [
68
+ 'chapter_name.required' => 'Bắt buộc nhập',
69
+ ];
70
+ }
71
+ }