diff --git a/app/Livewire/Alerts.php b/app/Livewire/Alerts.php index 5fb228a..0879a4c 100644 --- a/app/Livewire/Alerts.php +++ b/app/Livewire/Alerts.php @@ -4,7 +4,6 @@ use Illuminate\View\View; use Livewire\Component; - class Alerts extends Component { public function render(): View diff --git a/app/Livewire/OrderEdit.php b/app/Livewire/OrderEdit.php index 774c781..513a173 100644 --- a/app/Livewire/OrderEdit.php +++ b/app/Livewire/OrderEdit.php @@ -3,9 +3,14 @@ namespace App\Livewire; use App\Models\Order; +use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Redirect; use Illuminate\View\View; use Livewire\Component; +use Illuminate\Support\Facades\Session; +use Livewire\Features\SupportRedirects\Redirector; + class OrderEdit extends Component { public Order $order; @@ -24,10 +29,14 @@ public function mount(Order $order): void $this->paymentStatus = $order->payment->status ?? 'pending'; } - public function save(): void + public function save(): RedirectResponse | Redirect | Redirector { $this->validate(); + if ($this->order->status === $this->status && $this->order->payment->status === $this->paymentStatus) { + return redirect()->route('orders.show', $this->order)->with('warning', 'Order updated successfully.'); + } + $this->order->status = $this->status; $this->order->save(); @@ -42,7 +51,7 @@ public function save(): void } } - session()->flash('message', 'Order updated successfully.'); + return redirect()->route('orders.show', $this->order)->with('warning', 'Order updated successfully.'); } public function render(): View diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 91c2c07..a3ab30a 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -27,6 +27,7 @@ public function getStatusClass(): string return match ($this->status) { 'pending' => 'bg-gray-500', 'completed' => 'text-green-500 bg-green-500', + 'failed' => 'text-red-500 bg-red-500', default => 'text-gray-500', }; } diff --git a/resources/views/orders/view.blade.php b/resources/views/orders/view.blade.php index c4ff0c0..f784b25 100644 --- a/resources/views/orders/view.blade.php +++ b/resources/views/orders/view.blade.php @@ -109,7 +109,7 @@ class="absolute top-0 btn btn-xs btn-circle btn-ghost bg-blue-500 right-0 mt-1 m