I've got this code in my controller;
$sql = "SELECT * FROM `contracts`.`payments` as t1
LEFT JOIN `postcodes`.`" . $postcode_lookup->dataset . "` AS t2 ON t1.`VendorZIP` = t2.`postcode` WHERE ";
foreach ($input as $key => $value) {
$sql .= "t2." . $key . " IN ('".implode("', '", $input[$key])."') OR ";
}
$sql = rtrim($sql, " OR ");
Which will return a working statement (when ran in SequelPro or PHPMyAdmin for example);
SELECT * FROM `contracts`.`payments` as t1
LEFT JOIN `postcodes`.`201502_postcode` AS t2 ON t1.`VendorZIP` = t2.`postcode`
WHERE t2.country IN ('L93000001', 'E92000001', 'M83000003', 'S92000003')
OR t2.county IN ('E10000002')
OR t2.gor IN ('Z', 'E', 'G', 'H')
OR t2.locauth IN ('S12000033')
OR t2.parlc IN ('W07000049')
How can I use raw queries in Laravel to run this in my application? and $payments = DB::raw($sql);
doesn't do anything.