Skip to content

Commit

Permalink
Previous orders fetch from the database
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 15, 2024
1 parent cf3e50d commit 1896821
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 66 deletions.
6 changes: 0 additions & 6 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
use Illuminate\Support\Facades\Mail;
use Illuminate\View\View;
use Illuminate\Http\Request;
use JetBrains\PhpStorm\NoReturn;

class PagesController extends Controller
{
public function dashboard(): View
{
$orders = Order::where('user_id', auth()->id())->get();
return view('dashboard', ['orders' => $orders]);
}

public function orderCreate(): View
{
Expand Down
6 changes: 6 additions & 0 deletions app/Livewire/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

class Dashboard extends Component
{
public $orders;
public function mount(): void
{
$this->orders = auth()->user()->orders;
}

public function render(): View
{
return view('dashboard');
Expand Down
65 changes: 5 additions & 60 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,67 +63,12 @@ class="text-white border border-white p-2 px-4 rounded-lg hover:text-white">View

<div class="mt-6 md:px-2 w-full text-white">
<div class="text-xl flex justify-between items-center font-semibold">
3 Previous Orders
Previous Orders
<i class="fas btn btn-circle btn-sm bg-white text-blue-500 btn-ghost hover:text-white hover:ring ring-white fa-calendar-alt"></i>
</div>

<div class="orders">
<div class="item mt-4">
<span class="text-sm text-gray-200">
12th Feb, 2024
</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">
09:00
</div>
<!-- Vertical Line -->
<div class="w-1 h-10 rounded-lg bg-blue-700 mx-2"></div>
<div class="">
<h4 class="text-xs text-gray-200 font-normal">Computer Science</h4>
<p class="text-lg">Java Programming</p>
</div>
</div>
</div>

<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">
12:34
</div>
<!-- Vertical Line -->
<div class="w-1 h-10 rounded-lg bg-green-400 mx-2"></div>
<div class="">
<h4 class="text-xs text-gray-200 font-normal">History</h4>
<p class="text-lg">Ukraine History</p>
</div>
</div>
</div>

<div class="day mt-4">
<span class="text-sm text-gray-200">
34th Oct, 2023
</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">
23:00
</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">Philosophy</h4>
<p class="text-lg text-ellipsis whitespace-nowrap mr-2">Geo Evolution</p>
</div>
</div>
</div>

</div>

<div class="item overflow-scroll mt-4">
@foreach($orders as $order)
<div class="day mt-4">
<span class="text-sm text-gray-200">
Expand All @@ -137,10 +82,10 @@ class="flex justify-between bg-white bg-opacity-10 p-2 w-full rounded-lg items-c
{{ $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="w-1 h-10 rounded-lg {{ $order->getStatusClass() }} 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>
<h4 class="text-lg text-gray-10 font-semibold">{{ $order->title }}</h4>
<p class="text-xs text-ellipsis whitespace-nowrap mr-2">{{ Str::limit($order->description, 25) }}</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 1896821

Please sign in to comment.