SearchUtility.php 557 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Utility;
  3. use App\Models\Search;
  4. class SearchUtility
  5. {
  6. public static function store($query)
  7. {
  8. if ($query != null && $query != "") {
  9. $search = Search::where('query', $query)->first();
  10. if ($search != null) {
  11. $search->count = $search->count + 1;
  12. $search->save();
  13. } else {
  14. $search = new Search;
  15. $search->query = $query;
  16. $search->count = 1;
  17. $search->save();
  18. }
  19. }
  20. }
  21. }