Skip to content

Commit

Permalink
Merge pull request #2 from ruchit-viitorcloud/master
Browse files Browse the repository at this point in the history
Code refactoring
  • Loading branch information
ruchit288 authored Jan 8, 2019
2 parents 9bd96b2 + 8ebf626 commit 6afedbe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ function refiner($request)
if (is_array($request)) {
return $request;
}

$requestData = $request->all();

if ($requestData) {
foreach ($requestData as $individualKey => $individualValue) {
foreach ($requestData as $key => $value) {
$filterString = [];
$requestedString = [];

if (!is_array($individualValue)) {
$requestedString = strtolower($individualValue);
if (!is_array($value)) {
$requestedString = strtolower($value);
$requestedString = explode(' ', $requestedString);
}

Expand All @@ -27,13 +29,14 @@ function refiner($request)

foreach ($requestedString as $words) {
$filterWords = rtrim(clean($words), '.');

if (!isset($detectWords[$filterWords])) {
$filterString[] = $words;
}
}

$filterString = implode(' ', $filterString);
$request = $request->merge([$individualKey => $filterString]);
$request = $request->merge([$key => $filterString]);
}
}

Expand Down

0 comments on commit 6afedbe

Please sign in to comment.