Php 如何使用laravel排列交叉连接结果

Php 如何使用laravel排列交叉连接结果,php,html,laravel,Php,Html,Laravel,我使用交叉连接得到两个表的结果。但是当我试图在视图中显示它时,我得到了这个错误 对数组上的成员函数crossJoin()的调用 那么如何在HTML表中排列它呢?看起来像下面 barcode | desc | qty | branch1 | branch2 | branch3 | branch4 ------------------------------------------------------------ 123456 | lenovo| 100 | null | null

我使用交叉连接得到两个表的结果。但是当我试图在视图中显示它时,我得到了这个错误

对数组上的成员函数crossJoin()的调用

那么如何在HTML表中排列它呢?看起来像下面

barcode | desc | qty | branch1 | branch2 | branch3 | branch4
------------------------------------------------------------
123456  | lenovo| 100  |  null   |  null   |  null   |  null   
252666  | hp    | 100  |  null   |  null   |  null   |  null  
895566  | acer  | 70   |  null   |  null   |  null   |  null  
968411  | apple | 800  |  null   |  null   |  null   |  null  
这是我的密码

$receiving=DB::select('select*from branch')
->交叉连接('allocation_stocks')->get();
返回视图('operation.home',['data'=>$receiving]);
表2.库存分配

barcode | desc | qty 
----------------------
123456  | lenovo| 100  
252666  | hp    | 100 
895566  | acer  | 70   
968411  | apple | 800  
桌支

brach_name|
-----------
branch1 
branch2 
branch3 
branch4 

尝试此查询。应该行得通

$receiving=DB::table('branch')
->交叉连接(“分配库存”)
->get();
返回视图('operation.home',['data'=>$receiving]);

尝试此查询。应该行得通

$receiving=DB::table('branch')
->交叉连接(“分配库存”)
->get();
返回视图('operation.home',['data'=>$receiving]);
要执行“交叉连接”,请使用交叉连接方法和您希望交叉连接到的表的名称

交叉联接在第一个表和联接表之间生成笛卡尔积:

$receiving = DB::table('branch')
    ->crossJoin('allocation_stocks')
    ->get();
另见:

要执行“交叉连接”,请使用带有要交叉连接到的表名称的交叉连接方法

交叉联接在第一个表和联接表之间生成笛卡尔积:

$receiving = DB::table('branch')
    ->crossJoin('allocation_stocks')
    ->get();
另见:


如何安排。而分支位于标题部分。使用方法。如何排列。而分支位于标题部分。使用方法。
$result = DB::table('branch')
               ->crossJoin('allocation_stocks')
               ->get();

return view('operation.home', ['data' => $result]);