From 585ce66e3c0fd03c4cf2cddf8d4385ab2a0202b2 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Thu, 1 Jun 2023 23:52:18 +0800 Subject: [PATCH 01/12] xpo 03-2023 --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 617691e8..8eb47681 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -65,7 +65,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { $bookings = Booking::where('service_id', '!=', 4)->where(function($query){ - return $query->whereMonth('created_at', '=', 04)->whereYear('created_at', 2023); + return $query->whereMonth('created_at', '=', 03)->whereYear('created_at', 2023); })->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); From 4218a4e398b19617d1067c467d398642eb6068f0 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 14:42:37 +0800 Subject: [PATCH 02/12] company name warning text --- .../vue/components/banks/forms/BankAccountFormComponent.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue index 6e9518d9..f0c58095 100644 --- a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue @@ -27,9 +27,10 @@
- + + {{ serviceType.id != 4 ? '*Please ensure to use the appropriate company name for corporate transfers, instead of personal names.' : ''}}
From 6b73f319937898bde5bb14c4589ca6fc1f976a62 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 15:48:33 +0800 Subject: [PATCH 03/12] email payment proof --- .../SendUserPaymentProofUploadedEmail.php | 42 +++++++++++++++++++ .../CreatePaymentProofDocumentLogic.php | 15 ++++++- .../PaymentProofUploadedEmail.php | 41 ++++++++++++++++++ .../accounts/payment_proof_email.blade.php | 12 ++++++ routes/web.php | 38 ++++++++++++++++- 5 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php create mode 100644 app/Classes/Notifications/PaymentProofUploadedEmail.php create mode 100644 resources/views/emails/accounts/payment_proof_email.blade.php diff --git a/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php new file mode 100644 index 00000000..8aa94ce8 --- /dev/null +++ b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php @@ -0,0 +1,42 @@ +user = $user; + $this->booking = $booking; + } + + + public function handle() + { + $this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking)); + } +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index fdda9019..b4448729 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -14,6 +14,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\CompanyType; use App\Classes\ValueObjects\Constants\DocumentType; +use App\Classes\Jobs\SendUserPaymentProofUploadedEmail; use App\Models\Company; use App\Models\Document; use Illuminate\Http\JsonResponse; @@ -50,6 +51,9 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic /** @var CreateInvoiceTransactionProcessor */ private $createInvoiceTransactionProcessor; + /** @var SendUserPaymentProofUploadedEmail */ + private $sendUserPaymentProofUploadedEmail; + /** * CreatePaymentProofDocumentLogic constructor. * @param FetchesTransaction $fetchesTransaction @@ -58,13 +62,14 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic * @param UpdatesTransactionStatus $updatesTransactionStatus * @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor */ - public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor) + public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor, SendUserPaymentProofUploadedEmail $sendUserPaymentProofUploadedEmail) { $this->fetchesTransaction = $fetchesTransaction; $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; + $this->sendUserPaymentProofUploadedEmail = $sendUserPaymentProofUploadedEmail; } /** @@ -88,6 +93,14 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic $this->createInvoiceTransactionProcessor->execute($transaction->owner->booking); + // send email to customer + // todo: send them the file also + // todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order + $companyEmployee = $transaction->owner->booking->company->employees; + foreach ($companyEmployee as $employee) { + $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking); + } + return $this->response([]); } diff --git a/app/Classes/Notifications/PaymentProofUploadedEmail.php b/app/Classes/Notifications/PaymentProofUploadedEmail.php new file mode 100644 index 00000000..d0bf21f0 --- /dev/null +++ b/app/Classes/Notifications/PaymentProofUploadedEmail.php @@ -0,0 +1,41 @@ +user = $user; + $this->booking = $booking; + } + + + public function toMail() + { + return (new MailMessage) + ->subject('Transfer Completed (REF: ' . $this->booking->marking . ')') + ->to('edmond.wuiming2021@gmail.com') // testing email + // ->attach('/path/to/file') // todo-new: add attachement + ->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]); + } + + +} diff --git a/resources/views/emails/accounts/payment_proof_email.blade.php b/resources/views/emails/accounts/payment_proof_email.blade.php new file mode 100644 index 00000000..8d888671 --- /dev/null +++ b/resources/views/emails/accounts/payment_proof_email.blade.php @@ -0,0 +1,12 @@ +@extends('emails.layout.base') + +@section('content') +

Dear {{$user->name}},

+

Thank you for using CIEF Exchange service!

+

We have completed your RMB transfer transaction for the ref. no {{$booking->marking}}. The RMB bank slip has been attached to this email. If you would like to view the transaction, please click on the following link:

+
+ +
+ + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 2547d087..3116a479 100644 --- a/routes/web.php +++ b/routes/web.php @@ -600,4 +600,40 @@ Route::get('/po/outsource/check', function(){ Route::get('/upload-honey-trap', function () { return view('pages.honey_trap'); -})->name('upload_honey_trap'); \ No newline at end of file +})->name('upload_honey_trap'); + +Route::get('/text-transfer-email', function () { + $booking = Booking::where('marking', '25760')->first(); + $mployee = $booking->company->employees->first(); + return view('emails.accounts.payment_proof_email', ['booking' => $booking, 'user' => $mployee, ]); +}); + +use Illuminate\Support\Facades\Mail; + +Route::get('/show-email', function () { + // Send some emails using MailMessage + // Retrieve the Swift Mailer instance + $mailer = Mail::getSwiftMailer(); + // Retrieve the Transport instance + $transport = $mailer->getTransport(); + // Retrieve the sent messages + $messages = $transport->getMessages(); + // Loop through the sent messages + foreach ($messages as $message) { + // Access the email details + $subject = $message->getSubject(); + $from = $message->getFrom(); + $to = $message->getTo(); + $cc = $message->getCc(); + $bcc = $message->getBcc(); + // ...and so on + + // Output the email details + echo "Subject: $subject\n"; + echo "From: $from\n"; + echo "To: $to\n"; + echo "Cc: $cc\n"; + echo "Bcc: $bcc\n"; + echo "\n"; + } +}); From f1ce5c6a86b56f2c900b665ba8c2c8c1bf6ba7e2 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 15:58:13 +0800 Subject: [PATCH 04/12] update email payment proof --- app/Classes/Notifications/PaymentProofUploadedEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Notifications/PaymentProofUploadedEmail.php b/app/Classes/Notifications/PaymentProofUploadedEmail.php index d0bf21f0..ff39c3c3 100644 --- a/app/Classes/Notifications/PaymentProofUploadedEmail.php +++ b/app/Classes/Notifications/PaymentProofUploadedEmail.php @@ -32,7 +32,7 @@ class PaymentProofUploadedEmail extends AbstractEmail { return (new MailMessage) ->subject('Transfer Completed (REF: ' . $this->booking->marking . ')') - ->to('edmond.wuiming2021@gmail.com') // testing email + // ->to('edmond.wuiming2021@gmail.com') // testing email // ->attach('/path/to/file') // todo-new: add attachement ->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]); } From ec85ec07ab2e4224e0576769a7d3ee27a5162c87 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 17:01:15 +0800 Subject: [PATCH 05/12] send email payment proof --- .../SendUserPaymentProofUploadedEmail.php | 9 +++-- .../CreatePaymentProofDocumentLogic.php | 4 +-- .../PaymentProofUploadedEmail.php | 19 ++++++++-- routes/web.php | 36 ------------------- 4 files changed, 25 insertions(+), 43 deletions(-) diff --git a/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php index 8aa94ce8..072dfa15 100644 --- a/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php +++ b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php @@ -5,6 +5,7 @@ namespace App\Classes\Jobs; use App\Classes\Notifications\PaymentProofUploadedEmail; use App\Models\Booking; use App\Models\User; +use App\Models\File; use App\Models\UserEmailVerification; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -23,20 +24,24 @@ class SendUserPaymentProofUploadedEmail implements ShouldQueue /** @var Booking */ private $booking; + /** @var File */ + private $file; + /** * SendUserVerificationEmail constructor. * @param User $user * @param UserEmailVerification $attempt */ - public function __construct(User $user, Booking $booking) + public function __construct(User $user, Booking $booking, File $file) { $this->user = $user; $this->booking = $booking; + $this->file = $file; } public function handle() { - $this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking)); + $this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking, $this->file)); } } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index b4448729..778362aa 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -87,7 +87,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic /** @var Document $document */ $document = $this->createsDocument->execute($transaction, $object); - $this->createsFile->execute($document, $object); + $file = $this->createsFile->execute($document, $object); $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); @@ -98,7 +98,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic // todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order $companyEmployee = $transaction->owner->booking->company->employees; foreach ($companyEmployee as $employee) { - $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking); + $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]); } return $this->response([]); diff --git a/app/Classes/Notifications/PaymentProofUploadedEmail.php b/app/Classes/Notifications/PaymentProofUploadedEmail.php index ff39c3c3..cc611236 100644 --- a/app/Classes/Notifications/PaymentProofUploadedEmail.php +++ b/app/Classes/Notifications/PaymentProofUploadedEmail.php @@ -4,6 +4,7 @@ namespace App\Classes\Notifications; use App\Models\Booking; use App\Models\User; +use App\Models\File; use App\Models\UserEmailVerification; use Illuminate\Notifications\Messages\MailMessage; @@ -16,24 +17,36 @@ class PaymentProofUploadedEmail extends AbstractEmail /** @var Booking */ private $booking; + /** @var File */ + private $file; + /** * UserVerificationEmail constructor. * @param User $user * @param UserEmailVerification $attempt */ - public function __construct(User $user, Booking $booking) + public function __construct(User $user, Booking $booking, File $file) { $this->user = $user; $this->booking = $booking; + $this->file = $file; } public function toMail() { + $attachedFile = null; + $file_info = $this->file->getFileAttribute($this->file)->file->file_info; + foreach ($file_info as $fileCount => $fileVal) { + if (isset($fileVal->original)) { + $file_path = $fileVal->original->file; + $attachedFile = storage_path('app/documents/' . $file_path); + } + } + return (new MailMessage) ->subject('Transfer Completed (REF: ' . $this->booking->marking . ')') - // ->to('edmond.wuiming2021@gmail.com') // testing email - // ->attach('/path/to/file') // todo-new: add attachement + ->attach($attachedFile) // todo-new: add attachement ->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]); } diff --git a/routes/web.php b/routes/web.php index 3116a479..7ba6d068 100644 --- a/routes/web.php +++ b/routes/web.php @@ -601,39 +601,3 @@ Route::get('/po/outsource/check', function(){ Route::get('/upload-honey-trap', function () { return view('pages.honey_trap'); })->name('upload_honey_trap'); - -Route::get('/text-transfer-email', function () { - $booking = Booking::where('marking', '25760')->first(); - $mployee = $booking->company->employees->first(); - return view('emails.accounts.payment_proof_email', ['booking' => $booking, 'user' => $mployee, ]); -}); - -use Illuminate\Support\Facades\Mail; - -Route::get('/show-email', function () { - // Send some emails using MailMessage - // Retrieve the Swift Mailer instance - $mailer = Mail::getSwiftMailer(); - // Retrieve the Transport instance - $transport = $mailer->getTransport(); - // Retrieve the sent messages - $messages = $transport->getMessages(); - // Loop through the sent messages - foreach ($messages as $message) { - // Access the email details - $subject = $message->getSubject(); - $from = $message->getFrom(); - $to = $message->getTo(); - $cc = $message->getCc(); - $bcc = $message->getBcc(); - // ...and so on - - // Output the email details - echo "Subject: $subject\n"; - echo "From: $from\n"; - echo "To: $to\n"; - echo "Cc: $cc\n"; - echo "Bcc: $bcc\n"; - echo "\n"; - } -}); From dc5b96403c7bd4a34c71861b4d204fbf78126c82 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 19:02:41 +0800 Subject: [PATCH 06/12] update email payment proof --- resources/views/emails/accounts/payment_proof_email.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/emails/accounts/payment_proof_email.blade.php b/resources/views/emails/accounts/payment_proof_email.blade.php index 8d888671..eb1357ea 100644 --- a/resources/views/emails/accounts/payment_proof_email.blade.php +++ b/resources/views/emails/accounts/payment_proof_email.blade.php @@ -1,7 +1,7 @@ @extends('emails.layout.base') @section('content') -

