Skip to content

Commit

Permalink
Added more session checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 10, 2024
1 parent c587594 commit a71bcb8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
14 changes: 4 additions & 10 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ public function dashboard(): View
return view('dashboard');
}

#[NoReturn]
public function orderCreate(): void
public function orderCreate(): View
{
$orderData = session('orderData');
dd($orderData);
//array:5 [▼ // app/Http/Controllers/PagesController.php:22
// "user_id" => null
// "title" => null
// "description" => null
// "total_price" => 28
// "status" => "pending"
//]
//set the user_id to the authenticated user
$orderData['user_id'] = auth()->id();

return view('order.create', ['orderData' => $orderData]);
}

public function contact(): View
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/StaticPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class StaticPageController extends Controller
{
public function welcome(): View
{
session()->flash('success', 'Welcome to Scholarspace! Get help with your assignments from expert writers.');

$process_steps = [
[
'icon' => 'fas avatar fa-pen-nib',
Expand Down
9 changes: 8 additions & 1 deletion app/Livewire/PriceCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ public function placeOrder()
$this->reset(['topic', 'subject', 'word_count']);

// redirect to the order creation page
return redirect()->route('orders.create.new');
if (!auth()->check()) {
$message = 'You need to login or register to place an order';
session()->flash('error', $message);
}else{
$message = 'Order placed successfully';
}

return redirect()->route('orders.create.new')->with('success', $message);
}

public function render(): View
Expand Down
1 change: 1 addition & 0 deletions resources/views/components/logged-out.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="font-sans min-h-screen flex justify-between flex-col bg-gray-50 antialiased">
@include('layouts.navigation.logged-out')
@include('session.alerts')
{{ $slot }}
@include('layouts.footer')
</body>
Expand Down
3 changes: 3 additions & 0 deletions resources/views/order/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<x-app-layout>

</x-app-layout>
18 changes: 15 additions & 3 deletions resources/views/session/alerts.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
<!--Check if there are any messages within the session-->
@if(session('success'))
<div class="alert rounded mt-3 alert-success">
<div class="alert rounded-none mt-3 alert-success">
{{ session('success') }}
</div>
@endif

@if(session('error'))
<div class="alert rounded mt-3 bg-red-500 alert-danger">
<div class="alert rounded-none mt-3 bg-red-500 alert-danger">
{{ session('error') }}
</div>
@endif

@if(session('info'))
<div class="alert rounded-none mt-3 bg-blue-500 alert-info">
{{ session('info') }}
</div>
@endif

@if(session('warning'))
<div class="alert rounded-none mt-3 bg-yellow-500 alert-warning">
{{ session('warning') }}
</div>
@endif

@if ($errors->any())
<div class="alert rounded mt-3 bg-red-500 alert-danger">
<div class="alert rounded-none mt-3 bg-red-500 alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
Expand Down

0 comments on commit a71bcb8

Please sign in to comment.