I am new to Laravel,
the query string from url may be three kind
- Both "Filter" and "Status":
http://localhost/products?filter=productName&value=Test+Product+1&status=A&action=Filter+Result
- "Filter" only and "Status" will be empty:
http://localhost/products?filter=productName&value=Test+Product+1&status=&action=Filter+Result
- "Status only and "Filter" will be empty: "Filter" and "Status"
http://localhost/products?filter=&value=&status=A&action=Filter+Result
Now from Controller i can access the Query string with $inputQ = Request::input()
in normal php i can do easy like below
$sql = 'SELECT * FROM products WHERE 1 = 1';
if(isset($_REQUEST['filter']) && $_REQUEST['filter'] != '' && $_REQUEST['value'] != ''){
$sql .= 'AND `'.$_REQUEST['filter'].'` = "'.addslashes($_REQUEST['value']).'"';
}
if(isset($_REQUEST['status']) && $_REQUEST['status'] != ''){
$sql .= 'AND `status` = "'.addslashes($_REQUEST['status']).'"';
}
$res = mysql_query($sql);
Now i need to build Laravel Eloquent please help me.