Skip to content

Commit

Permalink
Fix formatting in question show.blade.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Bijay-Shre-stha committed Mar 22, 2024
1 parent 1a6b9b4 commit 5f35cba
Showing 1 changed file with 45 additions and 43 deletions.
88 changes: 45 additions & 43 deletions resources/views/question/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<x-navbar-layout>
@if (session()->has('success'))
<div id="successMessage" class="alert alert-success">
{{ session()->get('success') }}
</div>
<div id="successMessage" class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
<script src="https://cdn.tiny.cloud/1/ythi0j085mic4ki07jiqtc5bor4z4sutbc0bhh50nxh1r2xp/tinymce/6/tinymce.min.js"
referrerpolicy="origin"></script>
Expand All @@ -18,8 +18,10 @@
</script>

<div class="fw-bolder fs-6 mt-3">
{{ ucfirst($question->title) }}
<p class="mt-2">Description: {{ ucfirst($question->description) }}</p>
<h3 class="fw-bolder mt-2">Question: {{ ucfirst($question->title) }}</h3>

<p class="mt-2">Description:{!! ucfirst($question->description) !!}
</p>
<p>
<small>
Asked by: <span class=" fw-bold ">{{ $question->user->username }}</span>,
Expand All @@ -30,58 +32,58 @@
</div> <br>
<hr class="border-3">
<h2>Some Answers</h2>
<form action="{{ route('answer.index') }}" method="GET" class="answer-sort-form">
<input type="hidden" name="question_id" value="{{ $question->id }}">
<select name="sort" id="sort" class="form-select form-select-lg mb-3 custom-select">
<option value="desc" @if (request('sort', 'desc') == 'desc') selected @endif>Sort by latest</option>
<option value="asc" @if (request('sort') == 'asc') selected @endif>Sort by oldest</option>
</select>
<button type="submit" class="btn btn-info">Sort Answers</button>
</form>
<form action="{{ route('answer.index') }}" method="GET" class="answer-sort-form">
<input type="hidden" name="question_id" value="{{ $question->id }}">
<select name="sort" id="sort" class="form-select form-select-lg mb-3 custom-select">
<option value="desc" @if (request('sort', 'desc' )=='desc' ) selected @endif>Sort by latest</option>
<option value="asc" @if (request('sort')=='asc' ) selected @endif>Sort by oldest</option>
</select>
<button type="submit" class="btn btn-info">Sort Answers</button>
</form>

@if ($answers && count($answers) > 0)
@foreach ($answers as $answer)
<div class="card mb-3 mt-3">
<div class="p-3 fs-6 ">
<p>
{!! ucfirst($answer->answer) !!}
</p>
</div>
<div class="card-footer">
<small class=" fs-5 ">
Answered: <br>
<div class=" mt-2 ">
<img src="{{ $answer->user->avatar }}" alt="{{ $answer->user->username }}" width="30"
height="30"> <span class=" fw-bold ">{{ $answer->user->username }}</span>,
<br>
<b>-{{ $answer->created_at->diffForHumans() }}</b>
</div>
</small>
@foreach ($answers as $answer)
<div class="card mb-3 mt-3">
<div class="p-3 fs-6 ">
<p>
{!! ucfirst($answer->answer) !!}
</p>
</div>
<div class="card-footer">
<small class=" fs-5 ">
Answered: <br>
<div class=" mt-2 ">
<img src="{{ $answer->user->avatar }}" alt="{{ $answer->user->username }}" width="30" height="30">
<span class=" fw-bold ">{{ $answer->user->username }}</span>,
<br>
<b>-{{ $answer->created_at->diffForHumans() }}</b>
</div>
</div>
@endforeach
</small>
</div>
</div>
@endforeach
@else
<p>No answers found for this question.</p>
<p>No answers found for this question.</p>
@endif
<hr class="border-3 mt-5">
<h4 class="mt-2 pt-1 text-success">Your answer</h4>

@auth
<form action="{{ route('answer.store') }}" method="post">
@csrf
@method('POST')
<form action="{{ route('answer.store') }}" method="post">
@csrf
@method('POST')

<input type="hidden" name="question_id" value="{{ $question->id }}">
<input type="hidden" name="user_id" value="{{ auth()->user()->id }}">
<textarea name="answer" id="answer"></textarea>
<button type="submit" class="btn btn-success mt-3 p-3 fs-4">Post your answer</button>
</form>
<input type="hidden" name="question_id" value="{{ $question->id }}">
<input type="hidden" name="user_id" value="{{ auth()->user()->id }}">
<textarea name="answer" id="answer"></textarea>
<button type="submit" class="btn btn-success mt-3 p-3 fs-4">Post your answer</button>
</form>
@else
<p>Please <strong><a href="{{ route('login') }}">log in</a></strong> to post an answer.</p>
<p>Please <strong><a href="{{ route('login') }}">log in</a></strong> to post an answer.</p>
@endauth
<script>
setTimeout(function() {
$('#successMessage').fadeOut('fast');
}, 2000);
</script>
</x-navbar-layout>
</x-navbar-layout>

0 comments on commit 5f35cba

Please sign in to comment.