How to implement multiple field searching in laravel? -


i have been working on project have 2 tables posts , description. need implement multiple field searching, when select 1 or more option should display result matching selected option(s). don't know how without bulk of if else conditions. please ! table structure

posts table id | posttype | featured description id |p_id | region | town have tried if else coditions, have check every posible conditon.

i'd suggest use datatables. lightweight (and free) javascript plugin displays data database in sortable , searchable table via ajax. tables made multiple search.

there good package makes use of datatables laravel5 easier.


when don't want use datatables, try eloquent solution:

$query = "%{$thevalueyouaresearchingfor}%" $resultset = posts::where('featured', 'like', $query')            ->orwherehas('description', function($query) use ($query){                     $query->where('region', 'like', $query)                        ->orwhere('town', 'like', $query);                 }) 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -