How can i combine 2 variable data in Laravel. Im trying combine data in $income1 and $income2 become $income data show all data from $income1 and $income2
Here my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Product;
use App\Blok;
class ProductController extends Controller
{
public function income()
{
$products = Product::all();
$income1 = \App\Pembelian::join('debitur','debitur.id','=','pembelian.debiturID')
->join('blok','blok.blok_id', '=', 'debitur.blokID')
->join('products','products.id', '=', 'blok.productID')
->get();
$income2 = \App\Pembayaran::join('angsuran','angsuran.id','=','pembayaran.angsurID')
->join('debitur','debitur.id','=','angsuran.debiturID')
->join('blok','blok.blok_id', '=', 'debitur.blokID')
->join('products','products.id', '=', 'blok.productID')
->get();
$income = collect($income1, $income2);
$income->all();
return view('income', compact('products', 'income'));
}
}
But it end up only showing $income1 data. Anyone can help me?
Aucun commentaire:
Enregistrer un commentaire