Ejemplo n.º 1
0
 public function searchresults($cari)
 {
     $profil_id = Profil::where('judul_profil', 'LIKE', '%' . $cari . '%')->orWhere('konten', 'LIKE', '%' . $cari . '%')->latest()->get();
     $artikel_id = Artikel::with('kategori')->where('judul_artikel', 'LIKE', '%' . $cari . '%')->orWhere('isi', 'LIKE', '%' . $cari . '%')->latest()->get();
     $profil_en = About::where('judul_profil', 'LIKE', '%' . $cari . '%')->orWhere('konten', 'LIKE', '%' . $cari . '%')->latest()->get();
     $artikel_en = Article::with('kategori')->where('judul_artikel', 'LIKE', '%' . $cari . '%')->orWhere('isi', 'LIKE', '%' . $cari . '%')->latest()->get();
     #Gabung hasil pencarian halaman INDONESIA
     $hasil_id = array_merge($profil_id->toArray(), $artikel_id->toArray());
     #Pagination Manual
     $perHalaman = 3;
     $total_hasil_id = count($hasil_id);
     $total_halaman = ceil($total_hasil_id / $perHalaman);
     #Cek user menuju halaman yang tidak ada/kembalikan ke page 1
     $page = Request::input('page', 1);
     if ($page > $total_halaman or $page < 1) {
         $page = 1;
     }
     #Hitung halaman mulai per page
     $mulai_halaman = $page * $perHalaman - $perHalaman;
     #Bagi hasil sesuai potongan
     $hasil_id = array_slice($hasil_id, $mulai_halaman, $perHalaman);
     #Buat paginasi
     $paginate_id = new Paginator($hasil_id, $total_hasil_id, $perHalaman);
     #Set Path
     $paginate_id->setPath($cari);
     #Gabung hasil pencarian halaman ENGLISH
     $hasil_en = array_merge($profil_en->toArray(), $artikel_en->toArray());
     #Pagination Manual
     $perHalaman = 5;
     $total_hasil_en = count($hasil_en);
     $total_halaman = ceil($total_hasil_en / $perHalaman);
     #Cek user menuju halaman yang tidak ada/kembalikan ke page 1
     $page = Request::input('page', 1);
     if ($page > $total_halaman or $page < 1) {
         $page = 1;
     }
     #Hitung halaman mulai per page
     $mulai_halaman = $page * $perHalaman - $perHalaman;
     #Bagi hasil sesuai potongan
     $hasil_en = array_slice($hasil_en, $mulai_halaman, $perHalaman);
     #Buat paginasi
     $paginate_en = new Paginator($hasil_en, $total_hasil_en, $perHalaman);
     #Set Path
     $paginate_en->setPath($cari);
     return view('homepage.search', compact('cari', 'hasil_id', 'paginate_id', 'hasil_en', 'paginate_en'));
 }
Ejemplo n.º 2
0
<?php

use contoh\Profil;
use contoh\About;
use contoh\KategoriArtikel;
#ViewShare
if (Schema::hasTable('profil') and Schema::hasTable('about') and Schema::hasTable('kategori_artikel')) {
    View::share('daftarprofil', Profil::oldest()->get());
    View::share('aboutlist', About::oldest()->get());
    View::share('kategori_artikel', KategoriArtikel::oldest()->get());
}
$bahasa = Request::segment(1);
if (in_array($bahasa, Config::get('app.bahasa'))) {
    App::setLocale($bahasa);
} else {
    $bahasa = 'id';
}
#RouteGroup MultiLanguage
Route::group(['prefix' => $bahasa], function () {
    Route::get('/', ['as' => 'home', 'uses' => 'HomepageController@index']);
    #Search
    Route::post('search', ['as' => 'search', 'uses' => 'HomepageController@search']);
    Route::get('search/{cari}', ['as' => 'searchresults', 'uses' => 'HomepageController@searchresults']);
    #AdminHome
    Route::get('home', ['as' => 'admin-homepage', 'uses' => 'AdminController@homepage']);
    #Profil
    #Showprofil - ID
    Route::get('profil/{slug}', ['as' => 'showprofil_id', 'uses' => 'ProfilController@showprofil_id']);
    #Showprofil - EN
    Route::get('about/{slug}', ['as' => 'showprofil_en', 'uses' => 'ProfilController@showprofil_en']);
    #Berita
Ejemplo n.º 3
0
 public function deleteprofil_id($slug)
 {
     $profil = Profil::whereSlug($slug)->firstOrFail();
     $profil->delete();
     return redirect()->route('admin-profil_id')->with('message', 'Profil telah dihapus...');
 }