Dear {{$user->name}},

+

Dear {{ucwords($user->name)}},

Thank you for using CIEF Exchange service!

We have completed your RMB transfer transaction for the ref. no {{$booking->marking}}. The RMB bank slip has been attached to this email. If you would like to view the transaction, please click on the following link:

From 763902879d68ea340c61fa8f03fe71ef411af6eb Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 3 Jun 2023 19:19:35 +0800 Subject: [PATCH 07/12] update send email payment proof, send email only in production --- .../ControllersLogic/CreatePaymentProofDocumentLogic.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index 778362aa..00ca9a85 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -94,11 +94,12 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic $this->createInvoiceTransactionProcessor->execute($transaction->owner->booking); // send email to customer - // todo: send them the file also // todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order - $companyEmployee = $transaction->owner->booking->company->employees; - foreach ($companyEmployee as $employee) { - $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]); + if (app()->environment('production')) { + $companyEmployee = $transaction->owner->booking->company->employees; + foreach ($companyEmployee as $employee) { + $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]); + } } return $this->response([]); From 5cab3578053529dad1775ed71da4047eaef9f2a5 Mon Sep 17 00:00:00 2001 From: Dillon Date: Sun, 4 Jun 2023 20:54:25 +0800 Subject: [PATCH 08/12] Testing of csrf --- .../AWS/AWSImageUploadController.php | 50 +++++++++++++++++++ .../views/pages/aws_image_upload.blade.php | 43 ++++++++++++++++ routes/web.php | 7 ++- 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/AWS/AWSImageUploadController.php create mode 100644 resources/views/pages/aws_image_upload.blade.php diff --git a/app/Http/Controllers/AWS/AWSImageUploadController.php b/app/Http/Controllers/AWS/AWSImageUploadController.php new file mode 100644 index 00000000..b258b3ee --- /dev/null +++ b/app/Http/Controllers/AWS/AWSImageUploadController.php @@ -0,0 +1,50 @@ +validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + ]); + + $imageName = time().'.'.$request->image->extension(); + + $request->image->storeAs('images', $imageName); + + return back() + ->with('success','You have successfully upload image.') + ->with('image',$imageName); + } + + + public function displayImage($fileName) + { + $path = 'images/'.$fileName; + $file = Storage::get($path); + $type = Storage::mimeType($path); + + $response = Response::make($file, 200); + $response->header("Content-Type", $type); + + return $response; + } + +} diff --git a/resources/views/pages/aws_image_upload.blade.php b/resources/views/pages/aws_image_upload.blade.php new file mode 100644 index 00000000..7e6e91f5 --- /dev/null +++ b/resources/views/pages/aws_image_upload.blade.php @@ -0,0 +1,43 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+

