From 9fa20c50223d282c485b01feb715ee4144b6389c Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Sat, 15 Jun 2024 12:36:18 +0300 Subject: [PATCH] Get order and verify it in the payments show page --- app/Http/Controllers/PagesController.php | 3 ++- app/Livewire/OrderPayment.php | 2 +- app/Livewire/VerifyOrderPayment.php | 24 +++++++++++++++++++++++- resources/views/dashboard.blade.php | 24 ++++++++++++++++++++++++ resources/views/layouts/guest.blade.php | 2 +- routes/web.php | 1 - 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 5961349..588af1f 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -12,7 +12,8 @@ class PagesController extends Controller { public function dashboard(): View { - return view('dashboard'); + $orders = Order::where('user_id', auth()->id())->get(); + return view('dashboard', ['orders' => $orders]); } public function orderCreate(): View diff --git a/app/Livewire/OrderPayment.php b/app/Livewire/OrderPayment.php index 2f99f72..2dfdaa7 100644 --- a/app/Livewire/OrderPayment.php +++ b/app/Livewire/OrderPayment.php @@ -70,7 +70,7 @@ public function pay() // session()->flash('success', 'Payment initiated successfully. Please wait for confirmation.'); // TODO: Send notification to the writer // Redirect to the dashboard - return redirect()->route('payment', ['paymentId' => $payment->id])->with('success', 'Payment initiated successfully. Please wait for confirmation.'); + return redirect()->route('payments.show', ['paymentId' => $payment->id])->with('success', 'Payment initiated successfully. Please wait for confirmation.'); } public function render(): View diff --git a/app/Livewire/VerifyOrderPayment.php b/app/Livewire/VerifyOrderPayment.php index cb2d253..d78874d 100644 --- a/app/Livewire/VerifyOrderPayment.php +++ b/app/Livewire/VerifyOrderPayment.php @@ -2,11 +2,33 @@ namespace App\Livewire; +use App\Models\Order; +use App\Models\Payment; +use Illuminate\View\View; use Livewire\Component; class VerifyOrderPayment extends Component { - public function render() + public Payment $payment; + public Order $order; + public function mount($paymentId): void + { + $this->payment = Payment::findOrFail($paymentId); + $order_id = $this->payment->order_id; + $this->order = Order::findOrFail($order_id); + $this->checkPaymentStatus(); + } + + public function checkPaymentStatus(): void + { + if ($this->payment->status === 'completed') { + session()->flash('success', 'Payment has been verified successfully'); + } else { + session()->flash('warning', 'Payment verification in progress'); + } + } + + public function render(): View { return view('orders.verify-order-payment'); } diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 2306f2b..9e7d5f0 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -123,6 +123,30 @@ class="flex justify-between bg-white bg-opacity-10 p-2 w-full rounded-lg items-c + + @foreach($orders as $order) +
+ + {{ $order->created_at->format('dS M, Y') }} + + +
+
+
+ {{ $order->created_at->format('H:i') }} +
+ +
+
+

{{ $order->subject }}

+

{{ $order->title }}

+
+
+
+
+ + @endforeach diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index 775e85e..f966672 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -29,7 +29,7 @@ -
+
{{ $slot }}
diff --git a/routes/web.php b/routes/web.php index e47ce88..9e0ac5b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -53,6 +53,5 @@ Route::get('/not-found', [PagesController::class, 'notfound'])->name('not-found'); Route::get('/info/price-calculator', [PagesController::class, 'info_price_calculator'])->name('info.price-calculator'); Route::view('/info/order/create', 'info.order.create')->name('info.order.create'); -//info.order.payment Route::view('/info/order/payment', 'info.order.payment')->name('info.order.payment'); require __DIR__.'/auth.php';