I have a controller in Laravel that currently looks like this
public function index($merchant_url_text)
{
$deals = DB::table('tbl_deal')
-> join ('tbl_merchant', 'tbl_deal.merchant_id', '=', 'tbl_merchant.merchant_id')
-> where ('merchant_url_text', $merchant_url_text)->get();
return $deals;
}
What I want to add to this controller is another query.
$merchant_name = DB::table('tbl_merchant')->where('merchant_url_text', $merchant_url_text)->value('merchant_name');
How do I make sure I can return just the single merchant_name along with the current rows that are being passed in $rows
Just return both of them in an associative array:
return array(
'merchant_name' => $merchant_name,
'deals' => $deals,
);