diff --git a/resources/views/index.php b/resources/views/index.php index d2c69103..5cd2f7a2 100644 --- a/resources/views/index.php +++ b/resources/views/index.php @@ -231,6 +231,29 @@

Total: , changed:

+
+
+
+
+ +
+ +
+
+
+
+
+ Search in + + searchKeys === 'false' ? '' : 'checked' ?> class="form-check-input" id="searchKeys"> + + + searchValues === 'false' ? '' : 'checked' ?> class="form-check-input" id="searchValues"> + +
+
diff --git a/src/Controller.php b/src/Controller.php index 31ab43c0..13e0f2d0 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -32,8 +32,19 @@ public function getIndex($group = null) $groups = [''=>'Choose a group'] + $groups; $numChanged = Translation::where('group', $group)->where('status', Translation::STATUS_CHANGED)->count(); + $allTranslations = Translation::where('group', $group); + if($searchKeywords = request()->keywords){ + $allTranslations->where(function ($query) use ($searchKeywords) { + $query->when(request()->searchKeys == 'true', function ($query) use ($searchKeywords) { + return $query->where('key', 'like', '%' . $searchKeywords . '%'); + }) + ->when(request()->searchValues == 'true', function ($query) use ($searchKeywords) { + return $query->orWhere('value', 'like', '%' . $searchKeywords . '%'); + }); + }); + } + $allTranslations = $allTranslations->orderBy('key', 'asc')->get(); - $allTranslations = Translation::where('group', $group)->orderBy('key', 'asc')->get(); $numTranslations = count($allTranslations); $translations = []; foreach($allTranslations as $translation){