Skip to content

Commit

Permalink
Get order and verify it in the payments show page
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 15, 2024
1 parent caf51aa commit 9fa20c5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/OrderPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion app/Livewire/VerifyOrderPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
24 changes: 24 additions & 0 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ class="flex justify-between bg-white bg-opacity-10 p-2 w-full rounded-lg items-c
</div>

</div>

@foreach($orders as $order)
<div class="day mt-4">
<span class="text-sm text-gray-200">
{{ $order->created_at->format('dS M, Y') }}
</span>

<div
class="flex justify-between bg-white bg-opacity-10 p-2 w-full rounded-lg items-center mt-2">
<div class="flex items-center gap-4">
<div class="text-lg w-14 font-semibold text-blue-50">
{{ $order->created_at->format('H:i') }}
</div>
<!-- Vertical Line -->
<div class="w-1 h-10 rounded-lg bg-red-500 mx-2"></div>
<div class="mr-2">
<h4 class="text-xs text-gray-200 font-normal">{{ $order->subject }}</h4>
<p class="text-lg text-ellipsis whitespace-nowrap mr-2">{{ $order->title }}</p>
</div>
</div>
</div>
</div>

@endforeach
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/guest.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
</div>

<div class="w-full flex flex-col sm:max-w-md mt-6 px-6 py-4 overflow-hidden sm:rounded-lg">
<div class="w-full flex flex-col sm:max-w-md mt-6 mb-6 px-6 py-4 overflow-hidden sm:rounded-lg">
{{ $slot }}
</div>

Expand Down
1 change: 0 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 9fa20c5

Please sign in to comment.