Image Upload with Laravel Vapor

+
+ + @if ($message = Session::get('success')) +
+ + {{ $message }} +
+ + @endif + + @if (count($errors) > 0) +
+ Whoops! There were some problems with your input. +
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + + +
+ @csrf +
+
+ +
+ +
+ +
+
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 2547d087..c02ac5c6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -600,4 +600,9 @@ Route::get('/po/outsource/check', function(){ Route::get('/upload-honey-trap', function () { return view('pages.honey_trap'); -})->name('upload_honey_trap'); \ No newline at end of file +})->name('upload_honey_trap'); + + +Route::get('aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); +Route::post('aws-image-upload/upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); +Route::get('aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); From 81b5fc5eb6fd6cc6d421a8ca6f6c00cf2c67916d Mon Sep 17 00:00:00 2001 From: Dillon Date: Sun, 4 Jun 2023 21:02:13 +0800 Subject: [PATCH 09/12] Testing of csrf --- routes/web.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/web.php b/routes/web.php index c02ac5c6..5ee6f211 100644 --- a/routes/web.php +++ b/routes/web.php @@ -603,6 +603,6 @@ Route::get('/upload-honey-trap', function () { })->name('upload_honey_trap'); -Route::get('aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); -Route::post('aws-image-upload/upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); -Route::get('aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); +Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); +Route::post('/aws-image-upload/upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); +Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); From 64f7150c95f829718b5511d4628a26ebbcf07a67 Mon Sep 17 00:00:00 2001 From: Dillon Date: Sun, 4 Jun 2023 22:04:13 +0800 Subject: [PATCH 10/12] Testing of csrf --- app/Http/Controllers/AWS/AWSImageUploadController.php | 2 +- routes/web.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AWS/AWSImageUploadController.php b/app/Http/Controllers/AWS/AWSImageUploadController.php index b258b3ee..e1414d34 100644 --- a/app/Http/Controllers/AWS/AWSImageUploadController.php +++ b/app/Http/Controllers/AWS/AWSImageUploadController.php @@ -6,7 +6,7 @@ namespace App\Http\Controllers\AWS; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use App\Http\Controllers\Controller; -use Illuminate\Http\Response; +use Illuminate\Support\Facades\Response; class AWSImageUploadController extends Controller diff --git a/routes/web.php b/routes/web.php index 14fda1c5..b8803f5e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -621,5 +621,5 @@ Route::get('/upload-honey-trap', function () { Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); -Route::post('/aws-image-upload/upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); +Route::post('/aws-image-upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); From 2ec51be6535dc907c6eaaa3904fea1b722f9cc97 Mon Sep 17 00:00:00 2001 From: Dillon Date: Sun, 4 Jun 2023 22:06:10 +0800 Subject: [PATCH 11/12] Testing of csrf --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 5ee6f211..53260db6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -604,5 +604,5 @@ Route::get('/upload-honey-trap', function () { Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); -Route::post('/aws-image-upload/upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); +Route::post('/aws-image-upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); From 361ea9719f1875496ffebee9ef2db09682d3cec9 Mon Sep 17 00:00:00 2001 From: Dillon Date: Thu, 8 Jun 2023 08:56:18 +0800 Subject: [PATCH 12/12] Revert previous testing code --- .../AWS/AWSImageUploadController.php | 50 ------------------- .../views/pages/aws_image_upload.blade.php | 43 ---------------- routes/web.php | 5 -- 3 files changed, 98 deletions(-) delete mode 100644 app/Http/Controllers/AWS/AWSImageUploadController.php delete mode 100644 resources/views/pages/aws_image_upload.blade.php diff --git a/app/Http/Controllers/AWS/AWSImageUploadController.php b/app/Http/Controllers/AWS/AWSImageUploadController.php deleted file mode 100644 index b258b3ee..00000000 --- a/app/Http/Controllers/AWS/AWSImageUploadController.php +++ /dev/null @@ -1,50 +0,0 @@ -validate([ - 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', - ]); - - $imageName = time().'.'.$request->image->extension(); - - $request->image->storeAs('images', $imageName); - - return back() - ->with('success','You have successfully upload image.') - ->with('image',$imageName); - } - - - public function displayImage($fileName) - { - $path = 'images/'.$fileName; - $file = Storage::get($path); - $type = Storage::mimeType($path); - - $response = Response::make($file, 200); - $response->header("Content-Type", $type); - - return $response; - } - -} diff --git a/resources/views/pages/aws_image_upload.blade.php b/resources/views/pages/aws_image_upload.blade.php deleted file mode 100644 index 7e6e91f5..00000000 --- a/resources/views/pages/aws_image_upload.blade.php +++ /dev/null @@ -1,43 +0,0 @@ -@extends('layouts.base_portal') -@section('inner_content') -
-
-

Image Upload with Laravel Vapor

-
- - @if ($message = Session::get('success')) -
- - {{ $message }} -
- - @endif - - @if (count($errors) > 0) -
- Whoops! There were some problems with your input. -
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - -
- @csrf -
-
- -
- -
- -
-
-
-
-
-
-@endsection diff --git a/routes/web.php b/routes/web.php index 53260db6..7ba6d068 100644 --- a/routes/web.php +++ b/routes/web.php @@ -601,8 +601,3 @@ Route::get('/po/outsource/check', function(){ Route::get('/upload-honey-trap', function () { return view('pages.honey_trap'); })->name('upload_honey_trap'); - - -Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); -Route::post('/aws-image-upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); -Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage');