Skip to content

Commit

Permalink
fix: user show not answered questions
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Mar 22, 2024
1 parent 9a9e418 commit 9c3fe75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Livewire/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function render(): View
return view('livewire.home', [
'questions' => Question::where('answer', '!=', null)
->where('is_reported', false)
->orderByDesc('updated_at')
->orderByDesc('answered_at')
->simplePaginate($this->perPage),
]);
}
Expand Down
5 changes: 1 addition & 4 deletions app/Livewire/Questions/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use App\Models\Question;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Livewire\Attributes\Locked;
Expand Down Expand Up @@ -50,9 +49,7 @@ public function render(Request $request): View
'questions' => $user
->questionsReceived()
->where('is_reported', false)
->when(! $user->is($request->user()), function (Builder $query, bool $_): void { // @phpstan-ignore-line
$query->whereNotNull('answer');
})
->whereNotNull('answer')
->orderByDesc('pinned')
->orderByDesc('answered_at')
->simplePaginate($this->perPage),
Expand Down

0 comments on commit 9c3fe75

Please sign in to comment.