php - 是否可以在 Laravel 8 中返回 2 个变量?
问题描述
//Create Borang Pendaftaran
public function CreateForm()
{
$names = DB::table('pendaftaran')
->where('isActive',1)
->orderBy('id','desc')
->get();
$names2 = DB::table('pendaftaran')
->where('isActive',0)
->orderBy('id','desc')
->get();
return view('contact',['names' =>$names]);
}
我所做的更改是
返回视图('联系人',['names' =>$names,$names2]);
解决方案
使用这个:
$contact= [
'name' => $names,
'names2' => $names2,
];
return view('contact',comapact('contact');
推荐阅读
- python - 我必须先运行 get-item 或 set-item 命令,然后我的 winrm 远程命令才能工作
- ios - 对 UITableView 的 tableHeaderView 使用约束,tableHeaderView 出现在单元格的顶部
- gtsummary - 胶水不能将函数插入字符串。* 对象 'n' 是一个函数
- next.js - WowJs React 使用效果
- python - API reading error: ValueError: Mixing dicts with non-Series may lead to ambiguous ordering
- javascript - Is there any other simple way to change my vanilla JavaScript code?
- python - Time complexity for a sorted container
- asp.net - Put method in web api (EF)
- python - 在 IE 中使用 Selenium python 的整页截图
- flutter - 按其值排序列表映射,保持 Flutter 中的顺序