lundi 20 juin 2016

Filtering on Laravel

i have project, in there i want to add filter fiture in there. i can make it but i have bug in my script. when i create new data booking in same title/post the filter list is increase and have same title/post. but in there i just want to make list of them. its my error

wrong

its should be :

  • Kost Alpha Charlie Delta Echo
  • Kost Fanta Bintaro
  • Home Test

here my controller :

public function getIndex()
    {
        $list = DB::table('data_kos')
        ->orderBy('id','asc')
        ->get();

        $limit = 10;
        $result = DB::table('data_kos')
        ->orderBy('id','asc');
        if(Request::get('q')) {
            $q = Request::input("q");
            $posts->where('title','like','%'.Request::get('q').'%');
            $posts->orwhere("sex","like","%".Request::get("q")."%");
            $posts->orwhere("price","like","%".Request::get("q")."%");
        }
        if(Request::get('title')) {
            $result = $result->where("title",Request::get("title"));
        }
        $data['list'] = $list;
        $data['posts'] = $result->paginate($limit);
        return view('kost', $data);
    }

and this my view :

@foreach($list as $row)
        <li><a href=''></a></li>
        @endforeach

have someone give me solution ? what i need to change in my code.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire