Skip to content

Commit

Permalink
Order and session alerts reorder positions
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 11, 2024
1 parent 171499d commit 03bd252
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/Livewire/AutoOrderCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Livewire;

use App\Models\Order;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
use Livewire\Component;

Expand All @@ -20,13 +21,17 @@ class AutoOrderCreate extends Component

public function mount()
{
// Check if the order data is available in the session
if (!session()->has('orderData')) {
return redirect()->route('orders.create');
}
$orderData = session('orderData');
$this->title = $orderData['title'] ?? '';
$this->description = $orderData['description'] ?? '';
$this->totalPrice = $orderData['total_price'] ?? 0;
}

public function createOrder()
public function createOrder(): RedirectResponse
{
$this->validate();

Expand Down
6 changes: 4 additions & 2 deletions app/Livewire/OrderCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

namespace App\Livewire;

use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
use Livewire\Component;
use App\Models\Order;
use Livewire\Features\SupportRedirects\Redirector;

class OrderCreate extends Component
{
public $title;
public $description;
public $total_price;

public function createOrder()
public function createOrder(): Redirector
{
$this->validate([
'title' => 'required|string|max:255',
Expand All @@ -30,7 +32,7 @@ public function createOrder()

$this->reset(['title', 'description', 'total_price']);

return redirect()->route('orders.pay', ['orderId' => $order->id]);
return redirect()->route('orders.pay', ['orderId' => $order->id])->with('success', 'Order created successfully.');
}

public function render(): View
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<body class="font-sans antialiased">
<div class="min-h-screen bg-white">
<livewire:navbar/>
@include('session.alerts')
<div class="flex relative gap-2 p-2">
<livewire:sidebar/>
<!-- Page Content -->
<main class="w-full bg-gray-100 overflow-clip rounded-[16px]">
@include('session.alerts')
<main class="w-full bg-gray-100 text-black/80 overflow-clip rounded-[16px]">
{{ $slot }}
</main>
</div>
Expand Down

0 comments on commit 03bd252

Please sign in to comment.