jeudi 17 août 2017

Two wheres and One orWhere Laravel Conditions

i want to search in Lists and get only the results with id, but search in title and seach in description, i dont want title and description i want title or description, but with this way i get all the results with coincidence in description not is limited for the first condition id, regards.

public function search_list( Request $request ){

    $id = $request->input("id_search");

    $data = $request->input("search");

    $lists = Lists::where( 'lists.id_user', $id )
                ->where( "title", "like", "%".$data."%" )
                ->orwhere( "description", "like", "%".$data."%" )
                ->paginate( 10 );

    return view( 'user.lists.list_lists' )
                ->with( "lists", $lists )
                ->with( "data", $data );

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2v5JNNl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire