Example #1
0
 /**
  * search surah depend the keyword
  *
  */
 public function searchKeyword()
 {
     $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
     $surah = isset($_GET['surah']) ? $_GET['surah'] : '';
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     $header_description_add = $pages = '';
     if (!empty($keyword)) {
         $QuranModel = new Quran();
         $search_result = $QuranModel->searchKeyword($keyword, $surah, $page);
         $data['search_result'] = $search_result;
         $count_search = $QuranModel->countSearchKeyword($keyword, $surah);
         $data['count_search'] = $count_search;
         // devide the search page
         if (is_int($count_search)) {
             $pages = round($count_search / 10);
             $data['pages'] = $pages;
             $data['page'] = $page;
         }
         // list surah
         $surahs = $QuranModel->surahSearchKeyword($keyword, $surah);
         $data['surahs'] = $surahs;
         $data['selected_surah'] = $surah;
         $header_description_add = '\'' . $keyword . '\' ditemukan dalam ' . $count_search . ' ayat. ';
     }
     if (empty($surahs)) {
         if (empty($keyword)) {
             return redirect('mushaf')->with('messageError', 'Masukan kata yang ingin dicari!');
         }
         return redirect('mushaf')->with('messageError', 'Data tidak ditemukan!');
     }
     $data['keyword'] = $keyword;
     $data['pages'] = $pages;
     $data['header_title'] = 'Cari Kata \'' . $keyword . '\'';
     $data['header_description'] = $header_description_add . 'Cari kata dalam Al-Quran dan Tafsir Al-Quran';
     return view('mushaf_search', $data);
 }