From c366302a12a3e02a8eeb5346793f142e081cb0fe Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Tue, 21 May 2024 07:47:05 +0300 Subject: [PATCH] Custom btn styles --add component, add route to create an order --- app/Livewire/CreateOrder.php | 17 +++++++++++++++++ app/Livewire/OrderShow.php | 13 ++++++++++++- resources/css/app.css | 4 ++++ resources/views/orders/index.blade.php | 11 ----------- resources/views/orders/show.blade.php | 9 +++++++-- routes/web.php | 3 +++ 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 app/Livewire/CreateOrder.php diff --git a/app/Livewire/CreateOrder.php b/app/Livewire/CreateOrder.php new file mode 100644 index 0000000..22fd2a3 --- /dev/null +++ b/app/Livewire/CreateOrder.php @@ -0,0 +1,17 @@ + + {{-- Knowing others is intelligence; knowing yourself is true wisdom. --}} + + HTML; + } +} diff --git a/app/Livewire/OrderShow.php b/app/Livewire/OrderShow.php index 8a24435..2d37446 100644 --- a/app/Livewire/OrderShow.php +++ b/app/Livewire/OrderShow.php @@ -13,6 +13,12 @@ class OrderShow extends Component public string $sortField = 'id'; // Default sort field public bool $sortAsc = true; // Default sort direction + public string $role; + + public function mount(): void + { + $this->role = auth()->user()->role ?? 'client'; + } protected $listeners = ['orderCreated' => 'refreshOrders']; @@ -41,8 +47,13 @@ public function getSortIcon($field): string public function render(): View { + if ($this->role === 'writer') { + $orders = Order::orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc')->paginate(10); + } else { + $orders = Order::where('user_id', auth()->id())->orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc')->paginate(10); + } return view('orders.show', [ - 'orders' => Order::orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc')->paginate(10) + 'orders' => $orders ]); } } diff --git a/resources/css/app.css b/resources/css/app.css index e8a5bcc..6883d97 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -63,3 +63,7 @@ input:-webkit-autofill { .message-input{ @apply w-full rounded-md px-4 border border-gray-300 p-3 transition-all duration-300 ease-in-out text-gray-800; } + +.custom-btn{ + @apply bg-blue-500 text-white px-4 py-2 rounded-md transition-all duration-300 ease-in-out hover:bg-blue-600; +} diff --git a/resources/views/orders/index.blade.php b/resources/views/orders/index.blade.php index 9652ac9..9ebb535 100644 --- a/resources/views/orders/index.blade.php +++ b/resources/views/orders/index.blade.php @@ -4,17 +4,6 @@
- - -
-
- -
- -
- -
-
diff --git a/resources/views/orders/show.blade.php b/resources/views/orders/show.blade.php index 145e168..74ea5a4 100644 --- a/resources/views/orders/show.blade.php +++ b/resources/views/orders/show.blade.php @@ -1,4 +1,4 @@ -
+
@if(!$orders->isEmpty())
@@ -26,11 +26,16 @@
@endif -
+
@if($orders->isEmpty())
You haven't placed any orders yet. + @if($role === 'client') + + Place an order + + @endif
@else
diff --git a/routes/web.php b/routes/web.php index e8ecea9..de92dde 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('messages'); Route::get('/orders', Orders::class)->name('orders'); Route::get('/referrals', Referrals::class)->name('referrals'); + + Route::get('/orders/create', CreateOrder::class)->name('orders.create'); }); require __DIR__.'/auth.php';