Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Final feature
  • Loading branch information
djaiss committed Feb 25, 2018
commit 0d168279e9555f42d42e9f95ec4da971ec28bb9c
10 changes: 7 additions & 3 deletions app/Http/Controllers/Api/ApiContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ public function index(Request $request)
if ($request->get('query')) {
$needle = $request->get('query');
$contacts = SearchHelper::searchContacts($needle, $this->getLimitPerPage());
} else {
$contacts = auth()->user()->account->contacts()->real()
->paginate($this->getLimitPerPage());

return ContactResource::collection($contacts)->additional(['meta' => [
'query' => $needle,
]]);
}

$contacts = auth()->user()->account->contacts()->real()
->paginate($this->getLimitPerPage());

return ContactResource::collection($contacts);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Api/Contact/ApiContactControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function test_it_applies_the_limit_parameter_in_search()
]);
}

public function test_it_is_possible_to_search_for_specific_contact()
public function test_it_is_possible_to_search_for_a_specific_contact()
{
$user = $this->signin();

Expand All @@ -93,6 +93,7 @@ public function test_it_is_possible_to_search_for_specific_contact()
$response->assertJsonFragment([
'first_name' => 'roger',
'total' => 1,
'query' => 'ro',
]);
}
}