-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter event controller index results #481
Filter event controller index results #481
Conversation
was causing an infinite recursion loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there was an issue with recursive relations loading, i fixed that for you, but while looking at this i noticed that this doesn't capture the exact filtering criteria properly as well
@@ -16,8 +16,11 @@ class EventController extends Controller | |||
*/ | |||
public function index(Request $request) | |||
{ | |||
$events = Event::all(); | |||
$events = Event::whereRegistered() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have this here, it means that we're always filtering the events by if a user is registered or not. What you'd want to do is check for a flag like $request->has('registered_only')
or what ever name you want in an if statement, if it has that then you add the whereRegistered()
call, otherwise don't add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments for ya!
$response = $this->actingAs($user)->get(route('event.index', [ | ||
'search' => $event->title, | ||
'registered_only' => true, | ||
'registered_user' => $user->id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about a test for if registered_user
is null? i suspect it likely will be null since 99% of the time we're filtering this list for the logged in user, which whereRegistered()
does automatically
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems about right to me!
Description
Closes #437